CodexBloom - Programming Q&A Platform

AWS CloudFormation not creating Elastic Load Balancer with invalid target group configuration

👀 Views: 96 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-08
AWS CloudFormation ELB Networking YAML

I recently switched to I'm currently experiencing an scenario where my AWS CloudFormation stack fails to create an Elastic Load Balancer (ELB) due to what seems to be an invalid target group configuration... The behavior I receive is: ``` Resource of type 'AWS::ElasticLoadBalancingV2::LoadBalancer' failed to create due to 'InvalidTargetGroupConfiguration'. ``` I have defined the ELB and target group in my template as follows: ```yaml Resources: MyTargetGroup: Type: AWS::ElasticLoadBalancingV2::TargetGroup Properties: Name: my-target-group Port: 80 Protocol: HTTP VpcId: !Ref MyVPC HealthCheckPath: /health HealthCheckProtocol: HTTP TargetType: instance MyLoadBalancer: Type: AWS::ElasticLoadBalancingV2::LoadBalancer Properties: Name: my-load-balancer Subnets: - !Ref MySubnet1 - !Ref MySubnet2 SecurityGroups: - !Ref MySecurityGroup Scheme: internet-working with LoadBalancerAttributes: - Key: idle_timeout.timeout_seconds Value: '60' Tags: - Key: Environment Value: Production TargetGroup: !Ref MyTargetGroup ``` I've checked that my VPC and subnets are correctly defined and that they exist. Also, I confirmed that the security group allows traffic on port 80. However, the behavior continues. I attempted to create the target group independently through the AWS console, and it worked without scenario. Is there something specific in the CloudFormation template that I'm missing or incorrectly defining? I've considered the compatibility between the ELB and the target group, but everything seems aligned with best practices. Any insights would be greatly appreciated! This is my first time working with Yaml 3.10. I'd love to hear your thoughts on this.