Skip to content

Instantly share code, notes, and snippets.

@ivawzh
Created February 24, 2017 01:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivawzh/435dd3f169aeb7c19878b828c6a5c72a to your computer and use it in GitHub Desktop.
Save ivawzh/435dd3f169aeb7c19878b828c6a5c72a to your computer and use it in GitHub Desktop.
Stand alone ALB Cloudformation setup. For ECS service to consume.
Resources:
# ============================ Application Load Balancer ============================
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: !Ref AWS::StackName
Scheme: internet-facing
Subnets: !Split
- ','
- "Fn::ImportValue":
"Fn::Sub": "${NetworkStackName}-PublicSubnets"
SecurityGroups:
- !ImportValue
"Fn::Sub": "${ECSCLusterStackName}-LoadBalancerSecurityGroup"
LoadBalancerAttributes:
- Key: idle_timeout.timeout_seconds
Value: '30'
Tags:
- Key: Name
Value: !Ref AWS::StackName
LoadBalancerListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
LoadBalancerArn: !Ref LoadBalancer
Port: 80
# Protocol: HTTPS
Protocol: HTTP
Certificates:
- CertificateArn: !ImportValue
"Fn::Sub": "${CertificatesStackName}-StudyABitCertificate"
DefaultActions:
- Type: forward
TargetGroupArn: !Ref DefaultTargetGroup
# # We define a default target group here, as this is a mandatory Parameters
# # when creating an Application Load Balancer Listener. This is not used, instead
# # a target group is created per-service in each service template
DefaultTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Name: default
VpcId: !ImportValue
"Fn::Sub": "${NetworkStackName}-VPC"
Port: 80
Protocol: HTTP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment