Data Source: oci_identity_compartments

This data source provides the list of Compartments in Oracle Cloud Infrastructure Identity service.

Lists the compartments in a specified compartment. The members of the list returned depends on the values set for several parameters.

With the exception of the tenancy (root compartment), the ListCompartments operation returns only the first-level child compartments in the parent compartment specified in compartmentId. The list does not include any subcompartments of the child compartments (grandchildren).

The parameter accessLevel specifies whether to return only those compartments for which the requestor has INSPECT permissions on at least one resource directly or indirectly (the resource can be in a subcompartment).

The parameter compartmentIdInSubtree applies only when you perform ListCompartments on the tenancy (root compartment). When set to true, the entire hierarchy of compartments can be returned. To get a full list of all compartments and subcompartments in the tenancy (root compartment), set the parameter compartmentIdInSubtree to true and accessLevel to ANY.

See Where to Get the Tenancy’s OCID and User’s OCID.

Example Usage

data "oci_identity_compartments" "test_compartments" {
	#Required
	compartment_id = var.compartment_id

	#Optional
	access_level = var.compartment_access_level
	compartment_id_in_subtree = var.compartment_compartment_id_in_subtree
	name = var.compartment_name
	state = var.compartment_state
}

Argument Reference

The following arguments are supported:

Attributes Reference

The following attributes are exported:

Compartment Reference

The following attributes are exported: