Home > database >  Is it possible to make the aws cloudformation code shorter than this?
Is it possible to make the aws cloudformation code shorter than this?

Time:01-10

I am writing aws cloudformation code. Could you possibly make it more concise than the code I wrote?

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

CodePudding user response:

I think the following should work (don't need Sub):

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