【问题标题】:Terraform add Route Rule to an existing route table - Oracle OCI providerTerraform 将路由规则添加到现有路由表 - Oracle OCI 提供程序
【发布时间】:2021-03-12 04:51:32
【问题描述】:

我想在不同 VCN 中的现有路由表中添加新路由规则,并且该路由表已由其他团队创建。

如果我添加任何新的路由规则,它会被所有其他现有的路由规则覆盖。我可以从数据源获取路由规则。现在,如何通过循环使用从数据源获取的规则来添加新规则。

      "route_rules" = [
        {
          "cidr_block" = ""
          "description" = ""
          "destination" = "0.0.0.0/0"
          "destination_type" = "CIDR_BLOCK"
          "network_entity_id" = "ocid1.internetgateway.oc1.phx.aaaaaaaa66a5u6h63c2vx4x4era"
        },
        {
          "cidr_block" = ""
          "description" = ""
          "destination" = "192.164.0.0/16"
          "destination_type" = "CIDR_BLOCK"
          "network_entity_id" = "ocid1.localpeeringgateway.oc1.phx.aaaaaxd6ffzyac74pwtzmadaycd344ua"
        },
        {
          "cidr_block" = ""
          "description" = ""
          "destination" = "193.168.0.0/16"
          "destination_type" = "CIDR_BLOCK"
          "network_entity_id" = "ocid1.localpeeringgateway.oc1.phx.aaaaaaavpjfi2cd7bnum3xcfdrylfnpa"
        },
        {
          "cidr_block" = ""
          "description" = ""
          "destination" = "192.168.0.0/16"
          "destination_type" = "CIDR_BLOCK"
          "network_entity_id" = "ocid1.localpeeringgateway.oc1.phx.aaaaaaotebnjfi2cd7bnum3xcfdrylfnpa"
        },
      ]

如何在上述规则的同时添加新规则?

Datasource,

data "oci_core_route_tables" "test_route_tables" {
    compartment_id = "ocid1.compartment.oc1..aaaaaap6foynzstr3qoqsgwt6gwfq"
    vcn_id = "ocid1.vcn.oc1.phx.amaaaaaawbmpx5iab6gjrszm7sybnn5n6zcs45f66q"
}


output "route" {

  value = data.oci_core_route_tables.test_route_tables
}

New rule to be added,

"CIDR block"= "192.176.0.0/16"
"destination_type" = "CIDR_BLOCK"
"network_entity_id" =  "ocid.ddd.oft"

【问题讨论】:

    标签: terraform oracle-cloud-infrastructure


    【解决方案1】:

    您应该能够import 现有路由规则进入您的 terraform 状态,然后在配置中将其与新路由规则相应地匹配并应用更改。 https://registry.terraform.io/providers/hashicorp/oci/latest/docs/resources/core_route_table#import

    更多关于导入的信息可以在这里找到 - https://www.terraform.io/docs/import/index.html

    【讨论】:

    • 不,实际上我想通过映射数据源值来动态添加新规则。
    猜你喜欢
    • 2021-12-06
    • 2017-10-02
    • 1970-01-01
    • 2017-04-28
    • 1970-01-01
    • 2019-01-21
    • 1970-01-01
    • 1970-01-01
    • 2021-10-30
    相关资源
    最近更新 更多