I am receiving this error:
Error waiting for NAT Gateway (nat-xxxxx) to become available: unexpected state ‘failed’, wanted target ‘available’. last error: %!s()
It seems this error was encountered by several others under this issue, but I didn’t see a resolution:
is there a known solution to this? Or, a way to get more information about this error, such as what is causing this unexpected state of failed?
posting code below incase it is just some obvious error on my part:
###Create NAT Gateway
#-------------------------------------------------------
#If RdsCreate is set to true, the NAT EIP will be created. All of the network infrastructure related to the RDS depends_on NATEIP.
resource “aws_eip” “NATEIP” {
provider = aws.region-main
count = var.RdsCreate ? 1 : 0
vpc = true
}
resource “aws_nat_gateway” “NAT” {
provider = aws.region-main
allocation_id = aws_eip.NATEIP[0].id
#public_ip = aws_eip.NATEIP[0].id
count = length(aws_subnet.RdsSubnets)
subnet_id = aws_subnet.RdsSubnets[count.index].id #aws_subnet.Public.id
#connectivity_type = “private”
depends_on = [aws_eip.NATEIP, aws_internet_gateway.IGW]
}
output “nat_gateway_ip” {
value = aws_eip.NATEIP[0].public_ip
}
#-------------------------------------------------------
###Create Private RDS Subnets and Route Table
#-------------------------------------------------------
resource “aws_subnet” “RdsSubnets” {
provider = aws.region-main
count = length(var.RdsSubnets)
vpc_id = aws_vpc.VPC.id
cidr_block = var.RdsSubnets[count.index]
availability_zone = data.aws_availability_zones.AZs.names[count.index]
map_public_ip_on_launch = false
depends_on = [aws_eip.NATEIP]
tags = {
Name = "RdsPrivateSubnet${1+count.index}"
}
}
resource “aws_route_table” “Private” {
provider = aws.region-main
vpc_id = aws_vpc.VPC.id
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = "aws_nat_gateway.NAT[0].id"
}
depends_on = [aws_eip.NATEIP]
}
resource “aws_route_table_association” “Private” {
provider = aws.region-main
count = length(aws_subnet.RdsSubnets)
subnet_id = aws_subnet.RdsSubnets[count.index].id
route_table_id = aws_route_table.Private.id
depends_on = [aws_eip.NATEIP]
}
thank you in advance!!