【问题标题】:Inappropriate value for attribute "route": element 0: attributes属性“路由”的值不合适:元素 0:属性
【发布时间】:2021-12-09 19:54:04
【问题描述】:

属性“路由”的值不合适:元素 0:属性“carrier_gateway_id”、“cidr_block”、“destination_prefix_list_id”、“gateway_id”、 │ “instance_id”、“local_gateway_id”、“nat_gateway_id”、“network_interface_id”、“transit_gateway_id”、“vpc_endpoint_id”和“vpc_peering_connection_id”是 │ 必填。

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
  tags = {
    Name = "main"
  }
}

resource "aws_subnet" "public-subnet-1" {
  vpc_id     = aws_vpc.main.id
  cidr_block = "10.0.1.0/24"

  tags = {
    Name = "public-main-1"
  }
}

resource "aws_subnet" "public-subnet-2" {
  vpc_id     = aws_vpc.main.id
  cidr_block = "10.0.3.0/24"

  tags = {
    Name = "public-main-2"
  }
}

resource "aws_internet_gateway" "gw" {
  vpc_id = aws_vpc.main.id

  tags = {
    Name = "gw"
  }
}

resource "aws_route_table" "rt" {
  vpc_id = aws_vpc.main.id

  route = [
    {
      cidr_block = "10.0.1.0/24"
      gateway_id = aws_internet_gateway.gw.id
    }
  ]

  tags = {
    Name = "rt"
  }
}

【问题讨论】:

标签: terraform amazon-vpc


【解决方案1】:

添加所有可选参数以减少错误。 这里所有的空块/参数都是可选的,但我们必须提供所有这些以避免错误。

resource "aws_route_table" "rt" {
  vpc_id = aws_vpc.main.id

  route = [
    {
      cidr_block = "0.0.0.0/0"
      gateway_id = aws_internet_gateway.gw.id
      carrier_gateway_id         = ""
      destination_prefix_list_id = ""
      egress_only_gateway_id     = ""
      instance_id                = ""
      ipv6_cidr_block            = ""
      local_gateway_id           = ""
      nat_gateway_id             = ""
      network_interface_id       = ""
      transit_gateway_id         = ""
      vpc_endpoint_id            = ""
      vpc_peering_connection_id  = ""
    }
  ]

  tags = {
    Name = "rt"
  }
}

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2021-03-26
  • 2021-12-14
  • 1970-01-01
  • 2020-04-09
  • 2021-07-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多