【问题标题】:How to terraform import the AWS default route table of a VPC?如何terraform导入VPC的AWS默认路由表?
【发布时间】:2020-08-31 16:06:52
【问题描述】:

此处的文档:https://www.terraform.io/docs/providers/aws/r/default_route_table.html 声称您可以使用 VPC id 导入默认路由表。

当我尝试这样做时,我收到以下错误:

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

Error: resource aws_default_route_table doesn't support import

我尝试使用路由表 ID 本身,以防文档不准确,但我得到了同样的错误。

我成功导入了路由表所属的VPC,再次尝试导入路由表无济于事。

对于上下文 - 我需要导入默认路由表的原因是为 VPN 网关启用路由传播,如下所示:

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
  ]
}

是我遗漏了什么,还是真的不可能将现有的默认路由表导入 terraform?

【问题讨论】:

    标签: terraform terraform-provider-aws


    【解决方案1】:

    我跳到导入部分的速度太快了。在同一文档的开头https://www.terraform.io/docs/providers/aws/r/default_route_table.html 有这样的子句:

    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.
    

    所以,TL;DR 你不能导入,但你可以尝试创建一个现有的路由表,terraform 将“采用”它,效果将与导入现有资源相同。

    【讨论】:

    • 如果没有创建VPC,如何创建路由表?
    【解决方案2】:

    我认为您的导入看起来不错。您可能需要使用 terraform-aws-provider 提出错误报告。 https://github.com/terraform-providers/terraform-provider-aws

    【讨论】:

      猜你喜欢
      • 2019-01-21
      • 2014-04-09
      • 2019-07-21
      • 2021-06-16
      • 2019-06-10
      • 2020-09-06
      • 1970-01-01
      • 2022-12-13
      • 1970-01-01
      相关资源
      最近更新 更多