@@ -11,7 +11,7 @@ export interface TestbedProps extends cdk.StackProps {
11
11
}
12
12
13
13
export class Testbed extends cdk . Stack {
14
- constructor ( scope : cdk . Construct , id : string = "testbed" , props : TestbedProps ) {
14
+ constructor ( scope : cdk . Construct , id : string = "testbed" , props : TestbedProps ) {
15
15
super ( scope , id , props )
16
16
17
17
const vpc = new ec2 . Vpc ( this , id , {
@@ -30,6 +30,15 @@ export class Testbed extends cdk.Stack {
30
30
} ,
31
31
] ,
32
32
} ) ;
33
+
34
+ //Tag pub subnets for KIT CP
35
+ const selection = vpc . selectSubnets ( {
36
+ subnetType : ec2 . SubnetType . PUBLIC
37
+ } ) ;
38
+ selection . subnets . forEach ( subnet => {
39
+ Tags . of ( subnet ) . add ( 'kit/hostcluster' , `${ id } -controlplane` )
40
+ } )
41
+
33
42
//ToDo: revisit once this is resolved - https://github.com/aws/aws-cdk/issues/5927
34
43
// index<=8 will give us 9 /16 cidrs additionally to make a mega VPC.
35
44
for ( let index = 0 ; index <= 8 ; index ++ ) {
@@ -38,26 +47,37 @@ export class Testbed extends cdk.Stack {
38
47
cidrBlock : `10.${ index + 1 } .0.0/16`
39
48
} ) ;
40
49
let privateSubnet = new ec2 . PrivateSubnet ( this , `${ id } -private-subnet-${ index } ` , {
41
- availabilityZone : cdk . Stack . of ( this ) . availabilityZones [ index % cdk . Stack . of ( this ) . availabilityZones . length ] ,
50
+ availabilityZone : cdk . Stack . of ( this ) . availabilityZones [ index % cdk . Stack . of ( this ) . availabilityZones . length ] ,
42
51
vpcId : vpc . vpcId ,
43
52
cidrBlock : `10.${ index + 1 } .0.0/16`
44
53
} )
45
54
privateSubnet . node . addDependency ( additionalCidr ) ;
55
+ //Tag pub subnets for KIT DP
56
+ Tags . of ( privateSubnet ) . add ( 'kit/hostcluster' , `${ id } -dataplane` )
57
+ let natSubnet = new ec2 . PublicSubnet ( this , `${ id } -nat-subnet-${ index } ` , {
58
+ availabilityZone : cdk . Stack . of ( this ) . availabilityZones [ index % cdk . Stack . of ( this ) . availabilityZones . length ] ,
59
+ vpcId : vpc . vpcId ,
60
+ cidrBlock : `10.0.64.${ index * 16 } /28`
61
+ } )
62
+ //add igw route for nat subnets
63
+ let routeTableId = natSubnet . routeTable . routeTableId
64
+ new ec2 . CfnRoute ( this , 'publicIGWRoute' + index , {
65
+ routeTableId,
66
+ gatewayId : vpc . internetGatewayId ,
67
+ destinationCidrBlock : "0.0.0.0/0"
68
+ } )
46
69
47
70
ec2 . NatProvider . gateway ( ) . configureNat ( {
48
71
natSubnets : [
49
- new ec2 . PublicSubnet ( this , `${ id } -nat-subnet-${ index } ` , {
50
- availabilityZone : cdk . Stack . of ( this ) . availabilityZones [ index % cdk . Stack . of ( this ) . availabilityZones . length ] ,
51
- vpcId : vpc . vpcId ,
52
- cidrBlock : `10.0.64.${ index * 16 } /28`
53
- } )
72
+ natSubnet
54
73
] ,
55
74
privateSubnets : [
56
75
privateSubnet
57
76
] ,
58
77
vpc : vpc
59
78
} )
60
79
}
80
+
61
81
const cluster = new eks . Cluster ( this , 'cluster' , {
62
82
clusterName : id ,
63
83
vpc : vpc ,
@@ -87,7 +107,6 @@ export class Testbed extends cdk.Stack {
87
107
]
88
108
} ) ,
89
109
} )
90
-
91
110
// service account used by tekton workflows.
92
111
cluster . addServiceAccount ( 'test-executor' , { name : 'test-executor' } )
93
112
. role . addManagedPolicy ( { managedPolicyArn : 'arn:aws:iam::aws:policy/AdministratorAccess' } )
0 commit comments