@@ -167,7 +167,7 @@ func (i *AWSInfrastructure) AllocateAddress() AWSInfrastructure {
167
167
168
168
t := 0
169
169
addr , _ := GetAddress (i .Context , * aa .AllocationId )
170
- for addr == nil || t < 180 {
170
+ for addr == nil && t < 180 {
171
171
time .Sleep (1 * time .Second )
172
172
addr , _ = GetAddress (i .Context , * aa .AllocationId )
173
173
t ++
@@ -177,10 +177,19 @@ func (i *AWSInfrastructure) AllocateAddress() AWSInfrastructure {
177
177
}
178
178
179
179
func (i * AWSInfrastructure ) CreateNatGateway (ct string ) AWSInfrastructure {
180
+ t := 0
180
181
s , serr := GetSubnetByName (i .Context , i .Spec .ClusterName + "-subnet-" + ct )
181
182
if serr != nil {
182
183
return * i
183
184
}
185
+ for s == nil && t < 180 {
186
+ time .Sleep (1 * time .Second )
187
+ s , _ = GetSubnetByName (i .Context , i .Spec .ClusterName + "-subnet-" + ct )
188
+ t ++
189
+ }
190
+ if s == nil {
191
+ return * i
192
+ }
184
193
ngwC , ngwce := CreateNatGateway (i .Context , i .Spec .ClusterName + "-nat" , ct , * i .ElasticIP .AllocationId , * s .SubnetId )
185
194
if ngwce != nil {
186
195
return * i
@@ -229,27 +238,45 @@ func (i *AWSInfrastructure) GetRouteTable(rtID string) AWSInfrastructure {
229
238
// routes to their respective gateway.
230
239
func (i * AWSInfrastructure ) CreateInfrastructure () AWSInfrastructure {
231
240
i .CreateVPC ()
241
+ Byf ("Created VPC - %s" , * i .VPC .VpcId )
232
242
if i .VPC != nil {
233
243
i .CreatePublicSubnet ()
244
+ if i .State .PublicSubnetID != nil {
245
+ Byf ("Created Public Subnet - %s" , * i .State .PublicSubnetID )
246
+ }
234
247
i .CreatePrivateSubnet ()
248
+ if i .State .PrivateSubnetID != nil {
249
+ Byf ("Created Private Subnet - %s" , * i .State .PrivateSubnetID )
250
+ }
235
251
for t := 0 ; t < 30 ; t ++ {
236
252
if * i .RefreshVPCState ().State .VpcState == "available" {
237
253
break
238
254
}
239
255
time .Sleep (1 * time .Second )
240
256
}
241
257
i .CreateInternetGateway ()
258
+ if i .InternetGateway != nil {
259
+ Byf ("Created Internet Gateway - %s" , * i .InternetGateway .InternetGatewayId )
260
+ }
242
261
}
243
262
i .AllocateAddress ()
244
263
if i .ElasticIP != nil && i .ElasticIP .AllocationId != nil {
264
+ Byf ("Created Elastic IP - %s" , * i .ElasticIP .AllocationId )
245
265
i .CreateNatGateway ("public" )
246
266
if i .NatGateway != nil && i .NatGateway .NatGatewayId != nil {
247
267
WaitForNatGatewayState (i .Context , * i .NatGateway .NatGatewayId , 180 , "available" )
268
+ Byf ("Created NAT Gateway - %s" , * i .NatGateway .NatGatewayId )
248
269
}
249
270
}
250
271
if len (i .Subnets ) == 2 {
251
272
i .CreateRouteTable ("public" )
273
+ if i .State .PublicRouteTableID != nil {
274
+ Byf ("Created public route table - %s" , * i .State .PublicRouteTableID )
275
+ }
252
276
i .CreateRouteTable ("private" )
277
+ if i .State .PrivateRouteTableID != nil {
278
+ Byf ("Created private route table - %s" , * i .State .PrivateRouteTableID )
279
+ }
253
280
if i .InternetGateway != nil && i .InternetGateway .InternetGatewayId != nil {
254
281
CreateRoute (i .Context , * i .State .PublicRouteTableID , "0.0.0.0/0" , nil , i .InternetGateway .InternetGatewayId , nil )
255
282
}
0 commit comments