@@ -8,18 +8,25 @@ Description: CloudFormation template to create a ROSA Quickstart default VPC.
8
8
This CloudFormation template may not work with rosa CLI versions later than 1.2.48.
9
9
Please ensure that you are using the compatible CLI version before deploying this template.
10
10
11
- Transform: 'AWS::LanguageExtensions'
12
-
13
11
Parameters:
14
12
AvailabilityZoneCount:
15
13
Type: Number
16
14
Description: "Number of Availability Zones to use"
17
15
Default: 1
18
16
MinValue: 1
19
17
MaxValue: 3
20
- AvailabilityZones:
21
- Type: CommaDelimitedList
22
- Description: "List of Availability Zones to use"
18
+ AZ1:
19
+ Type: String
20
+ Description: "First availability zone to use"
21
+ Default: ""
22
+ AZ2:
23
+ Type: String
24
+ Description: "Second availability zone to use"
25
+ Default: ""
26
+ AZ3:
27
+ Type: String
28
+ Description: "Third availability zone to use"
29
+ Default: ""
23
30
Region:
24
31
Type: String
25
32
Description: "AWS Region"
@@ -33,24 +40,20 @@ Parameters:
33
40
Default: '10.0.0.0/16'
34
41
35
42
Conditions:
36
- AZ3Explicit : !Equals [Fn::Length: !Ref AvailabilityZones, 3 ]
37
- AZ2Explicit: !Or [!Equals [Fn::Length: !Ref AvailabilityZones, 2], !Condition AZ3Explicit ]
38
- AZ1Explicit : !Or [!Equals [Fn::Length: !Ref AvailabilityZones, 1], !Condition AZ2Explicit ]
43
+ AZ1Explicit : !Not [!Equals [ !Ref AZ1, ""] ]
44
+ AZ2Explicit: !Not [!Equals [!Ref AZ2, ""] ]
45
+ AZ3Explicit : !Not [!Equals [!Ref AZ3, ""] ]
39
46
40
- HasAZ1: !Or [!Equals [!Ref AvailabilityZoneCount, 1], !Condition AZ1Explicit]
41
- HasAZ2: !Or [!Equals [!Ref AvailabilityZoneCount, 2], !Condition AZ2Explicit]
42
- HasAZ3: !Or [!Equals [!Ref AvailabilityZoneCount, 3], !Condition AZ3Explicit]
47
+ ExplicitAZs: !Or [!Condition AZ1Explicit, !Condition AZ2Explicit, !Condition AZ3Explicit]
48
+ NoExplicitAZs: !Not [!Condition ExplicitAZs]
43
49
44
- One:
45
- Fn::Or:
46
- - Condition: HasAZ1
47
- - Condition: HasAZ2
48
- - Condition: HasAZ3
50
+ AZ3Implicit: !Equals [!Ref AvailabilityZoneCount, 3]
51
+ AZ2Implicit: !Or [!Equals [!Ref AvailabilityZoneCount, 2], !Condition AZ3Implicit]
52
+ AZ1Implicit: !Or [!Equals [!Ref AvailabilityZoneCount, 1], !Condition AZ2Implicit]
49
53
50
- Two:
51
- Fn::Or:
52
- - Condition: HasAZ3
53
- - Condition: HasAZ2
54
+ One: !Or [!And [!Condition ExplicitAZs, !Condition AZ1Explicit], !And [!Condition NoExplicitAZs, !Condition AZ1Implicit]]
55
+ Two: !Or [!And [!Condition ExplicitAZs, !Condition AZ2Explicit], !And [!Condition NoExplicitAZs, !Condition AZ2Implicit]]
56
+ Three: !Or [!And [!Condition ExplicitAZs, !Condition AZ3Explicit], !And [!Condition NoExplicitAZs, !Condition AZ3Implicit]]
54
57
55
58
Resources:
56
59
VPC:
@@ -80,12 +83,12 @@ Resources:
80
83
- !Ref PrivateRouteTable
81
84
82
85
SubnetPublic1:
83
- Condition: One
84
86
Type: AWS::EC2::Subnet
87
+ Condition: One
85
88
Properties:
86
89
VpcId: !Ref VPC
87
90
CidrBlock: !Select [0, !Cidr [!Ref VpcCidr, 6, 8]]
88
- AvailabilityZone: !If [AZ1Explicit , !Select [0, ! Ref AvailabilityZones] , !Select [0, !GetAZs '']]
91
+ AvailabilityZone: !If [ExplicitAZs , !Ref AZ1 , !Select [0, !GetAZs '']]
89
92
MapPublicIpOnLaunch: true
90
93
Tags:
91
94
- Key: Name
@@ -95,17 +98,17 @@ Resources:
95
98
- Key: 'rosa_hcp_policies'
96
99
Value: 'true'
97
100
- Key: 'service'
98
- Value: 'ROSA'
101
+ Value: 'ROSA'
99
102
- Key: 'kubernetes.io/role/elb'
100
103
Value: '1'
101
104
102
105
SubnetPrivate1:
103
- Condition: One
104
106
Type: AWS::EC2::Subnet
107
+ Condition: One
105
108
Properties:
106
109
VpcId: !Ref VPC
107
110
CidrBlock: !Select [1, !Cidr [!Ref VpcCidr, 6, 8]]
108
- AvailabilityZone: !If [AZ1Explicit , !Select [0, ! Ref AvailabilityZones] , !Select [0, !GetAZs '']]
111
+ AvailabilityZone: !If [ExplicitAZs , !Ref AZ1 , !Select [0, !GetAZs '']]
109
112
MapPublicIpOnLaunch: false
110
113
Tags:
111
114
- Key: Name
@@ -115,17 +118,17 @@ Resources:
115
118
- Key: 'rosa_hcp_policies'
116
119
Value: 'true'
117
120
- Key: 'service'
118
- Value: 'ROSA'
121
+ Value: 'ROSA'
119
122
- Key: 'kubernetes.io/role/internal-elb'
120
123
Value: '1'
121
124
122
125
SubnetPublic2:
123
- Condition: Two
124
126
Type: AWS::EC2::Subnet
127
+ Condition: Two
125
128
Properties:
126
129
VpcId: !Ref VPC
127
130
CidrBlock: !Select [2, !Cidr [!Ref VpcCidr, 6, 8]]
128
- AvailabilityZone: !If [AZ2Explicit , !Select [1, ! Ref AvailabilityZones] , !Select [1, !GetAZs '']]
131
+ AvailabilityZone: !If [ExplicitAZs , !Ref AZ2 , !Select [1, !GetAZs '']]
129
132
MapPublicIpOnLaunch: true
130
133
Tags:
131
134
- Key: Name
@@ -140,12 +143,12 @@ Resources:
140
143
Value: '1'
141
144
142
145
SubnetPrivate2:
143
- Condition: Two
144
146
Type: AWS::EC2::Subnet
147
+ Condition: Two
145
148
Properties:
146
149
VpcId: !Ref VPC
147
150
CidrBlock: !Select [3, !Cidr [!Ref VpcCidr, 6, 8]]
148
- AvailabilityZone: !If [AZ2Explicit , !Select [1, ! Ref AvailabilityZones] , !Select [1, !GetAZs '']]
151
+ AvailabilityZone: !If [ExplicitAZs , !Ref AZ2 , !Select [1, !GetAZs '']]
149
152
MapPublicIpOnLaunch: false
150
153
Tags:
151
154
- Key: Name
@@ -160,12 +163,12 @@ Resources:
160
163
Value: '1'
161
164
162
165
SubnetPublic3:
163
- Condition: HasAZ3
164
166
Type: AWS::EC2::Subnet
167
+ Condition: Three
165
168
Properties:
166
169
VpcId: !Ref VPC
167
170
CidrBlock: !Select [4, !Cidr [!Ref VpcCidr, 6, 8]]
168
- AvailabilityZone: !If [AZ3Explicit , !Select [2, ! Ref AvailabilityZones] , !Select [2, !GetAZs '']]
171
+ AvailabilityZone: !If [ExplicitAZs , !Ref AZ3 , !Select [2, !GetAZs '']]
169
172
MapPublicIpOnLaunch: true
170
173
Tags:
171
174
- Key: Name
@@ -180,12 +183,12 @@ Resources:
180
183
Value: '1'
181
184
182
185
SubnetPrivate3:
183
- Condition: HasAZ3
184
186
Type: AWS::EC2::Subnet
187
+ Condition: Three
185
188
Properties:
186
189
VpcId: !Ref VPC
187
190
CidrBlock: !Select [5, !Cidr [!Ref VpcCidr, 6, 8]]
188
- AvailabilityZone: !If [AZ3Explicit , !Select [2, ! Ref AvailabilityZones] , !Select [2, !GetAZs '']]
191
+ AvailabilityZone: !If [ExplicitAZs , !Ref AZ3 , !Select [2, !GetAZs '']]
189
192
MapPublicIpOnLaunch: false
190
193
Tags:
191
194
- Key: Name
@@ -219,6 +222,7 @@ Resources:
219
222
InternetGatewayId: !Ref InternetGateway
220
223
221
224
ElasticIP1:
225
+ Condition: One
222
226
Type: AWS::EC2::EIP
223
227
Properties:
224
228
Domain: vpc
@@ -233,6 +237,7 @@ Resources:
233
237
Value: 'ROSA'
234
238
235
239
ElasticIP2:
240
+ Condition: Two
236
241
Type: AWS::EC2::EIP
237
242
Properties:
238
243
Domain: vpc
@@ -247,7 +252,7 @@ Resources:
247
252
Value: 'ROSA'
248
253
249
254
ElasticIP3:
250
- Condition: HasAZ3
255
+ Condition: Three
251
256
Type: AWS::EC2::EIP
252
257
Properties:
253
258
Domain: vpc
@@ -294,7 +299,7 @@ Resources:
294
299
Value: 'ROSA'
295
300
296
301
NATGateway3:
297
- Condition: HasAZ3
302
+ Condition: Three
298
303
Type: 'AWS::EC2::NatGateway'
299
304
Properties:
300
305
AllocationId: !GetAtt ElasticIP3.AllocationId
@@ -357,7 +362,7 @@ Resources:
357
362
- Two
358
363
- !Ref NATGateway2
359
364
- !If
360
- - HasAZ3
365
+ - Three
361
366
- !Ref NATGateway3
362
367
- !Ref "AWS::NoValue"
363
368
@@ -376,7 +381,7 @@ Resources:
376
381
RouteTableId: !Ref PublicRouteTable
377
382
378
383
PublicSubnetRouteTableAssociation3:
379
- Condition: HasAZ3
384
+ Condition: Three
380
385
Type: AWS::EC2::SubnetRouteTableAssociation
381
386
Properties:
382
387
SubnetId: !Ref SubnetPublic3
@@ -397,7 +402,7 @@ Resources:
397
402
RouteTableId: !Ref PrivateRouteTable
398
403
399
404
PrivateSubnetRouteTableAssociation3:
400
- Condition: HasAZ3
405
+ Condition: Three
401
406
Type: AWS::EC2::SubnetRouteTableAssociation
402
407
Properties:
403
408
SubnetId: !Ref SubnetPrivate3
@@ -435,11 +440,11 @@ Resources:
435
440
ServiceName: !Sub "com.amazonaws.${Region}.ec2"
436
441
PrivateDnsEnabled: true
437
442
VpcEndpointType: Interface
438
- SubnetIds:
443
+ SubnetIds:
439
444
- !If [One, !Ref SubnetPrivate1, !Ref "AWS::NoValue"]
440
445
- !If [Two, !Ref SubnetPrivate2, !Ref "AWS::NoValue"]
441
- - !If [HasAZ3 , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]
442
- SecurityGroupIds:
446
+ - !If [Three , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]
447
+ SecurityGroupIds:
443
448
- !Ref SecurityGroup
444
449
445
450
KMSVPCEndpoint:
@@ -449,11 +454,11 @@ Resources:
449
454
ServiceName: !Sub "com.amazonaws.${Region}.kms"
450
455
PrivateDnsEnabled: true
451
456
VpcEndpointType: Interface
452
- SubnetIds:
457
+ SubnetIds:
453
458
- !If [One, !Ref SubnetPrivate1, !Ref "AWS::NoValue"]
454
459
- !If [Two, !Ref SubnetPrivate2, !Ref "AWS::NoValue"]
455
- - !If [HasAZ3 , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]
456
- SecurityGroupIds:
460
+ - !If [Three , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]
461
+ SecurityGroupIds:
457
462
- !Ref SecurityGroup
458
463
459
464
STSVPCEndpoint:
@@ -463,11 +468,11 @@ Resources:
463
468
ServiceName: !Sub "com.amazonaws.${Region}.sts"
464
469
PrivateDnsEnabled: true
465
470
VpcEndpointType: Interface
466
- SubnetIds:
471
+ SubnetIds:
467
472
- !If [One, !Ref SubnetPrivate1, !Ref "AWS::NoValue"]
468
473
- !If [Two, !Ref SubnetPrivate2, !Ref "AWS::NoValue"]
469
- - !If [HasAZ3 , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]
470
- SecurityGroupIds:
474
+ - !If [Three , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]
475
+ SecurityGroupIds:
471
476
- !Ref SecurityGroup
472
477
473
478
EcrApiVPCEndpoint:
@@ -477,11 +482,11 @@ Resources:
477
482
ServiceName: !Sub "com.amazonaws.${Region}.ecr.api"
478
483
PrivateDnsEnabled: true
479
484
VpcEndpointType: Interface
480
- SubnetIds:
485
+ SubnetIds:
481
486
- !If [One, !Ref SubnetPrivate1, !Ref "AWS::NoValue"]
482
487
- !If [Two, !Ref SubnetPrivate2, !Ref "AWS::NoValue"]
483
- - !If [HasAZ3 , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]
484
- SecurityGroupIds:
488
+ - !If [Three , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]
489
+ SecurityGroupIds:
485
490
- !Ref SecurityGroup
486
491
487
492
EcrDkrVPCEndpoint:
@@ -491,11 +496,11 @@ Resources:
491
496
ServiceName: !Sub "com.amazonaws.${Region}.ecr.dkr"
492
497
PrivateDnsEnabled: true
493
498
VpcEndpointType: Interface
494
- SubnetIds:
499
+ SubnetIds:
495
500
- !If [One, !Ref SubnetPrivate1, !Ref "AWS::NoValue"]
496
501
- !If [Two, !Ref SubnetPrivate2, !Ref "AWS::NoValue"]
497
- - !If [HasAZ3 , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]
498
- SecurityGroupIds:
502
+ - !If [Three , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]
503
+ SecurityGroupIds:
499
504
- !Ref SecurityGroup
500
505
501
506
Outputs:
@@ -513,13 +518,13 @@ Outputs:
513
518
514
519
PublicSubnets:
515
520
Description: "Public Subnet Ids"
516
- Value: !Join [",", [!If [One, !Ref SubnetPublic1, !Ref "AWS::NoValue"], !If [Two, !Ref SubnetPublic2, !Ref "AWS::NoValue"], !If [HasAZ3 , !Ref SubnetPublic3, !Ref "AWS::NoValue"]]]
521
+ Value: !Join [",", [!If [One, !Ref SubnetPublic1, !Ref "AWS::NoValue"], !If [Two, !Ref SubnetPublic2, !Ref "AWS::NoValue"], !If [Three , !Ref SubnetPublic3, !Ref "AWS::NoValue"]]]
517
522
Export:
518
523
Name: !Sub "${Name}-PublicSubnets"
519
524
520
525
PrivateSubnets:
521
526
Description: "Private Subnet Ids"
522
- Value: !Join [",", [!If [One, !Ref SubnetPrivate1, !Ref "AWS::NoValue"], !If [Two, !Ref SubnetPrivate2, !Ref "AWS::NoValue"], !If [HasAZ3 , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]]]
527
+ Value: !Join [",", [!If [One, !Ref SubnetPrivate1, !Ref "AWS::NoValue"], !If [Two, !Ref SubnetPrivate2, !Ref "AWS::NoValue"], !If [Three , !Ref SubnetPrivate3, !Ref "AWS::NoValue"]]]
523
528
Export:
524
529
Name: !Sub "${Name}-PrivateSubnets"
525
530
@@ -530,21 +535,22 @@ Outputs:
530
535
Name: !Sub "${Name}-EIP1-AllocationId"
531
536
532
537
EIP2AllocationId:
538
+ Condition: Two
533
539
Description: Allocation ID for ElasticIP2
534
540
Value: !GetAtt ElasticIP2.AllocationId
535
541
Export:
536
542
Name: !Sub "${Name}-EIP2-AllocationId"
537
543
538
544
EIP3AllocationId:
539
- Condition: HasAZ3
545
+ Condition: Three
540
546
Description: Allocation ID for ElasticIP3
541
547
Value: !GetAtt ElasticIP3.AllocationId
542
548
Export:
543
549
Name: !Sub "${Name}-EIP3-AllocationId"
544
550
545
551
NatGatewayId:
546
552
Description: The NAT Gateway IDs
547
- Value: !Join [",", [!If [One, !Ref NATGateway1, !Ref "AWS::NoValue"], !If [Two, !Ref NATGateway2, !Ref "AWS::NoValue"], !If [HasAZ3 , !Ref NATGateway3, !Ref "AWS::NoValue"]]]
553
+ Value: !Join [",", [!If [One, !Ref NATGateway1, !Ref "AWS::NoValue"], !If [Two, !Ref NATGateway2, !Ref "AWS::NoValue"], !If [Three , !Ref NATGateway3, !Ref "AWS::NoValue"]]]
548
554
Export:
549
555
Name: !Sub "${Name}-NatGatewayId"
550
556
0 commit comments