تكوين وحدة المقارنة

حدد كل قسم كمورد ، وقم بتعريف المتغيرات المطلوبة.

أكمل الخطوات التالية في الدليل الفرعي compartments:
  1. قم بتكوين ملف نصي باسم variables.tf وألصق التعليمات البرمجية التالية في الملف.
    يعلن هذا الرمز المتغيرات المستخدمة في هذه الوحدة
    variable "tenancy_ocid" {}
    variable "app_tag" {}
    variable "environment" {}
  2. قم بتكوين ملف نصي باسم compartments.tf وألصق التعليمات البرمجية التالية في الملف.
    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. قم بتكوين ملف نصي باسم compartments_output.tf وألصق التعليمات البرمجية التالية في الملف.
    يؤدي هذا الرمز إلى عرض معرفات الأقسام بعد تكوينها.
    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}"
    }