Terraform OCI - 在多个区域创建多个 VCN

Terraform OCI - create multiple VCN in multiple regions(Terraform OCI - 在多个区域创建多个 VCN)
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)