【问题标题】:Is it possible to make the aws cloudformation code shorter than this?是否可以使 aws cloudformation 代码比这更短?
【发布时间】:2022-01-10 14:15:06
【问题描述】:

我正在编写 aws cloudformation 代码。你能不能让它比我写的代码更简洁?

PublicSubnet:
  Type: AWS::EC2::Subnet
  Properties:
    VPCId: !Ref VPC
    CibrBlock: !Sub
    - ${CibrBlockHeader}
    - { CibrBlockHeader: If [ IsProd, !FindInMap [ VPC, CibrBlockHeader, CibrBlockFooter ], !FindInMap [ VPC, DevCibrBlockHeader, CibrBlockFooter ] ] }

【问题讨论】:

  • 为什么?当前长度有什么问题?
  • 我只是想让!If 声明更简洁。

标签: amazon-web-services amazon-cloudformation


【解决方案1】:

我认为以下应该可以工作(不需要Sub):

PublicSubnet:
  Type: AWS::EC2::Subnet
  Properties:
    VPCId: !Ref VPC
    CibrBlock: 
      CibrBlockHeader: If [ IsProd, !FindInMap [ VPC, CibrBlockHeader, CibrBlockFooter ], !FindInMap [ VPC, DevCibrBlockHeader, CibrBlockFooter ] ]

【讨论】:

    猜你喜欢
    • 2022-11-03
    • 1970-01-01
    • 2022-09-26
    • 1970-01-01
    • 1970-01-01
    • 2017-03-01
    • 1970-01-01
    • 2019-08-26
    • 1970-01-01
    相关资源
    最近更新 更多