aws-cloudformation - 在 CloudFormation 模板中参数化资源名称?

标签 aws-cloudformation

这个答案在这里:Is there a way to parameterize cloud formation resource names?并没有真正帮助,因为我希望设置物理名称,而不是逻辑名称。我希望能够在参数列表中设置参数,例如:

"ELBName": {
  "Type": "String",
  "Default": "xxx",
  "Description": "The Production Number for this stack (e.g. xxx)"
}

然后

"LoadBalancerName": "prod" + {Ref: "ELBName"}

尽管直接连接是不可能的。有什么办法可以做我想做的事吗?我的最终目标是采用我创建的模板并使用它来创建其自身的许多副本,每个副本都具有相同的资源,但名称不同,可能是通过嵌套堆栈。

最佳答案

使用 Fn::Join 函数来执行此操作:

            "LoadBalancerName":{
           "Fn::Join":[
              "",
              [
                 "prod",
                 {
                    "Ref":"ELBName"
                 }
              ]
           ]
        }

假设 ELBName 参数已传递值 01,这会将名称指定为 prod01

关于aws-cloudformation - 在 CloudFormation 模板中参数化资源名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38919693/

相关文章:

amazon-web-services - 使用 Boto3 来自 CF 模板的资源 ARN

amazon-web-services - CodePipeline 无法找到 SAM 模板 yaml 文件

amazon-web-services - aws cloudformation 模板 sns sqs

json - AWS CloudFormation Cognito 身份提供商 (SAML)

amazon-web-services - 设置 Tableau Server 以在 AWS GovCloud 上运行

amazon-web-services - CloudFormation 设置 CodePipeline/CodeBuild 以部署 SAM 应用程序

amazon-ec2 - 如何使用实例类型 t2.micro 创建 ec2 cloudformation 的策略

python - 如何使用python从cloudformation堆栈字典中获取特定字段的值

json - 如何在 AWS CloudFormation 中创建 Amazon SQS 队列并订阅 Amazon SNS 主题?

amazon-web-services - 在 Cloudformation-YAML 中的单个资源中添加不同的参数值