forked from filipercampos/api-oracle-nestjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud-formation-new-environment.yml
278 lines (278 loc) · 6.63 KB
/
cloud-formation-new-environment.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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: Cloudformation description
Globals:
Function:
Timeout: 15
Parameters:
ApplicationBaseName:
Type: String
Default: flp
Environment:
Type: String
Default: hml
AllowedValues:
- prd
- hml
- dev
Mappings:
Environment:
Name:
prd: production
hml: homologation
dev: development
NewRelicLicenseKey:
prd: x
hml: x
dev: x
ElasticApmUrl:
prd: https://url
hml: https://url
dev: https://url
ElasticApmSecret:
prd: 1x
hml: 1x
dev: 1x
AutoScalingMinCapacity:
prd: 8
hml: 2
dev: 2
AutoScalingMaxCapacity:
prd: 10
hml: 2
dev: 2
AutoScalingInCooldown:
prd: 10
hml: 0
dev: 0
AutoScalingOutCooldown:
prd: 10
hml: 0
dev: 0
DynamicScalingInSuspended:
prd: false
hml: true
dev: true
DynamicScalingOutSuspended:
prd: false
hml: true
dev: true
ScheduledScalingSuspended:
prd: false
hml: true
dev: true
VpcSubnet:
sa-east-1:
prd:
- subnet-0x
- subnet-0x
us-east-2:
hml:
- subnet-0x
- subnet-0x
dev:
- subnet-0x
- subnet-0x
VpcSecurityGroup:
sa-east-1:
prd:
- sg-0x
us-east-2:
hml:
- sg-0x
dev:
- sg-0x
DbSubnetGroup:
us-east-2:
hml: subgroup-hml-vpceks
dev: subgroup-hml-vpceks
sa-east-1:
prd: subgroup-prd-vpceks
DbSecurityGroup:
us-east-2:
hml:
- sg-x
dev:
- sg-x
sa-east-1:
prd:
- sg-x
VpcEndpointApiGateway:
us-east-2:
hml:
- vpce-0x
- vpce-0x
dev:
- vpce-0x
- vpce-0x
sa-east-1:
prd:
- vpce-0x
- vpce-0x
Resources:
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
IpAddressType: ipv4
Name: !Ref ApplicationBaseName
Scheme: internal
Type: network
Subnets: !FindInMap [VpcSubnet, !Ref "AWS::Region", !Ref Environment]
Tags:
- Key: Project
Value: !Ref ApplicationBaseName
- Key: Environment
Value: !Ref Environment
# VpcLink:
# Type: AWS::ApiGateway::VpcLink
# Properties:
# Name: !Join ["-", ["nlb", !Ref ApplicationBaseName]]
# TargetArns:
# - !Ref LoadBalancer
ApiGateway:
Type: AWS::ApiGateway::RestApi
Properties:
Name: !Ref ApplicationBaseName
EndpointConfiguration:
Types:
- PRIVATE
VpcEndpointIds:
!FindInMap [
VpcEndpointApiGateway,
!Ref "AWS::Region",
!Ref Environment,
]
Parameters:
Key: Value
Policy:
{
"Version": "2012-10-17",
"Statement":
[
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource":
!Join [
"",
[
"arn:aws:execute-api:",
!Ref "AWS::Region",
":account_id:*/*/*",
],
],
},
{
"Effect": "Deny",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource":
!Join [
"",
[
"arn:aws:execute-api:",
!Ref "AWS::Region",
":account_id:*/*/*",
],
],
"Condition":
{
"StringNotEquals":
{
"aws:SourceVpce":
!FindInMap [
VpcEndpointApiGateway,
!Ref "AWS::Region",
!Ref Environment,
],
},
},
},
],
}
Tags:
- Key: Project
Value: !Ref ApplicationBaseName
- Key: Environment
Value: !Ref Environment
ApiGatewayDeployment:
Type: AWS::ApiGateway::Deployment
DependsOn: ApiGatewayMethod
Properties:
RestApiId: !Ref ApiGateway
ApiGatewayStage:
Type: AWS::ApiGateway::Stage
Properties:
StageName: !Ref Environment
RestApiId: !Ref ApiGateway
DeploymentId: !Ref ApiGatewayDeployment
ApiGatewayResource:
Type: AWS::ApiGateway::Resource
Properties:
ParentId: !GetAtt ApiGateway.RootResourceId
PathPart: "health"
RestApiId: !Ref ApiGateway
ApiGatewayMethod:
Type: AWS::ApiGateway::Method
Properties:
HttpMethod: GET
Integration:
Type: MOCK
ResourceId: !GetAtt ApiGatewayResource.ResourceId
RestApiId: !Ref ApiGateway
AuthorizationType: NONE
Cluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: !Join ["-", [!Ref ApplicationBaseName, !Ref Environment]]
ClusterSettings:
- Name: containerInsights
Value: enabled
Tags:
- Key: Project
Value: !Ref ApplicationBaseName
- Key: Environment
Value: !Ref Environment
Outputs:
ClusterName:
Description: Name of newly created Cluster
Value: !Ref Cluster
Export:
Name:
"Fn::Sub": "${AWS::StackName}-ClusterName"
ApiGatewayId:
Description: Id of newly created ApiGateway
Value: !Ref ApiGateway
#Value: !Ref ApiGatewayId
Export:
Name:
"Fn::Sub": "${AWS::StackName}-ApiGatewayId"
ApiGatewayRootResourceId:
Description: Id of root resource of newly created ApiGateway
Value: !GetAtt ApiGateway.RootResourceId
#Value: !Ref ApiGatewayRootResourceId
Export:
Name:
"Fn::Sub": "${AWS::StackName}-ApiGatewayRootResourceId"
LoadBalancerArn:
Description: Arn of created LoadBalancer
Value: !Ref LoadBalancer
#Value: !Ref LoadBalancerArn
Export:
Name:
"Fn::Sub": "${AWS::StackName}-LoadBalancerArn"
LoadBalancerDnsUri:
Description: DNS Uri of LoadBalancer
Value: !GetAtt LoadBalancer.DNSName
#Value: !Ref LoadBalancerDnsUri
Export:
Name:
"Fn::Sub": "${AWS::StackName}-LoadBalancerDnsUri"
# VpcLinkId:
# Description: VPC Lind Id of LoadBalancer
# Value: !Ref VpcLink
# #Value: !Ref VpcLinkId
# Export:
# Name:
# "Fn::Sub": "${AWS::StackName}-VpcLinkId"