lono-cfn 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ module LonoCfn
2
+ VERSION = "0.0.1"
3
+ end
data/lono_cfn.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lono_cfn/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lono-cfn"
8
+ spec.version = LonoCfn::VERSION
9
+ spec.authors = ["Tung Nguyen"]
10
+ spec.email = ["tongueroo@gmail.com"]
11
+ spec.description = %q{Wrapper cfn tool to quickly create CloudFormation stacks from lono templates and params files}
12
+ spec.summary = %q{Wrapper cfn tool to quickly create CloudFormation stacks from lono templates and params files}
13
+ spec.homepage = "https://github.com/tongueroo/lono-cfn"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor"
22
+ spec.add_dependency "hashie"
23
+ spec.add_dependency "colorize"
24
+ spec.add_dependency "lono"
25
+ spec.add_dependency "aws-sdk"
26
+ spec.add_dependency "lono-params"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.3"
29
+ spec.add_development_dependency "rake"
30
+ spec.add_development_dependency "guard"
31
+ spec.add_development_dependency "guard-bundler"
32
+ spec.add_development_dependency "guard-rspec"
33
+ end
@@ -0,0 +1 @@
1
+ # this file is just in here to get the lono-cfn spec to pass
@@ -0,0 +1,829 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Conditions": {
4
+ "CreateEC2LCWithKeyPair": {
5
+ "Fn::Not": [
6
+ {
7
+ "Fn::Equals": [
8
+ {
9
+ "Ref": "KeyName"
10
+ },
11
+ ""
12
+ ]
13
+ }
14
+ ]
15
+ },
16
+ "CreateEC2LCWithoutKeyPair": {
17
+ "Fn::Equals": [
18
+ {
19
+ "Ref": "KeyName"
20
+ },
21
+ ""
22
+ ]
23
+ },
24
+ "CreateELB": {
25
+ "Fn::Or": [
26
+ {
27
+ "Condition": "CreateELBForExistingVpc"
28
+ },
29
+ {
30
+ "Condition": "CreateELBForNewVpc"
31
+ }
32
+ ]
33
+ },
34
+ "CreateELBForExistingVpc": {
35
+ "Fn::And": [
36
+ {
37
+ "Fn::Equals": [
38
+ {
39
+ "Ref": "CreateElasticLoadBalancer"
40
+ },
41
+ "true"
42
+ ]
43
+ },
44
+ {
45
+ "Condition": "ExistingVpcResources"
46
+ }
47
+ ]
48
+ },
49
+ "CreateELBForNewVpc": {
50
+ "Fn::And": [
51
+ {
52
+ "Fn::Equals": [
53
+ {
54
+ "Ref": "CreateElasticLoadBalancer"
55
+ },
56
+ "true"
57
+ ]
58
+ },
59
+ {
60
+ "Condition": "CreateVpcResources"
61
+ }
62
+ ]
63
+ },
64
+ "CreateVpcResources": {
65
+ "Fn::Equals": [
66
+ {
67
+ "Ref": "VpcId"
68
+ },
69
+ ""
70
+ ]
71
+ },
72
+ "ExistingVpcResources": {
73
+ "Fn::Not": [
74
+ {
75
+ "Fn::Equals": [
76
+ {
77
+ "Ref": "VpcId"
78
+ },
79
+ ""
80
+ ]
81
+ }
82
+ ]
83
+ },
84
+ "SetEndpointToECSAgent": {
85
+ "Fn::Not": [
86
+ {
87
+ "Fn::Equals": [
88
+ {
89
+ "Ref": "EcsEndpoint"
90
+ },
91
+ ""
92
+ ]
93
+ }
94
+ ]
95
+ },
96
+ "UseSpecifiedVpcAvailabilityZones": {
97
+ "Fn::Not": [
98
+ {
99
+ "Fn::Equals": [
100
+ {
101
+ "Fn::Join": [
102
+ "",
103
+ {
104
+ "Ref": "VpcAvailabilityZones"
105
+ }
106
+ ]
107
+ },
108
+ ""
109
+ ]
110
+ }
111
+ ]
112
+ }
113
+ },
114
+ "Description": "AWS CloudFormation template to create a new VPC or use an existing VPC for ECS deployment",
115
+ "Mappings": {
116
+ "VpcCidrs": {
117
+ "ap-northeast-1": {
118
+ "pubsubnet1": "10.0.0.0/24",
119
+ "pubsubnet2": "10.0.1.0/24",
120
+ "vpc": "10.0.0.0/16"
121
+ },
122
+ "ap-southeast-1": {
123
+ "pubsubnet1": "10.0.0.0/24",
124
+ "pubsubnet2": "10.0.1.0/24",
125
+ "vpc": "10.0.0.0/16"
126
+ },
127
+ "ap-southeast-2": {
128
+ "pubsubnet1": "10.0.0.0/24",
129
+ "pubsubnet2": "10.0.1.0/24",
130
+ "vpc": "10.0.0.0/16"
131
+ },
132
+ "eu-central-1": {
133
+ "pubsubnet1": "10.0.0.0/24",
134
+ "pubsubnet2": "10.0.1.0/24",
135
+ "vpc": "10.0.0.0/16"
136
+ },
137
+ "eu-west-1": {
138
+ "pubsubnet1": "10.0.0.0/24",
139
+ "pubsubnet2": "10.0.1.0/24",
140
+ "vpc": "10.0.0.0/16"
141
+ },
142
+ "sa-east-1": {
143
+ "pubsubnet1": "10.0.0.0/24",
144
+ "pubsubnet2": "10.0.1.0/24",
145
+ "vpc": "10.0.0.0/16"
146
+ },
147
+ "us-east-1": {
148
+ "pubsubnet1": "10.0.0.0/24",
149
+ "pubsubnet2": "10.0.1.0/24",
150
+ "vpc": "10.0.0.0/16"
151
+ },
152
+ "us-west-1": {
153
+ "pubsubnet1": "10.0.0.0/24",
154
+ "pubsubnet2": "10.0.1.0/24",
155
+ "vpc": "10.0.0.0/16"
156
+ },
157
+ "us-west-2": {
158
+ "pubsubnet1": "10.0.0.0/24",
159
+ "pubsubnet2": "10.0.1.0/24",
160
+ "vpc": "10.0.0.0/16"
161
+ }
162
+ }
163
+ },
164
+ "Outputs": {
165
+ "EcsElbName": {
166
+ "Description": "Load Balancer for ECS Service",
167
+ "Value": {
168
+ "Fn::If": [
169
+ "CreateELB",
170
+ {
171
+ "Fn::If": [
172
+ "CreateELBForNewVpc",
173
+ {
174
+ "Ref": "EcsElasticLoadBalancer"
175
+ },
176
+ {
177
+ "Ref": "EcsElasticLoadBalancerExistingVpc"
178
+ }
179
+ ]
180
+ },
181
+ ""
182
+ ]
183
+ }
184
+ },
185
+ "EcsInstanceAsgName": {
186
+ "Description": "Auto Scaling Group Name for ECS Instances",
187
+ "Value": {
188
+ "Ref": "EcsInstanceAsg"
189
+ }
190
+ }
191
+ },
192
+ "Parameters": {
193
+ "AsgMaxSize": {
194
+ "Default": "1",
195
+ "Description": "Maximum size and initial Desired Capacity of ECS Auto Scaling Group",
196
+ "Type": "Number"
197
+ },
198
+ "CreateElasticLoadBalancer": {
199
+ "Default": "false",
200
+ "Description": "Optional : When set to true, creates a ELB for ECS Service",
201
+ "Type": "String"
202
+ },
203
+ "EcsAmiId": {
204
+ "Description": "ECS AMI Id",
205
+ "Type": "String"
206
+ },
207
+ "EcsClusterName": {
208
+ "Default": "default",
209
+ "Description": "ECS Cluster Name",
210
+ "Type": "String"
211
+ },
212
+ "EcsEndpoint": {
213
+ "Default": "",
214
+ "Description": "Optional : ECS Endpoint for the ECS Agent to connect to",
215
+ "Type": "String"
216
+ },
217
+ "EcsInstanceType": {
218
+ "AllowedValues": [
219
+ "t2.micro",
220
+ "t2.small",
221
+ "t2.medium",
222
+ "t2.large",
223
+ "m4.large",
224
+ "m4.xlarge",
225
+ "m4.2xlarge",
226
+ "m4.4xlarge",
227
+ "m4.10xlarge",
228
+ "m3.medium",
229
+ "m3.large",
230
+ "m3.xlarge",
231
+ "m3.2xlarge",
232
+ "c4.large",
233
+ "c4.xlarge",
234
+ "c4.2xlarge",
235
+ "c4.4xlarge",
236
+ "c4.8xlarge",
237
+ "c3.large",
238
+ "c3.xlarge",
239
+ "c3.2xlarge",
240
+ "c3.4xlarge",
241
+ "c3.8xlarge",
242
+ "r3.large",
243
+ "r3.xlarge",
244
+ "r3.2xlarge",
245
+ "r3.4xlarge",
246
+ "r3.8xlarge",
247
+ "i2.xlarge",
248
+ "i2.2xlarge",
249
+ "i2.4xlarge",
250
+ "i2.8xlarge"
251
+ ],
252
+ "ConstraintDescription": "must be a valid EC2 instance type.",
253
+ "Default": "t2.micro",
254
+ "Description": "ECS EC2 instance type",
255
+ "Type": "String"
256
+ },
257
+ "EcsPort": {
258
+ "Default": "80",
259
+ "Description": "Optional - Security Group port to open on ECS instances - defaults to port 80",
260
+ "Type": "String"
261
+ },
262
+ "ElbHealthCheckTarget": {
263
+ "Default": "HTTP:80/",
264
+ "Description": "Optional - Health Check Target for ELB - defaults to HTTP:80/",
265
+ "Type": "String"
266
+ },
267
+ "ElbPort": {
268
+ "Default": "80",
269
+ "Description": "Optional - Security Group port to open on ELB - port 80 will be open by default",
270
+ "Type": "String"
271
+ },
272
+ "ElbProtocol": {
273
+ "Default": "HTTP",
274
+ "Description": "Optional - ELB Protocol - defaults to HTTP",
275
+ "Type": "String"
276
+ },
277
+ "IamRoleInstanceProfile": {
278
+ "Description": "Name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance",
279
+ "Type": "String"
280
+ },
281
+ "KeyName": {
282
+ "Default": "",
283
+ "Description": "Optional - Name of an existing EC2 KeyPair to enable SSH access to the ECS instances",
284
+ "Type": "String"
285
+ },
286
+ "SourceCidr": {
287
+ "Default": "0.0.0.0/0",
288
+ "Description": "Optional - CIDR/IP range for EcsPort and ElbPort - defaults to 0.0.0.0/0",
289
+ "Type": "String"
290
+ },
291
+ "SubnetIds": {
292
+ "Default": "",
293
+ "Description": "Optional - Comma separated list of existing VPC Subnet Ids where ECS instances will run",
294
+ "Type": "CommaDelimitedList"
295
+ },
296
+ "VpcAvailabilityZones": {
297
+ "Default": "",
298
+ "Description": "Optional : Comma-delimited list of two VPC availability zones in which to create subnets",
299
+ "Type": "CommaDelimitedList"
300
+ },
301
+ "VpcId": {
302
+ "AllowedPattern": "^(?:vpc-[0-9a-f]{8}|)$",
303
+ "ConstraintDescription": "VPC Id must begin with 'vpc-' or leave blank to have a new VPC created",
304
+ "Default": "",
305
+ "Description": "Optional - VPC Id of existing VPC. Leave blank to have a new VPC created",
306
+ "Type": "String"
307
+ }
308
+ },
309
+ "Resources": {
310
+ "AttachGateway": {
311
+ "Condition": "CreateVpcResources",
312
+ "Properties": {
313
+ "InternetGatewayId": {
314
+ "Ref": "InternetGateway"
315
+ },
316
+ "VpcId": {
317
+ "Ref": "Vpc"
318
+ }
319
+ },
320
+ "Type": "AWS::EC2::VPCGatewayAttachment"
321
+ },
322
+ "EcsElasticLoadBalancer": {
323
+ "Condition": "CreateELBForNewVpc",
324
+ "Properties": {
325
+ "CrossZone": "true",
326
+ "HealthCheck": {
327
+ "HealthyThreshold": "2",
328
+ "Interval": "30",
329
+ "Target": {
330
+ "Ref": "ElbHealthCheckTarget"
331
+ },
332
+ "Timeout": "5",
333
+ "UnhealthyThreshold": "10"
334
+ },
335
+ "Listeners": [
336
+ {
337
+ "InstancePort": {
338
+ "Ref": "EcsPort"
339
+ },
340
+ "LoadBalancerPort": {
341
+ "Ref": "ElbPort"
342
+ },
343
+ "Protocol": {
344
+ "Ref": "ElbProtocol"
345
+ }
346
+ }
347
+ ],
348
+ "SecurityGroups": [
349
+ {
350
+ "Ref": "ElbSecurityGroup"
351
+ }
352
+ ],
353
+ "Subnets": [
354
+ {
355
+ "Ref": "PubSubnetAz1"
356
+ },
357
+ {
358
+ "Ref": "PubSubnetAz2"
359
+ }
360
+ ]
361
+ },
362
+ "Type": "AWS::ElasticLoadBalancing::LoadBalancer"
363
+ },
364
+ "EcsElasticLoadBalancerExistingVpc": {
365
+ "Condition": "CreateELBForExistingVpc",
366
+ "Properties": {
367
+ "CrossZone": "true",
368
+ "HealthCheck": {
369
+ "HealthyThreshold": "2",
370
+ "Interval": "30",
371
+ "Target": {
372
+ "Ref": "ElbHealthCheckTarget"
373
+ },
374
+ "Timeout": "5",
375
+ "UnhealthyThreshold": "10"
376
+ },
377
+ "Listeners": [
378
+ {
379
+ "InstancePort": {
380
+ "Ref": "EcsPort"
381
+ },
382
+ "LoadBalancerPort": {
383
+ "Ref": "ElbPort"
384
+ },
385
+ "Protocol": {
386
+ "Ref": "ElbProtocol"
387
+ }
388
+ }
389
+ ],
390
+ "SecurityGroups": [
391
+ {
392
+ "Ref": "ElbSecurityGroup"
393
+ }
394
+ ],
395
+ "Subnets": {
396
+ "Ref": "SubnetIds"
397
+ }
398
+ },
399
+ "Type": "AWS::ElasticLoadBalancing::LoadBalancer"
400
+ },
401
+ "EcsInstanceAsg": {
402
+ "Properties": {
403
+ "DesiredCapacity": {
404
+ "Ref": "AsgMaxSize"
405
+ },
406
+ "LaunchConfigurationName": {
407
+ "Fn::If": [
408
+ "CreateEC2LCWithKeyPair",
409
+ {
410
+ "Ref": "EcsInstanceLc"
411
+ },
412
+ {
413
+ "Ref": "EcsInstanceLcWithoutKeyPair"
414
+ }
415
+ ]
416
+ },
417
+ "MaxSize": {
418
+ "Ref": "AsgMaxSize"
419
+ },
420
+ "MinSize": "1",
421
+ "Tags": [
422
+ {
423
+ "Key": "Name",
424
+ "PropagateAtLaunch": "true",
425
+ "Value": {
426
+ "Fn::Join": [
427
+ "",
428
+ [
429
+ "ECS Instance - ",
430
+ {
431
+ "Ref": "AWS::StackName"
432
+ }
433
+ ]
434
+ ]
435
+ }
436
+ }
437
+ ],
438
+ "VPCZoneIdentifier": {
439
+ "Fn::If": [
440
+ "CreateVpcResources",
441
+ [
442
+ {
443
+ "Fn::Join": [
444
+ ",",
445
+ [
446
+ {
447
+ "Ref": "PubSubnetAz1"
448
+ },
449
+ {
450
+ "Ref": "PubSubnetAz2"
451
+ }
452
+ ]
453
+ ]
454
+ }
455
+ ],
456
+ {
457
+ "Ref": "SubnetIds"
458
+ }
459
+ ]
460
+ }
461
+ },
462
+ "Type": "AWS::AutoScaling::AutoScalingGroup"
463
+ },
464
+ "EcsInstanceLc": {
465
+ "Condition": "CreateEC2LCWithKeyPair",
466
+ "Properties": {
467
+ "AssociatePublicIpAddress": true,
468
+ "IamInstanceProfile": {
469
+ "Ref": "IamRoleInstanceProfile"
470
+ },
471
+ "ImageId": {
472
+ "Ref": "EcsAmiId"
473
+ },
474
+ "InstanceType": {
475
+ "Ref": "EcsInstanceType"
476
+ },
477
+ "KeyName": {
478
+ "Ref": "KeyName"
479
+ },
480
+ "SecurityGroups": [
481
+ {
482
+ "Ref": "EcsSecurityGroup"
483
+ }
484
+ ],
485
+ "UserData": {
486
+ "Fn::If": [
487
+ "SetEndpointToECSAgent",
488
+ {
489
+ "Fn::Base64": {
490
+ "Fn::Join": [
491
+ "",
492
+ [
493
+ "#!/bin/bash\n",
494
+ "echo ECS_CLUSTER=",
495
+ {
496
+ "Ref": "EcsClusterName"
497
+ },
498
+ " >> /etc/ecs/ecs.config",
499
+ "\necho ECS_BACKEND_HOST=",
500
+ {
501
+ "Ref": "EcsEndpoint"
502
+ },
503
+ " >> /etc/ecs/ecs.config"
504
+ ]
505
+ ]
506
+ }
507
+ },
508
+ {
509
+ "Fn::Base64": {
510
+ "Fn::Join": [
511
+ "",
512
+ [
513
+ "#!/bin/bash\n",
514
+ "echo ECS_CLUSTER=",
515
+ {
516
+ "Ref": "EcsClusterName"
517
+ },
518
+ " >> /etc/ecs/ecs.config"
519
+ ]
520
+ ]
521
+ }
522
+ }
523
+ ]
524
+ }
525
+ },
526
+ "Type": "AWS::AutoScaling::LaunchConfiguration"
527
+ },
528
+ "EcsInstanceLcWithoutKeyPair": {
529
+ "Condition": "CreateEC2LCWithoutKeyPair",
530
+ "Properties": {
531
+ "AssociatePublicIpAddress": true,
532
+ "IamInstanceProfile": {
533
+ "Ref": "IamRoleInstanceProfile"
534
+ },
535
+ "ImageId": {
536
+ "Ref": "EcsAmiId"
537
+ },
538
+ "InstanceType": {
539
+ "Ref": "EcsInstanceType"
540
+ },
541
+ "SecurityGroups": [
542
+ {
543
+ "Ref": "EcsSecurityGroup"
544
+ }
545
+ ],
546
+ "UserData": {
547
+ "Fn::If": [
548
+ "SetEndpointToECSAgent",
549
+ {
550
+ "Fn::Base64": {
551
+ "Fn::Join": [
552
+ "",
553
+ [
554
+ "#!/bin/bash\n",
555
+ "echo ECS_CLUSTER=",
556
+ {
557
+ "Ref": "EcsClusterName"
558
+ },
559
+ " >> /etc/ecs/ecs.config",
560
+ "\necho ECS_BACKEND_HOST=",
561
+ {
562
+ "Ref": "EcsEndpoint"
563
+ },
564
+ " >> /etc/ecs/ecs.config"
565
+ ]
566
+ ]
567
+ }
568
+ },
569
+ {
570
+ "Fn::Base64": {
571
+ "Fn::Join": [
572
+ "",
573
+ [
574
+ "#!/bin/bash\n",
575
+ "echo ECS_CLUSTER=",
576
+ {
577
+ "Ref": "EcsClusterName"
578
+ },
579
+ " >> /etc/ecs/ecs.config"
580
+ ]
581
+ ]
582
+ }
583
+ }
584
+ ]
585
+ }
586
+ },
587
+ "Type": "AWS::AutoScaling::LaunchConfiguration"
588
+ },
589
+ "EcsSecurityGroup": {
590
+ "Properties": {
591
+ "GroupDescription": "ECS Allowed Ports",
592
+ "SecurityGroupIngress": {
593
+ "Fn::If": [
594
+ "CreateELB",
595
+ [
596
+ {
597
+ "CidrIp": {
598
+ "Ref": "SourceCidr"
599
+ },
600
+ "FromPort": {
601
+ "Ref": "EcsPort"
602
+ },
603
+ "IpProtocol": "tcp",
604
+ "ToPort": {
605
+ "Ref": "EcsPort"
606
+ }
607
+ },
608
+ {
609
+ "FromPort": "1",
610
+ "IpProtocol": "tcp",
611
+ "SourceSecurityGroupId": {
612
+ "Ref": "ElbSecurityGroup"
613
+ },
614
+ "ToPort": "65535"
615
+ }
616
+ ],
617
+ [
618
+ {
619
+ "CidrIp": {
620
+ "Ref": "SourceCidr"
621
+ },
622
+ "FromPort": {
623
+ "Ref": "EcsPort"
624
+ },
625
+ "IpProtocol": "tcp",
626
+ "ToPort": {
627
+ "Ref": "EcsPort"
628
+ }
629
+ }
630
+ ]
631
+ ]
632
+ },
633
+ "VpcId": {
634
+ "Fn::If": [
635
+ "CreateVpcResources",
636
+ {
637
+ "Ref": "Vpc"
638
+ },
639
+ {
640
+ "Ref": "VpcId"
641
+ }
642
+ ]
643
+ }
644
+ },
645
+ "Type": "AWS::EC2::SecurityGroup"
646
+ },
647
+ "ElbSecurityGroup": {
648
+ "Properties": {
649
+ "GroupDescription": "ELB Allowed Ports",
650
+ "SecurityGroupIngress": [
651
+ {
652
+ "CidrIp": {
653
+ "Ref": "SourceCidr"
654
+ },
655
+ "FromPort": {
656
+ "Ref": "ElbPort"
657
+ },
658
+ "IpProtocol": "tcp",
659
+ "ToPort": {
660
+ "Ref": "ElbPort"
661
+ }
662
+ }
663
+ ],
664
+ "VpcId": {
665
+ "Fn::If": [
666
+ "CreateVpcResources",
667
+ {
668
+ "Ref": "Vpc"
669
+ },
670
+ {
671
+ "Ref": "VpcId"
672
+ }
673
+ ]
674
+ }
675
+ },
676
+ "Type": "AWS::EC2::SecurityGroup"
677
+ },
678
+ "InternetGateway": {
679
+ "Condition": "CreateVpcResources",
680
+ "Type": "AWS::EC2::InternetGateway"
681
+ },
682
+ "PubSubnet1RouteTableAssociation": {
683
+ "Condition": "CreateVpcResources",
684
+ "Properties": {
685
+ "RouteTableId": {
686
+ "Ref": "RouteViaIgw"
687
+ },
688
+ "SubnetId": {
689
+ "Ref": "PubSubnetAz1"
690
+ }
691
+ },
692
+ "Type": "AWS::EC2::SubnetRouteTableAssociation"
693
+ },
694
+ "PubSubnet2RouteTableAssociation": {
695
+ "Condition": "CreateVpcResources",
696
+ "Properties": {
697
+ "RouteTableId": {
698
+ "Ref": "RouteViaIgw"
699
+ },
700
+ "SubnetId": {
701
+ "Ref": "PubSubnetAz2"
702
+ }
703
+ },
704
+ "Type": "AWS::EC2::SubnetRouteTableAssociation"
705
+ },
706
+ "PubSubnetAz1": {
707
+ "Condition": "CreateVpcResources",
708
+ "Properties": {
709
+ "AvailabilityZone": {
710
+ "Fn::If": [
711
+ "UseSpecifiedVpcAvailabilityZones",
712
+ {
713
+ "Fn::Select": [
714
+ "0",
715
+ {
716
+ "Ref": "VpcAvailabilityZones"
717
+ }
718
+ ]
719
+ },
720
+ {
721
+ "Fn::Select": [
722
+ "0",
723
+ {
724
+ "Fn::GetAZs": {
725
+ "Ref": "AWS::Region"
726
+ }
727
+ }
728
+ ]
729
+ }
730
+ ]
731
+ },
732
+ "CidrBlock": {
733
+ "Fn::FindInMap": [
734
+ "VpcCidrs",
735
+ {
736
+ "Ref": "AWS::Region"
737
+ },
738
+ "pubsubnet1"
739
+ ]
740
+ },
741
+ "VpcId": {
742
+ "Ref": "Vpc"
743
+ }
744
+ },
745
+ "Type": "AWS::EC2::Subnet"
746
+ },
747
+ "PubSubnetAz2": {
748
+ "Condition": "CreateVpcResources",
749
+ "Properties": {
750
+ "AvailabilityZone": {
751
+ "Fn::If": [
752
+ "UseSpecifiedVpcAvailabilityZones",
753
+ {
754
+ "Fn::Select": [
755
+ "1",
756
+ {
757
+ "Ref": "VpcAvailabilityZones"
758
+ }
759
+ ]
760
+ },
761
+ {
762
+ "Fn::Select": [
763
+ "1",
764
+ {
765
+ "Fn::GetAZs": {
766
+ "Ref": "AWS::Region"
767
+ }
768
+ }
769
+ ]
770
+ }
771
+ ]
772
+ },
773
+ "CidrBlock": {
774
+ "Fn::FindInMap": [
775
+ "VpcCidrs",
776
+ {
777
+ "Ref": "AWS::Region"
778
+ },
779
+ "pubsubnet2"
780
+ ]
781
+ },
782
+ "VpcId": {
783
+ "Ref": "Vpc"
784
+ }
785
+ },
786
+ "Type": "AWS::EC2::Subnet"
787
+ },
788
+ "PublicRouteViaIgw": {
789
+ "Condition": "CreateVpcResources",
790
+ "DependsOn": "AttachGateway",
791
+ "Properties": {
792
+ "DestinationCidrBlock": "0.0.0.0/0",
793
+ "GatewayId": {
794
+ "Ref": "InternetGateway"
795
+ },
796
+ "RouteTableId": {
797
+ "Ref": "RouteViaIgw"
798
+ }
799
+ },
800
+ "Type": "AWS::EC2::Route"
801
+ },
802
+ "RouteViaIgw": {
803
+ "Condition": "CreateVpcResources",
804
+ "Properties": {
805
+ "VpcId": {
806
+ "Ref": "Vpc"
807
+ }
808
+ },
809
+ "Type": "AWS::EC2::RouteTable"
810
+ },
811
+ "Vpc": {
812
+ "Condition": "CreateVpcResources",
813
+ "Properties": {
814
+ "CidrBlock": {
815
+ "Fn::FindInMap": [
816
+ "VpcCidrs",
817
+ {
818
+ "Ref": "AWS::Region"
819
+ },
820
+ "vpc"
821
+ ]
822
+ },
823
+ "EnableDnsHostnames": "true",
824
+ "EnableDnsSupport": "true"
825
+ },
826
+ "Type": "AWS::EC2::VPC"
827
+ }
828
+ }
829
+ }