You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Terraform OCI:如何正确为默认路由表配置route_rules规则?

解决OCI默认路由表Terraform配置中route_rules的参数错误问题

错误原因

oci_core_default_route_table资源里,route_rules是嵌套配置块,而非键值对形式的参数,所以不能用route_rules = [{...}]这种数组赋值的写法,必须以独立块的形式定义每条路由规则。

正确配置示例

修正后的完整配置代码如下:

# VCN Prod Default routing table
resource "oci_core_default_route_table" "default-rt-pub-vcn" {
  manage_default_resource_id = oci_core_vcn.vcn_prod.default_route_table_id

  # 第一条路由规则
  route_rules {
    # Required
    network_entity_id = oci_core_internet_gateway.vcn_prod_IG.id
    # Optional
    destination_type = "CIDR_BLOCK"
    destination = "0.0.0.0/0"
    description = "Default route to access Internet"
  }

  # 第二条路由规则
  route_rules {
    # Required
    network_entity_id = oci_core_local_peering_gateway.LPG_prod.id
    # Optional
    destination_type = "CIDR_BLOCK"
    destination = "192.168.100.0/24"
    description = "Route to hub VCN and hub public subnet"
  }
}

关键修改点

  • 移除了route_rules = [{...}]的赋值语法,改用独立的route_rules { ... }块定义每条路由
  • 修正了原代码中manage_default_resource_id行的换行问题(拆分两行会导致Terraform解析失败)

内容的提问来源于stack exchange,提问作者doubando

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 07:25:21