通过参数在cloudformation模板中命名?

时间:2019-07-24 13:49:30

标签: amazon-web-services amazon-cloudformation

我正在尝试根据安全组的名称来命名我的安全组,但是我的问题是我也希望包括一个组类型名称。例如:

我尝试过

somerdsgroup:
  Type: AWS::EC2::SecurityGroup
  Properties: 
    GroupDescription: "RDS Security Group"
    Tags: 
      - 
        key: "env"
        value: Ref: envT
      -
        key:"name"
        value: #here i want like demo-cron

    VpcId: Ref: myVpcid

我希望结果像 name : demo-cronname : dev-cron取决于envT变量?

1 个答案:

答案 0 :(得分:0)

这应该有效:

somerdsgroup:
  Type: AWS::EC2::SecurityGroup
  Properties: 
    GroupDescription: "RDS Security Group"
    Tags: 
      - key: "env"
        value: Ref: envT
      - key:"name"
        value: !Sub "{envT}-${group}"
    VpcId: Ref: myVpcid