[英]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 -在部署无服务器堆栈之前,我需要执行一些手动步骤 -
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.