简体   繁体   English

AWS 无服务器框架:嵌套堆栈或 Cloudformation 模板

[英]AWS Serverless framework : Nested Stack or Cloudformation templates

I am using serverless framework -我正在使用serverless framework -

https://serverless.com/framework/docs/providers/aws/guide/serverless.yml/ 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创建 S3 存储桶
  2. Creating Cognito User Pools, App clients, etc. 3.....创建 Cognito 用户池、应用程序客户端等 3 .....

The ARNs of these AWS resources which are created in the above steps, are configured as environment variables in the serverless.yml file.在上述步骤中创建的这些 AWS 资源的 ARN 在 serverless.yml 文件中配置为环境变量。

Apart from this, I want to avoid the possible problem of reaching the AWS cloudformation limit of 200 resources in one stack.除此之外,我想避免达到 AWS cloudformation 一个堆栈中 200 个资源的限制可能出现的问题。

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?有没有例子,其中一个堆栈的 output 用作另一个堆栈中的环境变量?

Another option, I am thinking is to use the Cloudformation template, which Serverless framework creates and then use it inside a nested CF stack.我在想的另一个选择是使用无服务器框架创建的Cloudformation模板,然后在嵌套的 CF 堆栈中使用它。

Any better options/tools?有更好的选择/工具吗?

Yes.是的。 This is very much possible.这是很有可能的。

Assuming you are using deploying from the same AWS account and Region假设您使用从相同的 AWS 账户和区域进行部署

Instead of manually creating resources, use serverless to deploy these resources on AWS and use:无需手动创建资源,而是使用无服务器在 AWS 上部署这些资源并使用:

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:您可以直接在您的主 serverless.yml 文件中导入这些变量名称并将它们设置为 ENVIRONMENT 变量,例如:

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

OPTION 2 (Easier approach)选项 2(更简单的方法)

Or you can simply use plugin: serverless-plugin-split-stacks或者您可以简单地使用插件: serverless-plugin-split-stacks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无服务器框架中的参考现有Cloudformation堆栈输出 - Reference Existing Cloudformation Stack Outputs in Serverless Framework AWS Cloudformation将值传递给嵌套堆栈 - AWS cloudformation pass value to nested stack 在 AWS cloudformation 上理解 Apigateway 和嵌套堆栈时出错 - Error understanding Apigateway and nested stack on AWS cloudformation 无服务器框架1.0:将Cloudformation转换为Yaml for AWS Firehose - Serverless framework 1.0 : Converting Cloudformation to Yaml for AWS Firehose AWS 中的 Cloudformation/Serverless 与 Terraform - Cloudformation/Serverless vs Terraform in AWS 如何在嵌套堆栈中使用 AWS CloudFormation 模板中的映射 - How to use Mappings in AWS CloudFormation templates in nested stacks 无服务器框架:如何使用CloudFormation进行部署? - Serverless Framework: how to deploy with CloudFormation? AWS CloudFormation CodePipeline、ParameterOverrides、将列表传递给嵌套堆栈 - AWS CloudFormation CodePipeline, ParameterOverrides, pass list to a nested stack 如何将列表传递给AWS CloudFormation中的嵌套堆栈参数? - How to pass a list to a nested stack parameter in AWS CloudFormation? AWS Cloudformation-如何依赖另一个嵌套堆栈中的DependsOn资源 - AWS Cloudformation - how to DependsOn resource from another nested stack
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM