feat(oci): define separate distinct provider instances

This commit is contained in:
Kat Inskip 2024-06-08 17:49:11 -07:00
parent 1e79f4f23c
commit 571fa04dba
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
7 changed files with 55 additions and 65 deletions

View file

@ -1,3 +1,15 @@
/*
# https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformgettingstarted.htm
# https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformproviderconfiguration.htm
provider "oci" {
alias = "oci_compartment"
private_key = module.oci_compartment_bootstrap.child_compartment_key_value
region = var.oci_compartment_bootstrap_region
tenancy_ocid = module.oci_compartment_bootstrap.child_compartment_id
user_ocid = module.oci_compartment_bootstrap.child_user_id
fingerprint = module.oci_compartment_bootstrap.child_compartment_key_fingerprint
}
module "oci_common_private_network" {
source = "./oci_common_private_network"
@ -7,9 +19,13 @@ module "oci_common_private_network" {
display_name = "CoreNetwork"
dns_label = "core"
private_key = module.oci_compartment_bootstrap.child_compartment_key_value
region = var.oci_compartment_bootstrap_region
tenancy_ocid = module.oci_compartment_bootstrap.child_compartment_id
user_ocid = module.oci_compartment_bootstrap.child_user_id
fingerprint = module.oci_compartment_bootstrap.child_compartment_key_fingerprint
}
providers = {
oci = oci.oci_compartment
}
depends_on = [
module.oci_compartment_bootstrap
]
}*/

View file

@ -1,28 +0,0 @@
variable "tenancy_ocid" {
type = string
}
variable "user_ocid" {
type = string
}
variable "private_key" {
type = string
}
variable "region" {
type = string
}
variable "fingerprint" {
type = string
}
# https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformgettingstarted.htm
provider "oci" {
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
private_key = var.private_key
region = var.region
fingerprint = var.fingerprint
}

View file

@ -1,3 +1,7 @@
variable "tenancy_ocid" {
type = string
}
variable "cidr_blocks" {
type = list(string)
}

View file

@ -20,10 +20,10 @@ variable "oci_compartment_bootstrap_fingerprint" {
type = string
}
# OCI Compartment Bootstrap
module "oci_compartment_bootstrap" {
source = "./oci_compartment_bootstrap"
# https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformgettingstarted.htm
# https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformproviderconfiguration.htm
provider "oci" {
alias = "oci_root"
private_key = var.oci_compartment_bootstrap_private_key
region = var.oci_compartment_bootstrap_region
tenancy_ocid = var.oci_compartment_bootstrap_tenancy_ocid
@ -31,6 +31,17 @@ module "oci_compartment_bootstrap" {
fingerprint = var.oci_compartment_bootstrap_fingerprint
}
# OCI Compartment Bootstrap
module "oci_compartment_bootstrap" {
source = "./oci_compartment_bootstrap"
tenancy_ocid = var.oci_compartment_bootstrap_tenancy_ocid
providers = {
oci = oci.oci_root
}
}
output "oci_compartment_bootstrap_child_user_id" {
value = module.oci_compartment_bootstrap.child_user_id
}

View file

@ -1,3 +1,7 @@
variable "tenancy_ocid" {
type = string
}
resource "oci_identity_compartment" "this" {
# Compartment ID is Tenancy ID for this case
compartment_id = var.tenancy_ocid

View file

@ -1,28 +0,0 @@
variable "tenancy_ocid" {
type = string
}
variable "user_ocid" {
type = string
}
variable "private_key" {
type = string
}
variable "region" {
type = string
}
variable "fingerprint" {
type = string
}
# https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformgettingstarted.htm
provider "oci" {
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
private_key = var.private_key
region = var.region
fingerprint = var.fingerprint
}

View file

@ -1,5 +1,16 @@
terraform {
required_providers {
# Vendor: Hashicorp
tls = {
source = "hashicorp/tls"
version = "4.0.5"
}
# Vendor: Oracle
oci = {
source = "oracle/oci"
version = "5.45.0"
configuration_aliases = [ oci.oci_root, oci.oci_compartment ]
}
hcloud = {
source = "hetznercloud/hcloud"
version = "1.38.2"