[英]Prepend StackName to Cloudformation resources
I want to have multiple stacks based on a single CloudFormation template, but I'm getting naming conflicts.我想要基于单个 CloudFormation 模板的多个堆栈,但我遇到了命名冲突。 The simplest way to resolve this would seem to be prepending (or appending) the StackName
to each of the repeated resources, eg my lambda functions or roles.解决此问题的最简单方法似乎是将StackName
添加(或附加)到每个重复的资源,例如我的 lambda 函数或角色。
AWS talks about AWS::StackName
in the 'Template Reference' section of the documentation , but there's no clear demonstration of how to do this. AWS 在文档的“模板参考”部分讨论了AWS::StackName
,但没有明确说明如何执行此操作。
How can I prepend the StackName
to a CloudFormation resource?如何将StackName
到 CloudFormation 资源?
MyLambdaFunction
Type: "AWS:Serverless::Function"
Properties:
FunctionName: AWS::StackName + "-myLambdaFunction"
You need to Ref
the pseudoparameter and use the Fn::Join
method to construct the name您需要Ref
伪参数并使用Fn::Join
方法构造名称
MyLambdaFunction
Type: "AWS:Serverless::Function"
Properties:
FunctionName: !Join [ "", [ {"Ref": "AWS::StackName"}, "-myLambdaFunction" ]]
The YAML version: YAML 版本:
RoleName: !Sub ${AWS::StackName}-InstanceRole
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.