-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalb.yml
94 lines (86 loc) · 2.39 KB
/
alb.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Description:
Load Balancer, Listeners and default rules
Parameters:
Environment:
Type: String
Default: develop
VPCId:
Type: String
PublicSubnets:
Type: CommaDelimitedList
Resources:
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: !Sub "${Environment}-alb"
Subnets: !Ref PublicSubnets
SecurityGroups:
- !Ref LoadBalancerSecurityGroup
Tags:
- Key: Env
Value: !Ref Environment
ELBDefaultListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
LoadBalancerArn: !Ref LoadBalancer
Port: 80
Protocol: HTTP
DefaultActions:
- Type: forward
TargetGroupArn: !Ref DefaultTargetGroup
DefaultTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Port: 80
Protocol: HTTP
Matcher:
HttpCode: 200-399
HealthCheckPath: "/"
VpcId: !Ref VPCId
HealthCheckProtocol: HTTP
HealthCheckIntervalSeconds: 20
HealthCheckTimeoutSeconds: 10
HealthyThresholdCount: 10
UnhealthyThresholdCount: 10
LoadBalancerSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security group for the Load Balancer
VpcId: !Ref VPCId
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
FromPort: 80
IpProtocol: tcp
ToPort: 80
Tags:
- Key: Name
Value: !Sub "elb-allow-web-${Environment}"
- Key: Env
Value: !Ref Environment
Outputs:
LoadBalancerArn:
Value: !Ref LoadBalancer
Export:
Name: !Sub "${Environment}-LoadBalancerArn"
HTTPListenerArn:
Value: !Ref ELBDefaultListener
Export:
Name: !Sub "${Environment}-HTTPListenerArn"
LoadBalancerZone:
Value: !GetAtt LoadBalancer.CanonicalHostedZoneID
LoadBalancerUrl:
Value: !GetAtt LoadBalancer.DNSName
LoadBalancerSecurityGroupId:
Value: !GetAtt LoadBalancerSecurityGroup.GroupId
Export:
Name: !Sub "${Environment}-LoadBalancerSecurityGroupId"
TargetGroupName:
Description: A reference to a port 80 listener
Value: !Ref DefaultTargetGroup
Export:
Name: !Sub "${Environment}-DefaultTargetGroup"
LoadBalacnerDNS:
Description: A reference to a loab balancer dns
Value: !GetAtt LoadBalancer.DNSName
Export:
Name: !Sub "${Environment}-LoadBalacnerDNS"