Cloudformation: Provided Load Balancers may not be valid. Please ensure they exist and try againΒΆ

Spent too much time troubleshooting the following error but I happy to find the solution for this error:

Cloudformation: "Provided Load Balancers may not be valid. Please ensure they exist and try again."
AutoScalingGroup:
   Type: AWS::AutoScaling::AutoScalingGroup
# ---
      TargetGroupARNs:
         - !Ref TargetGroupB
      LoadBalancerNames:    # Delete this to fix the error
            - !Ref LoadBalancerB

The error is caused by the above snippet where a ALB or AWS::ElasticLoadBalancingV2::LoadBalancer is used but both the TargetGroupARNs and LoadBalancerNames is referenced

Although the error message is not helpful, the documentation spells out how it must work. As per http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-group.html:

LoadBalancerNames:

A list of Classic load balancers associated with this Auto Scaling group. To specify Application load balancers, use TargetGroupARNs.

So the problem is we are not following the specification exactly and getting very nonsensical errors. The solution is simply to delete the LoadBalancerNames line from the above snippet.

Comments

comments powered by Disqus