Add timeout to AllocateAddress
Change timeout on AllocateAddress
Add validation prior to CreateNatGateway
Increment timeout
@@ -164,9 +164,14 @@ func (i *AWSInfrastructure) AllocateAddress() AWSInfrastructure {
return *i
}
- if addr, _ := GetAddress(i.Context, *aa.AllocationId); addr != nil {
- i.ElasticIP = addr
+ t := 0
+ addr, _ := GetAddress(i.Context, *aa.AllocationId)
+ for addr == nil || t < 180 {
+ time.Sleep(1 * time.Second)
+ addr, _ = GetAddress(i.Context, *aa.AllocationId)
+ t++
}
+ i.ElasticIP = addr
return *i
}
@@ -235,10 +240,12 @@ func (i *AWSInfrastructure) CreateInfrastructure() AWSInfrastructure {
i.CreateInternetGateway()
}
i.AllocateAddress()
+ if i.ElasticIP != nil && i.ElasticIP.AllocationId != nil {
i.CreateNatGateway("public")
if i.NatGateway != nil && i.NatGateway.NatGatewayId != nil {
WaitForNatGatewayState(i.Context, *i.NatGateway.NatGatewayId, 180, "available")
}
+ }
if len(i.Subnets) == 2 {
i.CreateRouteTable("public")
i.CreateRouteTable("private")
