0
votes

The documentation here: https://www.terraform.io/docs/providers/aws/r/default_route_table.html claims that you can import the default route table using the VPC id.

When I try to do that I get the following error:

$ terraform import 'aws_default_route_table.aws-vpc' vpc-12345678

Error: resource aws_default_route_table doesn't support import

I tried to use the route table ID itself, just in case the documentation is inaccurate, but I get the same error.

I imported successfully the VPC the route table belongs to and tried again to import the route table to no avail.

For context - the reason I need to import the default route table is to enable route propagation for VPN gateway as in:

resource aws_default_route_table aws-vpc {
  default_route_table_id = var.aws_default_route_table_id
  route {
    cidr_block = "0.0.0.0/0"
    gateway_id = var.aws_internet_gateway_id
  }
  propagating_vgws = [
    aws_vpn_gateway.aws-vpn-gw.id
  ]
}

Am I missing something, or is it really impossible to import an existing default route table into terraform?

2

2 Answers

3
votes

I skipped too fast to the import section. At the beginning of the same document https://www.terraform.io/docs/providers/aws/r/default_route_table.html there is this clause:

The aws_default_route_table behaves differently from normal resources, in that Terraform does not create this resource, but instead attempts to "adopt" it into management. We can do this because each VPC created has a Default Route Table that cannot be destroyed, and is created with a single route.

So, TL;DR you can't import, but you can attempt to create an existing route table, terraform will "adopt" it and the effect will be the same as importing an existing resource.

2
votes

I think your import looks fine. You might need to raise a bug report with terraform-aws-provider. https://github.com/terraform-providers/terraform-provider-aws