-
Notifications
You must be signed in to change notification settings - Fork 0
/
access-ci-load-balancer.yaml
134 lines (115 loc) · 3.07 KB
/
access-ci-load-balancer.yaml
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
---
AWSTemplateFormatVersion: 2010-09-09
Parameters:
LaunchType:
Type: String
Default: Fargate
AllowedValues:
- Fargate
- EC2
CreateHTTPSListener:
Type: String
Default: false
AllowedValues:
- true
- false
CertificateARN:
Type: String
Description: >
Specify the ARN of the SSL certificate to be used on HTTPS listener (if CreateHTTPSListener=true)
Subnets:
Type: List<AWS::EC2::Subnet::Id>
VpcId:
Type: String
Conditions:
EC2: !Equals [ !Ref LaunchType, "EC2" ]
HTTP: !Equals [ !Ref CreateHTTPSListener, "false" ]
HTTPS: !Equals [ !Ref CreateHTTPSListener, "true" ]
Resources:
SecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: !Sub ${AWS::StackName}-alb
SecurityGroupIngress:
- CidrIp: "0.0.0.0/0"
IpProtocol: "TCP"
FromPort: 443
ToPort: 443
VpcId: !Ref VpcId
Tags:
- Key: WBS
Value: 'ACCESS CONECT 1.4'
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Subnets: !Ref Subnets
SecurityGroups:
- !Ref SecurityGroup
Tags:
- Key: WBS
Value: 'ACCESS CONECT 1.4'
LoadBalancerListenerSSL:
Type: AWS::ElasticLoadBalancingV2::Listener
Condition: HTTPS
Properties:
LoadBalancerArn: !Ref LoadBalancer
Port: 443
Protocol: HTTPS
SslPolicy: ELBSecurityPolicy-FS-1-2-Res-2020-10
Certificates:
- CertificateArn: !Ref CertificateARN
DefaultActions:
- Type: forward
TargetGroupArn: !Ref TargetGroup
TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
DependsOn: LoadBalancer
Properties:
VpcId: !Ref VpcId
Port: 443
Protocol: HTTPS
Matcher:
HttpCode: 200-299
HealthCheckIntervalSeconds: 10
HealthCheckPath: /idp/
HealthCheckProtocol: HTTPS
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 2
TargetType: !If [ EC2, "instance", "ip" ]
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: 30
- Key: stickiness.enabled
Value: true
- Key: stickiness.type
Value: lb_cookie
- Key: stickiness.lb_cookie.duration_seconds
Value: 86400
Tags:
- Key: WBS
Value: 'ACCESS CONECT 1.4'
ListenerRuleSSL:
Type: AWS::ElasticLoadBalancingV2::ListenerRule
Condition: HTTPS
Properties:
ListenerArn: !Ref LoadBalancerListenerSSL
Priority: 1
Conditions:
- Field: path-pattern
Values:
- /
Actions:
- TargetGroupArn: !Ref TargetGroup
Type: forward
Outputs:
TargetGroup:
Value: !Ref TargetGroup
CanonicalHostedZoneID:
Value: !GetAtt LoadBalancer.CanonicalHostedZoneID
DNSName:
Value: !GetAtt LoadBalancer.DNSName
ServiceUrl:
Description: URL of the load balancer for the idp service.
Value: !Sub https://${LoadBalancer.DNSName}/idp/
SecurityGroup:
Value: !Ref SecurityGroup