Creating a Compartment

Create compartments in an IAM tenancy to organize and isolate your cloud resources.

When creating a compartment, you must provide a name for it that's unique within its parent compartment, with a maximum 100 characters, including letters, numbers, periods, hyphens, and underscores. You must also provide a description, which is a nonunique, changeable description for the compartment, from 1 to 400 characters. Oracle also assigns the compartment a unique ID called an Oracle Cloud ID (OCID). For more information, see Resource Identifiers.

You can create subcompartments in compartments to create hierarchies up are six levels deep, as shown in the following Console image.

Figure showing compartment hierarchy six levels deep

    1. Open the navigation menu and click Identity & Security. Under Identity, click Compartments.
      A list of the compartments you have access to in the tenancy is displayed.
    2. Navigate to the compartment in which you want to create the compartment.
      • To create the compartment in the tenancy (root compartment) click Create Compartment.
      • Otherwise, click through the hierarchy of compartments until you reach the detail page of the compartment in which you want to create the compartment. Then, on the details page, click Create Compartment.
    3. Enter the following information:
      • Name: A unique name for the compartment with a maximum of 100 characters, including letters, numbers, periods, hyphens, and underscores). The name must be unique across all the compartments in the tenancy. Avoid entering confidential information.
      • Description: A friendly description. You can change this later.
      • Parent Compartment: The compartment that you're in is displayed. To choose another compartment to create this compartment in, select it from the list.
      • Tags: If you have permissions to create a resource, then you also have permissions to apply free-form tags to that resource. To apply a defined tag, you must have permissions to use the tag namespace. For more information about tagging, see Resource Tags. If you're not sure whether to apply tags, skip this option or ask an administrator. You can apply tags later. You can apply tags later.
    4. Click Create Compartment.
    You might also want to write a policy for the compartment. See Creating a Policy.
  • Use the create command and required parameters to create a compartment:

    oci iam compartment create [OPTIONS]

    For a complete list of parameters and values for CLI commands, see the CLI Command Reference.

  • Run the CreateCompartment operation to create a compartment.