-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpc.yaml
392 lines (355 loc) · 11.9 KB
/
vpc.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
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
tosca_definitions_version: cloudify_dsl_1_3
description: Private customer AWS VPC deployment
imports:
- http://cloudify.co/spec/cloudify/6.3.0/types.yaml
- plugin:cloudify-aws-plugin
inputs:
aws_region:
type: string
display_label: AWS Region
description: The AWS region to create the VPC and resources in
default: us-west-1
constraints:
- valid_values:
- us-east-1
- us-east-2
- us-west-1
- us-west-2
- eu-central-1
- eu-west-1
- eu-west-2
- eu-south-1
- eu-west-3
- eu-north-1
- af-south-1
- ap-east-1
- ap-south-1
- ap-northeast-3
- ap-northeast-2
- ap-southeast-1
- ap-southeast-2
- ap-northeast-1
- ca-central-1
- me-south-1
- sa-east-1
primary_availability_zone:
type: string
display_label: Primary availability zone
description: The primary availability zone to deploy primary public and private subnets in
default: { concat: [ { get_input: aws_region }, 'a' ] }
secondary_availability_zone:
type: string
display_label: Secondary availability zone
description: The secondary availability zone to deploy secondary public and private subnets in
default: { concat: [ { get_input: aws_region }, 'c' ] }
vpc_cidr:
type: string
display_label: VPC CIDR
description: The CIDR network for the VPC
default: "10.0.0.0/16"
primary_public_subnet_cidr:
type: string
display_label: Primary public subnet CIDR
description: The CIDR network for the primary public subnet
default: "10.0.1.0/24"
secondary_public_subnet_cidr:
type: string
display_label: Secondary public subnet CIDR
description: The CIDR network for the secondary public subnet
default: "10.0.2.0/24"
primary_private_subnet_cidr:
type: string
display_label: Primary private subnet CIDR
description: The CIDR network for the primary private subnet
default: "10.0.11.0/24"
secondary_private_subnet_cidr:
type: string
display_label: Secondary private subnet CIDR
description: The CIDR network for the secondary private subnet
default: "10.0.12.0/24"
customer_name:
type: string
display_label: Customer Name
description: The name of the customer. Used to tag resources in AWS.
default: Acme
dsl_definitions:
client_config: &client_config
aws_access_key_id: { get_secret: aws_access_key_id }
aws_secret_access_key: { get_secret: aws_secret_access_key }
region_name: { get_input: aws_region }
node_templates:
# VPC
vpc:
type: cloudify.nodes.aws.ec2.Vpc
properties:
client_config: *client_config
resource_config:
CidrBlock: { get_input: vpc_cidr }
kwargs:
InstanceTenancy: default
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-vpc"] }
interfaces:
cloudify.interfaces.lifecycle:
start:
implementation: aws.cloudify_aws.ec2.resources.vpc.modify_vpc_attribute
inputs:
resource_config:
EnableDnsHostnames:
Value: True
# IGW
internet_gateway:
type: cloudify.nodes.aws.ec2.InternetGateway
properties:
client_config: *client_config
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-igw"] }
relationships:
- type: cloudify.relationships.connected_to
target: vpc
# Public subnets
primary_public_subnet:
type: cloudify.nodes.aws.ec2.Subnet
properties:
client_config: *client_config
resource_config:
CidrBlock: { get_input: primary_public_subnet_cidr }
AvailabilityZone: { get_input: primary_availability_zone }
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-subnet-public-01"] }
interfaces:
cloudify.interfaces.lifecycle:
poststart:
implementation: aws.cloudify_aws.ec2.resources.subnet.modify_subnet_attribute
inputs:
resource_config:
MapPublicIpOnLaunch:
Value: true
relationships:
- type: cloudify.relationships.depends_on
target: vpc
secondary_public_subnet:
type: cloudify.nodes.aws.ec2.Subnet
properties:
client_config: *client_config
resource_config:
CidrBlock: { get_input: secondary_public_subnet_cidr }
AvailabilityZone: { get_input: secondary_availability_zone }
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-subnet-public-02"] }
interfaces:
cloudify.interfaces.lifecycle:
poststart:
implementation: aws.cloudify_aws.ec2.resources.subnet.modify_subnet_attribute
inputs:
resource_config:
MapPublicIpOnLaunch:
Value: true
relationships:
- type: cloudify.relationships.depends_on
target: vpc
# Private subnets
primary_private_subnet:
type: cloudify.nodes.aws.ec2.Subnet
properties:
client_config: *client_config
resource_config:
CidrBlock: { get_input: primary_private_subnet_cidr }
AvailabilityZone: { get_input: primary_availability_zone }
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-subnet-private-01"] }
relationships:
- type: cloudify.relationships.depends_on
target: vpc
secondary_private_subnet:
type: cloudify.nodes.aws.ec2.Subnet
properties:
client_config: *client_config
resource_config:
CidrBlock: { get_input: secondary_private_subnet_cidr }
AvailabilityZone: { get_input: secondary_availability_zone }
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-subnet-private-02"] }
relationships:
- type: cloudify.relationships.depends_on
target: vpc
# NAT Gateway
nat_gateway_eip:
type: cloudify.nodes.aws.ec2.ElasticIP
properties:
client_config: *client_config
resource_config:
kwargs:
Domain: 'vpc'
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-nat-gw-eip"] }
nat_gateway:
type: cloudify.nodes.aws.ec2.NATGateway
properties:
client_config: *client_config
resource_config:
kwargs:
ConnectivityType: public
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-nat-gw"] }
relationships:
- type: cloudify.relationships.depends_on
target: primary_public_subnet
- type: cloudify.relationships.depends_on
target: nat_gateway_eip
# Public and private route tables
public_route_table:
type: cloudify.nodes.aws.ec2.RouteTable
properties:
client_config: *client_config
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-public-route-table"] }
relationships:
- type: cloudify.relationships.contained_in
target: vpc
- type: cloudify.relationships.connected_to
target: primary_public_subnet
- type: cloudify.relationships.connected_to
target: secondary_public_subnet
public_igw_route:
type: cloudify.nodes.aws.ec2.Route
properties:
client_config: *client_config
resource_config:
kwargs:
DestinationCidrBlock: '0.0.0.0/0'
relationships:
- type: cloudify.relationships.contained_in
target: public_route_table
- type: cloudify.relationships.connected_to
target: internet_gateway
private_nat_gw_route:
type: cloudify.nodes.aws.ec2.Route
properties:
client_config: *client_config
resource_config:
kwargs:
DestinationCidrBlock: '0.0.0.0/0'
relationships:
- type: cloudify.relationships.contained_in
target: private_route_table
- type: cloudify.relationships.connected_to
target: nat_gateway
private_route_table:
type: cloudify.nodes.aws.ec2.RouteTable
properties:
client_config: *client_config
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-private-route-table"] }
relationships:
- type: cloudify.relationships.contained_in
target: vpc
- type: cloudify.relationships.connected_to
target: primary_private_subnet
- type: cloudify.relationships.connected_to
target: secondary_private_subnet
# Gateway management security group and rules
gateway_management_security_group:
type: cloudify.nodes.aws.ec2.SecurityGroup
properties:
client_config: *client_config
resource_config:
GroupName: { concat: [ { get_input: customer_name }, "-gateway-mgmt"] }
Description: Gateway management security group
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-gateway-mgmt"] }
relationships:
- type: cloudify.relationships.contained_in
target: vpc
gateway_management_ingress_rules:
type: cloudify.nodes.aws.ec2.SecurityGroupRuleIngress
properties:
client_config: *client_config
resource_config:
kwargs:
IpPermissions:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
IpRanges:
- CidrIp: { get_input: vpc_cidr }
- IpProtocol: tcp
FromPort: 9000
ToPort: 9000
IpRanges:
- CidrIp: { get_input: vpc_cidr }
- IpProtocol: tcp
FromPort: 9001
ToPort: 9001
IpRanges:
- CidrIp: { get_input: vpc_cidr }
- IpProtocol: tcp
FromPort: 8443
ToPort: 8443
IpRanges:
- CidrIp: "0.0.0.0/0"
- IpProtocol: udp
FromPort: 8443
ToPort: 8443
IpRanges:
- CidrIp: "0.0.0.0/0"
- IpProtocol: udp
FromPort: 443
ToPort: 443
IpRanges:
- CidrIp: "0.0.0.0/0"
- IpProtocol: udp
FromPort: 51820
ToPort: 51820
IpRanges:
- CidrIp: "0.0.0.0/0"
relationships:
- type: cloudify.relationships.contained_in
target: gateway_management_security_group
# Gateway data security group and rules
gateway_data_security_group:
type: cloudify.nodes.aws.ec2.SecurityGroup
properties:
client_config: *client_config
resource_config:
GroupName: { concat: [ { get_input: customer_name }, "-gateway-data"] }
Description: Gateway data security group
Tags:
- Key: Name
Value: { concat: [ { get_input: customer_name }, "-gateway-data"] }
relationships:
- type: cloudify.relationships.contained_in
target: vpc
capabilities:
vpc_id:
description: ID of the deployed VPC
value: { get_attribute: [ vpc, aws_resource_id ] }
primary_public_subnet_id:
description: ID of the primary public subnet
value: { get_attribute: [ primary_public_subnet, aws_resource_id ] }
secondary_public_subnet_id:
description: ID of the secondary public subnet
value: { get_attribute: [ secondary_public_subnet, aws_resource_id ] }
primary_private_subnet_id:
description: ID of the primary private subnet
value: { get_attribute: [ primary_private_subnet, aws_resource_id ] }
secondary_private_subnet_id:
description: ID of the secondary private subnet
value: { get_attribute: [ secondary_private_subnet, aws_resource_id ] }
gateway_management_security_group_id:
description: ID of the gateway management security group
value: { get_attribute: [ gateway_management_security_group, aws_resource_id ] }
gateway_data_security_group_id:
description: ID of the gateway data security group
value: { get_attribute: [ gateway_data_security_group, aws_resource_id ] }