I am building a cloud formation template(YML format) for my ECS service and stuck in load-balancer target group, it was not able to attach to my ECS instance and trying to add Targets
by referring this official AWS docs https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetdescription.html
Below is my target group and as I stop start(which terminates) my instance several times, my instance id will be changing all the time and will not be static, like VPC or subnet ids and how can I build the value dynamically in Id field of Targets ?
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"
Note: I tried search for EC2 resources and found this https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-ec2.html but it didn't help me. Also I am using ASG and LC to create my ECS instance.