serverless-plugin-additional-stacks icon indicating copy to clipboard operation
serverless-plugin-additional-stacks copied to clipboard

Functions in additional stacks?

Open dfloresgonz opened this issue 7 years ago • 3 comments

Is there a way to put my functions in different stacks? I'm hitting the resource 200 limit. Thanks

dfloresgonz avatar Jun 21 '18 23:06 dfloresgonz

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!

elvisOperator avatar Aug 24 '18 22:08 elvisOperator

any update, please?

AhmedNourJamalElDin avatar Apr 30 '20 04:04 AhmedNourJamalElDin

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.

kennu avatar May 14 '20 19:05 kennu