Functions in additional stacks?
Is there a way to put my functions in different stacks? I'm hitting the resource 200 limit. Thanks
From poking around, it seems the "additional stacks" follow AWS CloudFormation template syntax, so yes, you can put functions in there, but they will be significantly more tedious to work with.
eg. (indents may be off...)
additionalStacks:
stackName:
Deploy: Before
DeployParameters: []
StackName: zenTestAdditionals
Resources:
arbitraryResourceName:
Type: AWS::S3::Bucket
Properties:
BucketName: test-addional-stack-resources-bucket
arbitraryResourceName2:
Type: AWS::Lambda::Function
Properties:
Handler: main
Role: imNotSureIfThisWillHandleVariablesLikeServerless
Code: yourGoingToNeedStuffHere
Wonder if perhaps they will eventually allow definitions like the serverless.yml's default... would be super powerful...
eg. (indents may be off...)
additionalStacks:
stackName:
provider:
name: aws
runtime: nodejs8.10
stage: ${file(./config/serverlessConfig.js):getEnv.stage}
region: ${file(./config/serverlessConfig.js):getEnv.region}
timeout: 300
role: ${file(./config/serverlessConfig.js):getEnv.iamRole}
environment:
NODE_ENV: ${env:NODE_ENV}
NMI_USERNAME: ${file(./config/serverlessConfig.js):getEnv.username}
NMI_PASSWORD: ${file(./config/serverlessConfig.js):getEnv.password}
vpc:
securityGroupIds:
- ${file(./config/serverlessConfig.js):getEnv.superSecure}
subnetIds:
- ${file(./config/serverlessConfig.js):getEnv.pciSubnetIdOne}
plugins:
- serverless-webpack
- serverless-offline
- serverless-prune-plugin
- serverless-domain-manager
- serverless-plugin-warmup
- serverless-content-encoding
- serverless-plugin-additional-stacks
functions:
func1:
handler: src/func1.main
events:
- http:
path: v3/token
method: post
authorizer:
arn: ${file(./config/serverlessConfig.js):getEnv.basicAuthorizer}
Deploy: Before
DeployParameters: []
StackName: testAdditionalStacks
if there is a way to do this, please let me know!
any update, please?
This would really be a big development effort and not in Nordcloud's plans since we don't need this kind of functionality ourselves. Right now the CloudFormation stack definition under additionalStacks is simply deployed verbatim.
My advice would be to split big projects up into multiple serverless.yml projects and define functions in them using the regular Serverless Framework syntax.