Created
April 15, 2019 12:48
-
-
Save pmarques/2e987f6553486e526266d8be1af53ebe to your computer and use it in GitHub Desktop.
Use AWS LoadBalancer V2 to redirect traffic.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
Resources: | |
SecurityGroup: | |
Type: AWS::EC2::SecurityGroup | |
Properties: | |
GroupDescription: Allow http to client host | |
VpcId: "vpc-1" | |
SecurityGroupIngress: | |
- IpProtocol: tcp | |
FromPort: 80 | |
ToPort: 80 | |
CidrIp: 0.0.0.0/0 | |
PublicLoadBalancerBackend: | |
Type: AWS::ElasticLoadBalancingV2::LoadBalancer | |
Properties: | |
Name: "redirectlb" | |
Scheme: "internet-facing" | |
SecurityGroups: | |
- !Ref SecurityGroup | |
Subnets: | |
- "subnet-az1" | |
- "subnet-az2" | |
PublicLoadBalancerHttpRedirectListener: | |
Type: AWS::ElasticLoadBalancingV2::Listener | |
DependsOn: | |
- PublicLoadBalancerBackend | |
Properties: | |
DefaultActions: | |
# https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_RedirectActionConfig.html | |
- RedirectConfig: | |
Host: "some.random.fqdn" # "#{host}" | |
Path: "/path" # "#{path}" | |
Port: 80 # 443 | |
Protocol: "HTTP" # "HTTPS" | |
Query: "test=1" # #{query}" | |
StatusCode: HTTP_301 | |
Type: redirect | |
LoadBalancerArn: !Ref 'PublicLoadBalancerBackend' | |
Port: 80 | |
Protocol: HTTP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment