简体   繁体   中英

AWS Serverless framework : Nested Stack or Cloudformation templates

I am using serverless framework -

https://serverless.com/framework/docs/providers/aws/guide/serverless.yml/

Before I deploy the serverless stack, there are some manual steps, which I need to perform -

  1. Creating S3 buckets
  2. Creating Cognito User Pools, App clients, etc. 3.....

The ARNs of these AWS resources which are created in the above steps, are configured as environment variables in the serverless.yml file.

Apart from this, I want to avoid the possible problem of reaching the AWS cloudformation limit of 200 resources in one stack.

What is the best way/tools to split this stack into two parts?

Are there any examples, in which output of one stack is used as environment variables in the another stack?

Another option, I am thinking is to use the Cloudformation template, which Serverless framework creates and then use it inside a nested CF stack.

Any better options/tools?

Yes. This is very much possible.

Assuming you are using deploying from the same AWS account and Region

Instead of manually creating resources, use serverless to deploy these resources on AWS and use:

resources:
  Outputs:
    BucketName:
      Value:
        Ref: S3BucketResource
      Export:
        Name: VariableNameToImport

You can directly import these variable names in your main serverless.yml file and set them to ENVIRONMENT variables like:

environment:
    S3BucketName:
        'Fn::ImportValue': VariableNameToImport

OPTION 2 (Easier approach)

Or you can simply use plugin: serverless-plugin-split-stacks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM