Share the content

Same provider different configurations

An common use case scenario deploy similar resources using distinct placements for some Cloud Providers can be translated in distinct regions, resources, local isolations.

As an consequence an very common technique to avoid single point of failures, with this on mind…

The meta-argument alias can be used to create an second configuration block for the same provider. Resulting:

The first provider, without the alias will be the default provider configuration.

The second provider block with the alias will be that will have the distinct configuration will be the alternate.

 

Default Provider

provider “oci” {
  tenancy_ocid     = var.tenancy_ocid
  user_ocid        = var.user_ocid
  fingerprint      = var.fingerprint
  private_key_path = var.private_key_path
  region           = var.region
}

Custom Provider Configuration

provider “oci” {
  alias = “home”
  tenancy_ocid     = var.tenancy_ocid
  user_ocid        = var.user_ocid
  fingerprint      = var.fingerprint
  private_key_path = var.private_key_path
  region           = var.region_home
}

How to reference the resource

resource “oci_identity_policy” “policy_sample” {
    depends_on = [
        oci_identity_dynamic_group.grafana,
    ]
    provider = oci.home
    name = “Permit_metrics_read”
    description = “Permit Sample Group Read METRICS”
    compartment_id = var.tenancy_ocid
    statements = [
        “allow dynamicgroup ${var.sample_group} to read metrics in tenancy”,
    ]     
}

The block above has the meta-argument “oci.home” in this resource.

This sample on OCI can illustrate better this scenario because:

IAM resources need to be created at tenancy home region. The ability to subscribe to any region to deploy services to any region in some deployments can create an requirement to adjust global constructs that must be updated on tenancy home regions for example.

Terraform documentation reference


Share the content

By mike

...passionate technology professional with deep experience in with high volume deployments and mission critical workloads build the orientation on - how to achieve the objectives leveraging key technologies be transparent and most of all a ‘forever student,’. Major aspect here is do using simple never forget enjoy and have fun avoid... Cycling is my major sport, with that I've learned several aspects that can apply on daily bases.... Horse riding is also very nice I try do when I can.... The views expressed on this [blog; website] are my own and do not necessarily reflect the views of Oracle or any other Company that I've worked in past. Today I've help the following certifications: OCI Architect Associate OCI Architect Professional OCI Operations Associate OCI Fundamentals The views expressed on www.simplesample.com blog is my own and do not necessarily reflect the views of Oracle.

Leave a Reply

Your email address will not be published. Required fields are marked *