I'm creating template that defines our prod environment. In our system we will use many Lambda and it produce huge Cloudformation template file with many (even hounded) entries like this presented below. Is possible to split one template file to several separate files (e.g one file for one function or at least one for one service). I know that there is substack mechanism but in substack I cannot store functions definitions in local files (I can only give template URL) and I'm not sure if I can pass argument to substack. As you from example below there are many parameters and references to other resources.
APILambadFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ../lambda_functions/
Handler: getUserInfo.lambda_handler
FunctionName: !Sub ${CreatorUsername}-getUserInfo
Runtime: python3.7
VpcConfig:
SecurityGroupIds:
- !Ref SecurityGroupLamda
SubnetIds:
- !Ref PrivateSubnet1
- !Ref PrivateSubnet2
Role:
Fn::GetAtt: [ RoleLamdaRestAPI, Arn ] # Rola dla wszystkich Lamd restowych
Environment:
Variables:
DB_HOST: !GetAtt 'PostgresDB.Endpoint.Address'
DB_PORT: !GetAtt 'PostgresDB.Endpoint.Port'
DB_NAME: !Sub '{{resolve:ssm:/${CreatorUsername}/${EnvType}/PostgresSQL/DBName:1}}'
DB_USERNAME: !Sub '{{resolve:ssm:/${CreatorUsername}/${EnvType}/PostgresSQL/Username:1}}'
CREATOR_USERNAME: !Ref CreatorUsername
ENV_TYPE: !Ref EnvType
Events:
GetUserInfo:
Type: Api
Properties:
Path: /user
Method: get
RestApiId: !Ref ApiGatewayApi