Terraform OCI - 在多个区域创建多个 VCN [英] Terraform OCI - create multiple VCN in multiple regions

查看:50
本文介绍了Terraform OCI - 在多个区域创建多个 VCN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在两个或更多区域内创建 2 个 VCN 和其他资源.

我在这个

您必须使用 provider = oci.region1 创建 2 个 oci_core_vcn 资源块,然后使用 provider = oci.root

I would like to create 2 VCN and other resources inside two or more regions.

I upload my code inside this github account

When i execute the code (you have to set the tenancy, user, fingerprint, etc) i don't have errors, but:

  1. When I go to the root region, all is created (compartment and VCN)
  2. when I go to the second region, the VCN is not created

terraform version: v1.0.2

my VCN module has:

terraform {
  required_providers {
    oci = {
      source = "hashicorp/oci"
      version = ">= 1.0.2"
      configuration_aliases = [
        oci.root,
        oci.region1
      ]
    }
  }
}

And when i call the VCN module I pass:

module "vcn" {
  source            = "./modules/vcn"
  
  providers = {
    oci.root = oci.home
    oci.region1 = oci.region1
  }
...
...

And my providers are:

provider "oci" {
  alias             = "home"
  tenancy_ocid      = local.json_data.TERRAFORM_work.tenancy_ocid
  user_ocid         = local.json_data.TERRAFORM_work.user_ocid
  private_key_path  = local.json_data.TERRAFORM_work.private_key_path
  fingerprint       = local.json_data.TERRAFORM_work.fingerprint
  region            = local.json_data.TERRAFORM_work.region
}

provider "oci" {
  alias             = "region1"
  region            = var.region1
  tenancy_ocid      = local.json_data.TERRAFORM_work.tenancy_ocid
  user_ocid         = local.json_data.TERRAFORM_work.user_ocid
  private_key_path  = local.json_data.TERRAFORM_work.private_key_path
  fingerprint       = local.json_data.TERRAFORM_work.fingerprint
}

What should i change, to create this VCN inside the two regions or more, at the same time?

using the terraform plan and apply

Thanks so much

解决方案

In the docs

You will have to create 2 oci_core_vcn resource blocks once with provider = oci.region1 to and once with provider = oci.root

这篇关于Terraform OCI - 在多个区域创建多个 VCN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆