【问题标题】:AWS Cloud Formation multiple route entries with parametersAWS Cloud Formation 带有参数的多个路由条目
【发布时间】:2021-11-08 17:56:08
【问题描述】:

cloudformation 模板需要有多个路由条目到路由表。 AWS::EC2::route 只能创建一个路由条目。 有没有办法创建取决于参数的多个路由条目? 参数中的示例将询问逗号分隔或目标 cidr 列表,目标将是 IGW

参数 目的地CidrList: 类型:字符串 默认:172.16.2.2\32、10.4.14.3\32

cfn 模板应该在路由表中创建到 IGW 的路由,这个目标列表可以有多个目标 IP 地址

【问题讨论】:

    标签: amazon-cloudformation aws-cloudformation-custom-resource


    【解决方案1】:

    我通过使用 AWS 宏 PyPlate 获得了解决方案 https://github.com/awslabs/aws-cloudformation-templates/tree/master/aws/services/CloudFormation/MacrosExamples/PyPlate/

    AWSTemplateFormatVersion: "2010-09-09"
    
    Parameters:
      RouteEntries:
        Type: CommaDelimitedList
        Default: "10.2.3.10/32,0.0.0.0/32"
    
      ResourceName:
        Type: CommaDelimitedList
        Default: "ip1,ip2"
    
    Transform: [PyPlate]
    
    Resources: |
      #!PyPlate
      output = {}
      for ip in params['RouteEntries']:
        for name in params['ResourceName']:
          output[name] = { "Type": "AWS::EC2::Route", "Properties": {"RouteTableId": "<RT ID>" , "DestinationCidrBlock": ip, "GatewayId": "<IGW ID>" }}
    
    

    【讨论】:

      猜你喜欢
      • 2015-10-06
      • 2019-11-15
      • 1970-01-01
      • 1970-01-01
      • 2018-03-05
      • 1970-01-01
      • 2021-05-29
      • 1970-01-01
      • 2018-07-31
      相关资源
      最近更新 更多