Question:
From the Load Balancer Lister configuration page, in the AWS Console it allows you to create a listener with a Default Action as shown here:
The Fixed Response option allows you to specify an http return code and a body:
Below is sample known-valid CloudFormation. Not sure how to edit this to support non-forwarding operations.
1 2 3 4 5 6 7 8 9 10 |
MyServicesLoadBalancerListener: Type: AWS::ElasticLoadBalancingV2::Listener Properties: LoadBalancerArn: !Ref MyServicesLoadBalancer Port: 80 Protocol: HTTP DefaultActions: - Type: forward TargetGroupArn: !Ref MyServicesTargetGroup |
How do I do this with CloudFormation? The documentation here seems to suggest only the Forward rule is supported in CloudFormation.
Thanks
Answer:
Not possible yet. It has been requested on the forums but no ETA.
According to the Release History of AWS CloudFormation, the feature was added on Nov 19, 2018. This should replicate the fixed response you shown with the console pictures.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
MyServicesLoadBalancerListener: Type: AWS::ElasticLoadBalancingV2::Listener Properties: LoadBalancerArn: !Ref MyServicesLoadBalancer Port: 80 Protocol: HTTP DefaultActions: - Type: fixed-response FixedResponseConfig: ContentType: "text/plain" MessageBody: "You've reached the listener! Congrats!" StatusCode: "503" |