amazon-web-services - AWS Cloudformation 循环输入参数

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

我希望我的 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

最佳答案

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

由于 CloudFormation 的局限性,您也可以考虑不使用它。流行的替代方案是 terraform,它有循环,可以用来实现您的需求。

关于amazon-web-services - AWS Cloudformation 循环输入参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65165187/

相关文章:

amazon-web-services - AWS CodeBuild Webhook - CloudFormation

amazon-web-services - 如何使用 CFT 启动具有 CreditSpecification 的 Spot 车队?

amazon-web-services - 由于 redis 内存使用,Redis cli 无法连接到 AWS ElastiCache,但应用程序仍然能够通信

amazon-web-services - 'statement-id'的参数 'add-permission'是什么意思?

amazon-web-services - ELB 运行状况检查因运行 AWS ECS 容器而失败

amazon-web-services - 云信息快速洞察

amazon-web-services - 无法使用 CloudFormation 创建 PostgreSQL,但可以使用 Web 界面

aws-cloudformation - 创建 RDS 数据库用户 CloudFormation

amazon-web-services - AWS cloudformation 嵌套堆栈因模板 URL 失败

python - 如何在 AWS EC2 实例上安装 Python 3?