Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (5.6k points)
edited by

The LB configuration in the AWS Console allows to create a listener with the Default Action and the fixed Response option allows to specify HTTP return code. Now I want to edit this to support non-forwarding operation, below is the sample cloud formation:

MyServicesLoadBalancerListener:

    Type: AWS::ElasticLoadBalancingV2::Listener

    Properties:

        LoadBalancerArn: !Ref MyServicesLoadBalancer

        Port: 80

        Protocol: HTTP

        DefaultActions:

            - Type: forward

              TargetGroupArn: !Ref MyServicesTargetGroup

How can I do this with CloudFormation?

1 Answer

0 votes
by (12.4k points)

Use the below code and modify it according to your requirements, this should replicate the fixed response.

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"

Do you want to learn more about AWS? Checkout AWS Training by Intellipaat!

You can watch the Cloudformation tutorial below:

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

Browse Categories

...