如何获取云计算模板中指定的ECS实例ID tp?

问题描述 投票:0回答:1

我正在为我的ECS服务构建云形成模板(YML格式,并停留在负载均衡器目标组中,它无法连接到我的ECS实例,并尝试通过引用此官方AWS文档来添加Targets [ C0]

下面是我的目标组,当我多次停止启动(终止)我的实例时,我的实例ID一直在变化,并且不会是静态的,例如VPC或子网ID,以及如何构建该值动态地在目标的ID字段中?

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetdescription.html

注意:我尝试搜索EC2资源并找到了此TargetGroup: Type: AWS::ElasticLoadBalancingV2::TargetGroup Properties: Matcher: HttpCode: "200" Name: "foo" Port: "8080" Protocol: "HTTP" Targets: Id: String // This I need to build dynamically Port: 8080 TargetType: "instance" UnhealthyThresholdCount: 3 VpcId: "vpc-79251d11" ,但它对我没有帮助。 而且我也在使用ASG和LC创建我的ECS实例。

amazon-web-services amazon-cloudformation aws-auto-scaling
1个回答
1
投票

基于聊天中的讨论。

由于实例将在Auto Scaling Group]中运行,因此无需直接在类型为https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-ec2.htmlTargetGroup资源中指定其ID。

© www.soinside.com 2019 - 2024. All rights reserved.