oci_identity_compartment

This resource provides the Compartment resource in Oracle Cloud Infrastructure Identity service.

Creates a new compartment in the specified compartment.

Important: Unless enable_delete is explicitly set to true: * Terraform will not delete compartments on destroy, and * For backwards compatibility, an existing compartment (not including root compartment) with the same name will be automatically imported into the state. Properties of the existing compartment will be updated to what is defined in the new configuration. This can cause a problem if multiple Terraform configurations are using the same compartment, but, for example, specify a different compartment description.

Specify the parent compartment’s OCID as the compartment ID in the request object. Remember that the tenancy is simply the root compartment. For information about OCIDs, see Resource Identifiers.

You must also specify a name for the compartment, which must be unique across all compartments in your tenancy. You can use this name or the OCID when writing policies that apply to the compartment. For more information about policies, see How Policies Work.

You must also specify a description for the compartment (although it can be an empty string). It does not have to be unique, and you can change it anytime with UpdateCompartment.

Example Usage

resource "oci_identity_compartment" "test_compartment" {
	#Required
	compartment_id = var.compartment_id
	description = var.compartment_description
	name = var.compartment_name

	#Optional
	defined_tags = {"Operations.CostCenter"= "42"}
	freeform_tags = {"Department"= "Finance"}
}

Argument Reference

The following arguments are supported:

** IMPORTANT ** Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values

Attributes Reference

The following attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Compartment * update - (Defaults to 20 minutes), when updating the Compartment * delete - (Defaults to 90 minutes), when destroying the Compartment

Import

Compartments can be imported using the id, e.g.

$ terraform import oci_identity_compartment.test_compartment "id"