Skip to content

Commit 0cf3cb4

Browse files
authored
Merge pull request #92 from ravigurram8/topic-release-3
Adding rg-alb-route53.yml
2 parents 0827fc1 + 0cfad79 commit 0cf3cb4

1 file changed

Lines changed: 144 additions & 0 deletions

File tree

rg-alb-route53.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
Metadata:
2+
AWS::CloudFormation::Interface:
3+
ParameterGroups:
4+
- Label:
5+
default: Network Configuration
6+
Parameters:
7+
- VPC
8+
- PublicSubnet1
9+
- PublicSubnet2
10+
- PublicSubnet3
11+
- Label:
12+
default: Certificate of your domain
13+
Parameters:
14+
- CertificateArn
15+
16+
Parameters:
17+
VPC:
18+
Description: The vpc to launch the service
19+
Type: AWS::EC2::VPC::Id
20+
PublicSubnet1:
21+
Description: The subnet where to launch the service
22+
Type: AWS::EC2::Subnet::Id
23+
PublicSubnet2:
24+
Description: The subnet where to launch the service
25+
Type: AWS::EC2::Subnet::Id
26+
PublicSubnet3:
27+
Description: The subnet where to launch the service
28+
Type: AWS::EC2::Subnet::Id
29+
CertificateArn:
30+
Description: Provide your certificate Arn to Research Gateway application available securely over SSL or leave it blank(optional)
31+
Default: ""
32+
Type: String
33+
34+
Conditions:
35+
securecommunication: !Not [!Equals [!Ref CertificateArn, ""]]
36+
nonsecurecommunication: !Equals [!Ref CertificateArn, ""]
37+
Resources:
38+
RGInstanceSecurityGroup:
39+
Type: AWS::EC2::SecurityGroup
40+
Properties:
41+
GroupDescription: Allow http to client host
42+
VpcId: !Ref VPC
43+
SecurityGroupIngress:
44+
- IpProtocol: tcp
45+
FromPort: 80
46+
ToPort: 80
47+
CidrIp: 0.0.0.0/0
48+
- IpProtocol: tcp
49+
FromPort: 443
50+
ToPort: 443
51+
CidrIp: 0.0.0.0/0
52+
- IpProtocol: tcp
53+
FromPort: 22
54+
ToPort: 22
55+
CidrIp: 0.0.0.0/0
56+
RGApplicationLoadBalancer:
57+
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
58+
Properties:
59+
Name: "RG-Application-Load-Balancer"
60+
Scheme: "internet-facing"
61+
Type: "application"
62+
Subnets:
63+
- !Ref PublicSubnet1
64+
- !Ref PublicSubnet2
65+
- !Ref PublicSubnet3
66+
SecurityGroups:
67+
- !GetAtt RGInstanceSecurityGroup.GroupId
68+
IpAddressType: "ipv4"
69+
RGHTTPSListener:
70+
Type: "AWS::ElasticLoadBalancingV2::Listener"
71+
Condition: securecommunication
72+
Properties:
73+
LoadBalancerArn: !Ref RGApplicationLoadBalancer
74+
Port: 443
75+
Protocol: "HTTPS"
76+
SslPolicy: "ELBSecurityPolicy-2016-08"
77+
Certificates:
78+
-
79+
CertificateArn: !Ref CertificateArn
80+
81+
DefaultActions:
82+
-
83+
Order: 1
84+
TargetGroupArn: !Ref RGTargetGroup
85+
Type: "forward"
86+
87+
RGHTTPListener:
88+
Type: "AWS::ElasticLoadBalancingV2::Listener"
89+
Condition: securecommunication
90+
Properties:
91+
LoadBalancerArn: !Ref RGApplicationLoadBalancer
92+
Port: 80
93+
Protocol: "HTTP"
94+
DefaultActions:
95+
-
96+
Order: 1
97+
RedirectConfig:
98+
Protocol: "HTTPS"
99+
Port: "443"
100+
Host: "#{host}"
101+
Path: "/#{path}"
102+
Query: "#{query}"
103+
StatusCode: "HTTP_301"
104+
Type: "redirect"
105+
RGTargetGroup:
106+
Type: "AWS::ElasticLoadBalancingV2::TargetGroup"
107+
Properties:
108+
HealthCheckIntervalSeconds: 30
109+
HealthCheckPath: "/"
110+
Port: 80
111+
Protocol: "HTTP"
112+
HealthCheckPort: "traffic-port"
113+
HealthCheckProtocol: "HTTP"
114+
HealthCheckTimeoutSeconds: 5
115+
UnhealthyThresholdCount: 2
116+
TargetType: "instance"
117+
Matcher:
118+
HttpCode: "200"
119+
HealthyThresholdCount: 5
120+
VpcId: !Ref VPC
121+
Name: "Rg-target-group-1"
122+
HealthCheckEnabled: true
123+
RGHTTPListener1:
124+
Type: "AWS::ElasticLoadBalancingV2::Listener"
125+
Condition: nonsecurecommunication
126+
Properties:
127+
DefaultActions:
128+
- Type: "forward"
129+
TargetGroupArn: !Ref RGTargetGroup
130+
Port: 80
131+
Protocol: "HTTP"
132+
LoadBalancerArn: !Ref RGApplicationLoadBalancer
133+
134+
Outputs:
135+
Applicationloadbalancer:
136+
Description: The created loadbalancer
137+
Value: !Ref RGApplicationLoadBalancer
138+
TargetGroup:
139+
Description: The created TargetGroup
140+
Value: !Ref RGTargetGroup
141+
LoadBalancerSecurityGroup:
142+
Description: The securty group for the ALB
143+
Value: !Ref RGInstanceSecurityGroup
144+

0 commit comments

Comments
 (0)