gpt4 book ai didi

amazon-web-services - 将目标组目标作为参数传递云形成

转载 作者:行者123 更新时间:2023-12-03 07:27:02 24 4
gpt4 key购买 nike

我正在尝试创建一个接受 Target 作为参数作为模板的 AWS::ElasticLoadBalancingV2::TargetGroup :

FETargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
Properties:
Name: !Sub 'targetgroup-ccp-fe-${EnvironmentName}'
Port: 443
Protocol: HTTPS
TargetType: ip
Targets:
- Id: !Select[0,!Split [",", !Ref TargetGroupIPs]]
- Id: !Select[1,!Split [",", !Ref TargetGroupIPs]]
VpcId: !Ref VPC

参数:

  TargetGroupIPs:
Description: IPs to be included in Target Group
Type: String

这里的问题是静态的 2 个 IP,我希望它接受 x 个 IP。例如:

FETargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
Properties:
Name: !Sub 'targetgroup-ccp-fe-${EnvironmentName}'
Port: 443
Protocol: HTTPS
TargetType: ip
Targets: !Split [",", !Ref TargetGroupIPs]
VpcId: !Ref VPC

但我收到验证错误:目标接受对象列表。如何才能正确完成?

最佳答案

How it can be done correctly ?

无法在普通 CloudFormation (CFN) 中完成。这需要 CFN 中不存在的循环机制。

要克服这个问题,您必须创建 CFN macrocustom resource 。在这两种情况下,您都必须编写lambda 函数。不同之处在于宏函数将解析您的原始模板(或其片段)并动态构造目标。相比之下,自定义资源的函数将使用 AWS SDK 完全创建目标组,并将您的 TargetGroupIPs 作为其输入参数。

关于amazon-web-services - 将目标组目标作为参数传递云形成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66689977/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com