【问题标题】:AWS Cloudformation loop over input parameterAWS Cloudformation 循环输入参数
【发布时间】:2021-03-17 18:47:42
【问题描述】:

我希望我的 CFT 将用户的子网列表作为参数并在创建 ALB 子网时使用它。在为 ALB 创建资源时如何循环子网?

类似:

    ApplicationLoadBalancer:
      Type: AWS::ElasticLoadBalancingV2::LoadBalancer
      Properties:
        Scheme: internet-facing # or internal
        Subnets:
<% for _, subnet in subnets %>
        - Ref: <%subnet%>
<% endfor %>
        SecurityGroups:
        - Ref: ELBSecurityGroup

【问题讨论】:

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


    【解决方案1】:

    遗憾的是,如果没有 custom resourcetemplate macro,它不可能。 CloudFormation 不支持循环,除非您使用自定义资源或宏自己实现它们。

    由于 CloudFormation 的限制,您也可以考虑不使用它。流行的alternative是terraform,它有循环,可以用来实现你所需要的。

    【讨论】:

      猜你喜欢
      • 2023-01-05
      • 2022-10-13
      • 2018-04-08
      • 1970-01-01
      • 2016-06-17
      • 1970-01-01
      • 1970-01-01
      • 2019-08-31
      • 2017-03-04
      相关资源
      最近更新 更多