forked from aws-samples/aws-refarch-wordpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws-refarch-wordpress-01-newvpc.yaml
1001 lines (974 loc) · 31 KB
/
aws-refarch-wordpress-01-newvpc.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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
AWSTemplateFormatVersion: 2010-09-09
Description: Reference Architecture to host WordPress on AWS - Creates New VPC
Metadata:
Authors:
Description: Darryl Osborne ([email protected])
License:
Description: 'Copyright 2018 Amazon.com, Inc. and its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0'
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Amazon VPC Parameters
Parameters:
- NumberOfAZs
- AvailabilityZones
- VpcCidr
- VpcTenancy
- PublicSubnet0Cidr
- PublicSubnet1Cidr
- PublicSubnet2Cidr
- PublicSubnet3Cidr
- PublicSubnet4Cidr
- PublicSubnet5Cidr
- WebSubnet0Cidr
- WebSubnet1Cidr
- WebSubnet2Cidr
- WebSubnet3Cidr
- WebSubnet4Cidr
- WebSubnet5Cidr
- DataSubnet0Cidr
- DataSubnet1Cidr
- DataSubnet2Cidr
- DataSubnet3Cidr
- DataSubnet4Cidr
- DataSubnet5Cidr
ParameterLabels:
AvailabilityZones:
default: Availability Zones
NumberOfAZs:
default: Number of Availability Zones
VpcCidr:
default: VpcCidr
VpcTenancy:
default: VpcTenancy
PublicSubnet0Cidr:
default: Public Subnet 0
PublicSubnet1Cidr:
default: Public Subnet 1
PublicSubnet2Cidr:
default: Public Subnet 2
PublicSubnet3Cidr:
default: Public Subnet 3
PublicSubnet4Cidr:
default: Public Subnet 4
PublicSubnet5Cidr:
default: Public Subnet 5
WebSubnet0Cidr:
default: Web Subnet 0
WebSubnet1Cidr:
default: Web Subnet 1
WebSubnet2Cidr:
default: Web Subnet 2
WebSubnet3Cidr:
default: Web Subnet 3
WebSubnet4Cidr:
default: Web Subnet 4
WebSubnet5Cidr:
default: Web Subnet 5
DataSubnet0Cidr:
default: Data Subnet 0
DataSubnet1Cidr:
default: Data Subnet 1
DataSubnet2Cidr:
default: Data Subnet 2
DataSubnet3Cidr:
default: Data Subnet 3
DataSubnet4Cidr:
default: Data Subnet 4
DataSubnet5Cidr:
default: Data Subnet 5
Parameters:
AvailabilityZones:
Description: 'List of Availability Zones to use for the subnets in the VPC. Note:
The logical order is preserved.'
Type: List<AWS::EC2::AvailabilityZone::Name>
NumberOfAZs:
AllowedValues:
- 2
- 3
- 4
- 5
- 6
Default: 3
Description: Number of Availability Zones to use in the VPC. This must match your
selections in the list of Availability Zones parameter.
Type: Number
VpcCidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.0.0/16
Description: CIDR block for the VPC
Type: String
VpcTenancy:
AllowedValues:
- default
- dedicated
Default: default
Description: The allowed tenancy of instances launched into the VPC
Type: String
DataSubnet0Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.100.0/24
Description: CIDR block for data subnet 0 located in Availability Zone 0
Type: String
DataSubnet1Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.101.0/24
Description: CIDR block for data subnet 1 located in Availability Zone 1
Type: String
DataSubnet2Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.102.0/24
Description: CIDR block for data subnet 2 located in Availability Zone 2
Type: String
DataSubnet3Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.103.0/24
Description: CIDR block for data subnet 3 located in Availability Zone 3
Type: String
DataSubnet4Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.104.0/24
Description: CIDR block for data subnet 4 located in Availability Zone 4
Type: String
DataSubnet5Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.105.0/24
Description: CIDR block for data subnet 5 located in Availability Zone 5
Type: String
PublicSubnet0Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.200.0/24
Description: CIDR block for Public subnet 0 located in Availability Zone 0
Type: String
PublicSubnet1Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.201.0/24
Description: CIDR block for Public subnet 1 located in Availability Zone 1
Type: String
PublicSubnet2Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.202.0/24
Description: CIDR block for Public subnet 2 located in Availability Zone 2
Type: String
PublicSubnet3Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.203.0/24
Description: CIDR block for Public subnet 3 located in Availability Zone 3
Type: String
PublicSubnet4Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.204.0/24
Description: CIDR block for Public subnet 4 located in Availability Zone 4
Type: String
PublicSubnet5Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.205.0/24
Description: CIDR block for Public subnet 5 located in Availability Zone 5
Type: String
WebSubnet0Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.0.0/22
Description: CIDR block for Web subnet 0 located in Availability Zone 0
Type: String
WebSubnet1Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.4.0/22
Description: CIDR block for Web subnet 1 located in Availability Zone 1
Type: String
WebSubnet2Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.8.0/22
Description: CIDR block for Web subnet 2 located in Availability Zone 2
Type: String
WebSubnet3Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.12.0/22
Description: CIDR block for Web subnet 3 located in Availability Zone 3
Type: String
WebSubnet4Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.16.0/22
Description: CIDR block for Web subnet 4 located in Availability Zone 4
Type: String
WebSubnet5Cidr:
AllowedPattern: "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(1[6-9]|2[0-8]))$"
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.20.0/22
Description: CIDR block for Web subnet 5 located in Availability Zone 5
Type: String
Conditions:
NumberOfAZs1:
!Equals [ '1', !Ref NumberOfAZs ]
NumberOfAZs2:
!Equals [ '2', !Ref NumberOfAZs ]
NumberOfAZs3:
!Equals [ '3', !Ref NumberOfAZs ]
NumberOfAZs4:
!Equals [ '4', !Ref NumberOfAZs ]
NumberOfAZs5:
!Equals [ '5', !Ref NumberOfAZs ]
NumberOfAZs6:
!Equals [ '6', !Ref NumberOfAZs ]
AZ0: !Or
- !Condition NumberOfAZs1
- !Condition NumberOfAZs2
- !Condition NumberOfAZs3
- !Condition NumberOfAZs4
- !Condition NumberOfAZs5
- !Condition NumberOfAZs6
AZ1: !Or
- !Condition NumberOfAZs2
- !Condition NumberOfAZs3
- !Condition NumberOfAZs4
- !Condition NumberOfAZs5
- !Condition NumberOfAZs6
AZ2: !Or
- !Condition NumberOfAZs3
- !Condition NumberOfAZs4
- !Condition NumberOfAZs5
- !Condition NumberOfAZs6
AZ3: !Or
- !Condition NumberOfAZs4
- !Condition NumberOfAZs5
- !Condition NumberOfAZs6
AZ4: !Or
- !Condition NumberOfAZs5
- !Condition NumberOfAZs6
AZ5: !Condition NumberOfAZs6
Resources:
WebSubnet0:
Condition: AZ0
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 0, !Ref AvailabilityZones ]
CidrBlock: !Ref WebSubnet0Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'WebSubnet0 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
WebSubnet1:
Condition: AZ1
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 1, !Ref AvailabilityZones ]
CidrBlock: !Ref WebSubnet1Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'WebSubnet1 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
WebSubnet2:
Condition: AZ2
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 2, !Ref AvailabilityZones ]
CidrBlock: !Ref WebSubnet2Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'WebSubnet2 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
WebSubnet3:
Condition: AZ3
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 3, !Ref AvailabilityZones ]
CidrBlock: !Ref WebSubnet3Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'WebSubnet3 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
WebSubnet4:
Condition: AZ4
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 4, !Ref AvailabilityZones ]
CidrBlock: !Ref WebSubnet4Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'WebSubnet4 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
WebSubnet5:
Condition: AZ5
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 5, !Ref AvailabilityZones ]
CidrBlock: !Ref WebSubnet5Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'WebSubnet5 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
WebSubnetRouteTableAssociation0:
Condition: AZ0
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable0
SubnetId: !Ref WebSubnet0
WebSubnetRouteTableAssociation1:
Condition: AZ1
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable1
SubnetId: !Ref WebSubnet1
WebSubnetRouteTableAssociation2:
Condition: AZ2
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable2
SubnetId: !Ref WebSubnet2
WebSubnetRouteTableAssociation3:
Condition: AZ3
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable3
SubnetId: !Ref WebSubnet3
WebSubnetRouteTableAssociation4:
Condition: AZ4
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable4
SubnetId: !Ref WebSubnet4
WebSubnetRouteTableAssociation5:
Condition: AZ5
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable5
SubnetId: !Ref WebSubnet5
DataSubnet0:
Condition: AZ0
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 0, !Ref AvailabilityZones ]
CidrBlock: !Ref DataSubnet0Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'DataSubnet0 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
DataSubnet1:
Condition: AZ1
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 1, !Ref AvailabilityZones ]
CidrBlock: !Ref DataSubnet1Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'DataSubnet1 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
DataSubnet2:
Condition: AZ2
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 2, !Ref AvailabilityZones ]
CidrBlock: !Ref DataSubnet2Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'DataSubnet2 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
DataSubnet3:
Condition: AZ3
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 3, !Ref AvailabilityZones ]
CidrBlock: !Ref DataSubnet3Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'DataSubnet3 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
DataSubnet4:
Condition: AZ4
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 4, !Ref AvailabilityZones ]
CidrBlock: !Ref DataSubnet4Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'DataSubnet4 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
DataSubnet5:
Condition: AZ5
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 5, !Ref AvailabilityZones ]
CidrBlock: !Ref DataSubnet5Cidr
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Join [ '', [ 'DataSubnet5 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Private
VpcId: !Ref Vpc
DataSubnetRouteTableAssociation0:
Condition: AZ0
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable0
SubnetId: !Ref DataSubnet0
DataSubnetRouteTableAssociation1:
Condition: AZ1
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable1
SubnetId: !Ref DataSubnet1
DataSubnetRouteTableAssociation2:
Condition: AZ2
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable2
SubnetId: !Ref DataSubnet2
DataSubnetRouteTableAssociation3:
Condition: AZ3
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable3
SubnetId: !Ref DataSubnet3
DataSubnetRouteTableAssociation4:
Condition: AZ4
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable4
SubnetId: !Ref DataSubnet4
DataSubnetRouteTableAssociation5:
Condition: AZ5
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NatRouteTable5
SubnetId: !Ref DataSubnet5
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: !Join [ '', [ 'InternetGateway / ', !Ref 'AWS::StackName' ] ]
AttachInternetGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref Vpc
NatEIP0:
Condition: AZ0
Type: AWS::EC2::EIP
Properties:
Domain: vpc
NatGateway0:
Condition: AZ0
Type: AWS::EC2::NatGateway
DependsOn: AttachInternetGateway
Properties:
AllocationId: !GetAtt NatEIP0.AllocationId
SubnetId: !Ref PublicSubnet0
NatRoute0:
Condition: AZ0
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref NatRouteTable0
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway0
NatRouteTable0:
Condition: AZ0
Type: AWS::EC2::RouteTable
Properties:
Tags:
- Key: Name
Value: !Join [ '', ['NatRouteTable0 / ', !Ref 'AWS::StackName' ] ]
- Key: Network
Value: Public
VpcId: !Ref Vpc
NatEIP1:
Condition: AZ1
Type: AWS::EC2::EIP
Properties:
Domain: vpc
NatGateway1:
Condition: AZ1
Type: AWS::EC2::NatGateway
DependsOn: AttachInternetGateway
Properties:
AllocationId: !GetAtt NatEIP1.AllocationId
SubnetId: !Ref PublicSubnet1
NatRoute1:
Condition: AZ1
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref NatRouteTable1
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway1
NatRouteTable1:
Condition: AZ1
Type: AWS::EC2::RouteTable
Properties:
Tags:
- Key: Name
Value: !Join [ '', [ 'NatRouteTable1 / ', !Ref 'AWS::StackName' ] ]
- Key: Network
Value: Public
VpcId: !Ref Vpc
NatEIP2:
Condition: AZ2
Type: AWS::EC2::EIP
Properties:
Domain: vpc
NatGateway2:
Condition: AZ2
Type: AWS::EC2::NatGateway
DependsOn: AttachInternetGateway
Properties:
AllocationId: !GetAtt NatEIP2.AllocationId
SubnetId: !Ref PublicSubnet2
NatRoute2:
Condition: AZ2
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref NatRouteTable2
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway2
NatRouteTable2:
Condition: AZ2
Type: AWS::EC2::RouteTable
Properties:
Tags:
- Key: Name
Value: !Join [ '', [ 'NatRouteTable2 / ', !Ref 'AWS::StackName' ] ]
- Key: Network
Value: Public
VpcId: !Ref Vpc
NatEIP3:
Condition: AZ3
Type: AWS::EC2::EIP
Properties:
Domain: vpc
NatGateway3:
Condition: AZ3
Type: AWS::EC2::NatGateway
DependsOn: AttachInternetGateway
Properties:
AllocationId: !GetAtt NatEIP3.AllocationId
SubnetId: !Ref PublicSubnet3
NatRoute3:
Condition: AZ3
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref NatRouteTable3
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway3
NatRouteTable3:
Condition: AZ3
Type: AWS::EC2::RouteTable
Properties:
Tags:
- Key: Name
Value: !Join [ '', [ 'NatRouteTable3 / ', !Ref 'AWS::StackName' ] ]
- Key: Network
Value: Public
VpcId: !Ref Vpc
NatEIP4:
Condition: AZ4
Type: AWS::EC2::EIP
Properties:
Domain: vpc
NatGateway4:
Condition: AZ4
Type: AWS::EC2::NatGateway
DependsOn: AttachInternetGateway
Properties:
AllocationId: !GetAtt NatEIP4.AllocationId
SubnetId: !Ref PublicSubnet4
NatRoute4:
Condition: AZ4
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref NatRouteTable4
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway4
NatRouteTable4:
Condition: AZ4
Type: AWS::EC2::RouteTable
Properties:
Tags:
- Key: Name
Value: !Join [ '', [ 'NatRouteTable4 / ', !Ref 'AWS::StackName' ] ]
- Key: Network
Value: Public
VpcId: !Ref Vpc
NatEIP5:
Condition: AZ5
Type: AWS::EC2::EIP
Properties:
Domain: vpc
NatGateway5:
Condition: AZ5
Type: AWS::EC2::NatGateway
DependsOn: AttachInternetGateway
Properties:
AllocationId: !GetAtt NatEIP5.AllocationId
SubnetId: !Ref PublicSubnet5
NatRoute5:
Condition: AZ5
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref NatRouteTable5
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway5
NatRouteTable5:
Condition: AZ5
Type: AWS::EC2::RouteTable
Properties:
Tags:
- Key: Name
Value: !Join [ '', [ 'NatRouteTable5 / ', !Ref 'AWS::StackName' ] ]
- Key: Network
Value: Public
VpcId: !Ref Vpc
PublicRoute:
Type: AWS::EC2::Route
DependsOn: AttachInternetGateway
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
Tags:
- Key: Name
Value: !Join [ '', [ 'PublicRouteTable / ', !Ref 'AWS::StackName' ] ]
- Key: Network
Value: Public
VpcId: !Ref Vpc
PublicRouteTableAssociation0:
Condition: AZ0
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet0
RouteTableId: !Ref PublicRouteTable
PublicRouteTableAssociation1:
Condition: AZ1
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet1
RouteTableId: !Ref PublicRouteTable
PublicRouteTableAssociation2:
Condition: AZ2
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet2
RouteTableId: !Ref PublicRouteTable
PublicRouteTableAssociation3:
Condition: AZ3
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet3
RouteTableId: !Ref PublicRouteTable
PublicRouteTableAssociation4:
Condition: AZ4
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet4
RouteTableId: !Ref PublicRouteTable
PublicRouteTableAssociation5:
Condition: AZ5
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet5
RouteTableId: !Ref PublicRouteTable
PublicSubnet0:
Condition: AZ0
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 0, !Ref AvailabilityZones ]
CidrBlock: !Ref PublicSubnet0Cidr
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Join [ '', [ 'PublicSubnet0 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Public
VpcId: !Ref Vpc
PublicSubnet1:
Condition: AZ1
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 1, !Ref AvailabilityZones ]
CidrBlock: !Ref PublicSubnet1Cidr
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Join [ '', [ 'PublicSubnet1 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Public
VpcId: !Ref Vpc
PublicSubnet2:
Condition: AZ2
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 2, !Ref AvailabilityZones ]
CidrBlock: !Ref PublicSubnet2Cidr
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Join [ '', [ 'PublicSubnet2 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Public
VpcId: !Ref Vpc
PublicSubnet3:
Condition: AZ3
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 3, !Ref AvailabilityZones ]
CidrBlock: !Ref PublicSubnet3Cidr
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Join [ '', [ 'PublicSubnet3 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Public
VpcId: !Ref Vpc
PublicSubnet4:
Condition: AZ4
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 4, !Ref AvailabilityZones ]
CidrBlock: !Ref PublicSubnet4Cidr
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Join [ '', [ 'PublicSubnet4 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Public
VpcId: !Ref Vpc
PublicSubnet5:
Condition: AZ5
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 5, !Ref AvailabilityZones ]
CidrBlock: !Ref PublicSubnet5Cidr
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Join [ '', [ 'PublicSubnet5 / ', !Ref 'AWS::StackName' ] ]
- Key: SubnetType
Value: Public
VpcId: !Ref Vpc
Vpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCidr
EnableDnsHostnames: true
EnableDnsSupport: true
Tags:
- Key: Name
Value: !Join [ '', [ 'Vpc / ', !Ref 'AWS::StackName' ] ]
VpcFlowLog:
Type: AWS::EC2::FlowLog
Properties:
DeliverLogsPermissionArn: !GetAtt VpcFlowLogsRole.Arn
LogGroupName: !Join [ '', [ !Ref 'AWS::StackName', '-FlowLog' ] ]
ResourceId: !Ref Vpc
ResourceType: VPC
TrafficType: ALL
VpcFlowLogsLogGroup:
Type: AWS::Logs::LogGroup
VpcFlowLogsRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- vpc-flow-logs.amazonaws.com
Path: '/'
Policies:
- PolicyName: root
PolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:DescribeLogGroups
- logs:DescribeLogStreams
- logs:PutLogEvents
Effect: Allow
Resource: '*'
Outputs:
Vpc:
Value: !Ref Vpc
VpcCidr:
Value: !Ref VpcCidr
PublicSubnet0:
Condition: AZ0
Value: !Ref PublicSubnet0
PublicSubnet1:
Condition: AZ1
Value: !Ref PublicSubnet1
PublicSubnet2:
Condition: AZ2
Value: !Ref PublicSubnet2
PublicSubnet3:
Condition: AZ3
Value: !Ref PublicSubnet3
PublicSubnet4:
Condition: AZ4
Value: !Ref PublicSubnet4
PublicSubnet5:
Condition: AZ5
Value: !Ref PublicSubnet5
WebSubnet0:
Condition: AZ0
Value: !Ref WebSubnet0
WebSubnet1:
Condition: AZ1
Value: !Ref WebSubnet1
WebSubnet2:
Condition: AZ2
Value: !Ref WebSubnet2
WebSubnet3:
Condition: AZ3
Value: !Ref WebSubnet3
WebSubnet4:
Condition: AZ4
Value: !Ref WebSubnet4
WebSubnet5:
Condition: AZ5
Value: !Ref WebSubnet5
DataSubnet0:
Condition: AZ0
Value: !Ref DataSubnet0
DataSubnet1:
Condition: AZ1
Value: !Ref DataSubnet1
DataSubnet2:
Condition: AZ2
Value: !Ref DataSubnet2
DataSubnet3:
Condition: AZ3
Value: !Ref DataSubnet3
DataSubnet4:
Condition: AZ4
Value: !Ref DataSubnet4
DataSubnet5:
Condition: AZ5
Value: !Ref DataSubnet5
DataSubnet:
Value:
!If
[ NumberOfAZs1,
!Ref DataSubnet0,
!If
[ NumberOfAZs2,
!Join [ ',', [ !Ref DataSubnet0, !Ref DataSubnet1 ] ],
!If
[ NumberOfAZs3,
!Join [ ',', [ !Ref DataSubnet0, !Ref DataSubnet1, !Ref DataSubnet2 ] ],
!If
[ NumberOfAZs4,
!Join [ ',', [ !Ref DataSubnet0, !Ref DataSubnet1, !Ref DataSubnet2, !Ref DataSubnet3 ] ],
!If
[ NumberOfAZs5,
!Join [ ',', [ !Ref DataSubnet0, !Ref DataSubnet1, !Ref DataSubnet2, !Ref DataSubnet3, !Ref DataSubnet4 ] ],
!Join [ ',', [ !Ref DataSubnet0, !Ref DataSubnet1, !Ref DataSubnet2, !Ref DataSubnet3, !Ref DataSubnet4, !Ref DataSubnet5 ] ]
]
]
]
]
]
WebSubnet:
Value:
!If
[ NumberOfAZs1,
!Ref WebSubnet0,
!If
[ NumberOfAZs2,
!Join [ ',', [ !Ref WebSubnet0, !Ref WebSubnet1 ] ],
!If
[ NumberOfAZs3,
!Join [ ',', [ !Ref WebSubnet0, !Ref WebSubnet1, !Ref WebSubnet2 ] ],
!If
[ NumberOfAZs4,
!Join [ ',', [ !Ref WebSubnet0, !Ref WebSubnet1, !Ref WebSubnet2, !Ref WebSubnet3 ] ],
!If
[ NumberOfAZs5,
!Join [ ',', [ !Ref WebSubnet0, !Ref WebSubnet1, !Ref WebSubnet2, !Ref WebSubnet3, !Ref WebSubnet4 ] ],
!Join [ ',', [ !Ref WebSubnet0, !Ref WebSubnet1, !Ref WebSubnet2, !Ref WebSubnet3, !Ref WebSubnet4, !Ref WebSubnet5 ] ]
]
]
]
]
]
PublicSubnet:
Value:
!If
[ NumberOfAZs1,
!Ref PublicSubnet0,
!If
[ NumberOfAZs2,
!Join [ ',', [ !Ref PublicSubnet0, !Ref PublicSubnet1 ] ],
!If
[ NumberOfAZs3,
!Join [ ',', [ !Ref PublicSubnet0, !Ref PublicSubnet1, !Ref PublicSubnet2 ] ],
!If
[ NumberOfAZs4,
!Join [ ',', [ !Ref PublicSubnet0, !Ref PublicSubnet1, !Ref PublicSubnet2, !Ref PublicSubnet3 ] ],
!If
[ NumberOfAZs5,
!Join [ ',', [ !Ref PublicSubnet0, !Ref PublicSubnet1, !Ref PublicSubnet2, !Ref PublicSubnet3, !Ref PublicSubnet4 ] ],
!Join [ ',', [ !Ref PublicSubnet0, !Ref PublicSubnet1, !Ref PublicSubnet2, !Ref PublicSubnet3, !Ref PublicSubnet4, !Ref PublicSubnet5 ] ]
]
]
]
]
]