Crea il modulo Compartimenti

Definire ciascun compartimento come risorsa e dichiarare le variabili necessarie.

Completare la procedura riportata di seguito nella sottodirectory compartments.
  1. Creare un file di testo denominato variables.tf e incollare il seguente codice nel file.
    Questo codice dichiara le variabili utilizzate nel modulo.
    variable "tenancy_ocid" {}
    variable "app_tag" {}
    variable "environment" {}
  2. Creare un file di testo denominato compartments.tf e incollare il seguente codice nel file.
    resource "oci_identity_compartment" "networks" {
      description = "The networks compartment"
      name        = "${var.app_tag}_${var.environment}_networks"
    }
    
    resource "oci_identity_compartment" "admin" {
      description = "The admin compartment"
      name        = "${var.app_tag}_${var.environment}_admin"
    }
    
    resource "oci_identity_compartment" "shared_services" {
      description = "The shared_services compartment"
      name        = "${var.app_tag}_${var.environment}_shared_services"
    }
    
    resource "oci_identity_compartment" "business_logic" {
      description = "The business_logic compartment"
      name        = "${var.app_tag}_${var.environment}_business_logic"
    }
    
    resource "oci_identity_compartment" "database" {
      description = "The database compartment"
      name        = "${var.app_tag}_${var.environment}_database"
    }
    
  3. Creare un file di testo denominato compartments_output.tf e incollare il seguente codice nel file.
    Questo codice causa la visualizzazione degli ID dei compartimenti dopo la creazione.
    output "networks_id" {
      value = "${oci_identity_compartment.networks.id}"
    }
    
    output "admin_id" {
      value = "${oci_identity_compartment.admin.id}"
    }
    
    output "shared_services_id" {
      value = "${oci_identity_compartment.shared_services.id}"
    }
    
    output "business_logic_id" {
      value = "${oci_identity_compartment.business_logic.id}"
    }
    
    output "database_id" {
      value = "${oci_identity_compartment.database.id}"
    }