I started a new chapter in my life, and this world of IaC (Infrastructure as code) is really amazing...
I saw a free course in YouTube, how to start working with Terraform in AWS, but something along the way is not working properly, although the code seems the as in the videos, and mine.
here is the code, and the result. I'll be grateful for your assistance in understanding what is wrong.
Terraform details:
Terraform v0.14.10
provider registry.terraform.io/hashicorp/aws v3.36.0
The code:
3. Create Custom Route Table
resource "aws_route_table" "prod-route-table" {
vpc_id = aws_vpc.prod-vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.gw.id
}
route {
ipv6_cidr_block = "::/0"
egress_only_gateway_id = aws_internet_gateway.gw.id
}
tags = {
Name = "example"
}
}
4. Create a Subnet
resource "aws_subnet" "subnet_1" {
vpc_id = aws_vpc.prod-vpc.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-east-1e"
tags = {
"name" = "Prod-subnet"
}
}
5. Assosicate subent with Route Table
resource "aws_route_table_association" "a" {
subnet_id = aws_subnet.subnet_1.id
route_table_id = aws_route_table.prod-route-table.id
}
The error:
Error: error creating route: InvalidEgressOnlyInternetGatewayId.Malformed: Invalid id: "igw-07f6dac9f8bd89fd5" (expecting "eigw-...")
status code: 400, request id: 7f7e2445-f537-4113-a52e-ac6b32dee888
on main.tf line 26, in resource "aws_route_table" "prod-route-table":
26: resource "aws_route_table" "prod-route-table" {
I added only the part of the code that the error is pointing me too.