Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create a ALB Listener with no Target Group (just want to return 404) for default route

When I create an ALB listener, it appears I need to set a TargetGroupArn.

But I was thing why not just return 404 ... I seem to be able to do this with ActionType of fixed-response. But even if I want to return a fixed-response, I need a target group? This does not seem to make sense?

Whats the best practice for default action?

like image 793
Jiew Meng Avatar asked Sep 20 '25 11:09

Jiew Meng


1 Answers

Yes, you can use a listener with the following cloudformation snippet in conjunction with your ALB...

    HttpListener:
    Type: 'AWS::ElasticLoadBalancingV2::Listener'
    Properties:
      DefaultActions:
      - Type: fixed-response
        FixedResponseConfig:
          StatusCode: 404
      LoadBalancerArn: !Ref LoadBalancer
      Port: 80
      Protocol: HTTP
like image 69
Larry Anderson Avatar answered Sep 22 '25 23:09

Larry Anderson