Skip to content

Instantly share code, notes, and snippets.

@cp-sumi-k
Last active April 12, 2022 12:41
Show Gist options
  • Save cp-sumi-k/63aecf6354ebb9a864ea30135e2c8c04 to your computer and use it in GitHub Desktop.
Save cp-sumi-k/63aecf6354ebb9a864ea30135e2c8c04 to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: 2010-09-09
Description: An ECS, ECR, ALB and cloudfront stack
Resources:
# http (port:80) listener redirects to https
HTTPListener:
Type: "AWS::ElasticLoadBalancingV2::Listener"
Properties:
DefaultActions:
-
Order: 1
RedirectConfig:
Protocol: "HTTPS"
Port: "443"
StatusCode: "HTTP_301" #redirect from http to https
Type: "redirect"
LoadBalancerArn: !Ref ApplicationLoadBalancer #load balancer reference
Port: 80
Protocol: HTTP
# https (port:443) listener with ssl certificate
HTTPSListener:
Type: "AWS::ElasticLoadBalancingV2::Listener"
Properties:
LoadBalancerArn: !Ref ApplicationLoadBalancer #load balancer reference
Port: 443
Protocol: "HTTPS"
SslPolicy: "ELBSecurityPolicy-TLS-1-2-Ext-2018-06"
Certificates:
- CertificateArn: < CERTIFICATE-ARN > #created using AWS cerificate manager
DefaultActions:
-
Order: 1
TargetGroupArn: !Ref TargetGroup #target group reference
Type: "forward"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment