I'm using an ALB in my Elastic Beanstalk environment. It works (on 80 and 443) but I want to implement a redirect rule in the cloudformation template.
I was able to create the rule in the console:
If PATH is / Redirect to HTTPS://#{host}:443/app?#{query}
How can I do this for an ALB in Elastic Beanstalk in CloudFormation?
You can add an EB extension that is a cloudformation snippet. It would look something like this:
albRedirect:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- Type: redirect
RedirectConfig:
Protocol: HTTPS
Host: '#{host}'
Query: '#{query}'
Path: '/#{path}'
Port: '443'
StatusCode: HTTP_301
LoadBalancerArn: !Ref AWSEBV2LoadBalancer
Port: 80
Protocol: HTTP
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-resources.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With