Moving an API Deployment Between Compartments

Find out how to move API deployments between compartments with the API Gateway service.

Having deployed an API on an API gateway by creating an API deployment, you might decide to move the API deployment from one compartment to another. An API gateway and the individual API deployments deployed on it can be in different compartments.

Note that calls to an API deployment will be disrupted while the API deployment is being moved to a different compartment. Do not call the API deployment until the move operation is complete.

  • To move an API deployment to a different compartment using the Console:

    1. On the Gateways list page, select the API gateway containing the API deployment that you want to move. If you need help finding the list page or the API gateway, see Listing API Gateways.
    2. Under Resources, select Deployments.

      The Deployments list page opens. All API deployments in the selected API gateway are displayed in a table.

    3. From the Actions menu (Actions Menu) for the API deployment, select Move Resource, select the compartment to which you want to move the API deployment, and select Move Resource to start the process of moving the API deployment.

      Do not call an API deployment while the API deployment is in the process of being moved to the new compartment.

    4. On the Gateway Details page, select Work Requests from the Resources list and confirm the move operation is complete.

      When the move operation is complete, resume calls to the API deployment.

  • To move API deployments to a different compartment using the CLI:

    1. Configure your client environment to use the CLI (Configuring Your Client Environment to use the CLI for API Gateway Development).
    2. To move an API deployment to a different compartment:

      1. Open a command prompt and run oci api-gateway deployment change-compartment to move the API deployment:

        oci api-gateway deployment change-compartment --deployment-id <deployment-ocid> --compartment-id <compartment-ocid>

        where:

        • <deployment-ocid> is the OCID of the API deployment to move. To find out the API deployment's OCID, see Listing API Gateways.
        • <compartment-ocid> is the OCID of the compartment to which to move the API deployment.

        For example:

        oci api-gateway deployment change-compartment --deployment-id ocid1.apideployment.oc1..aaaaaaaaab______pwa --compartment-id ocid1.compartment.oc1..aaaaaaaa7______ysq

        The response to the command includes:

        • The lifecycle state (for example, ACTIVE, FAILED).
        • The id of the work request to move the API deployment (details of work requests are available for seven days after completion, cancellation, or failure).

        If you want the command to wait to return control until the API deployment is active (or the request has failed), include either or both the following parameters:

        • --wait-for-state ACTIVE
        • --wait-for-state FAILED

        For example:

        oci api-gateway deployment change-compartment --deployment-id ocid1.apideployment.oc1..aaaaaaaaab______pwa --compartment-id ocid1.compartment.oc1..aaaaaaaa7______ysq --wait-for-state ACTIVE
      2. (Optional) To see the status of the work request that is moving the API deployment, enter:

        oci api-gateway work-request get --work-request-id <work-request-ocid>
      3. (Optional) To view the logs of the work request that is moving the API deployment, enter:

        oci api-gateway work-request-log list --work-request-id <work-request-ocid>
      4. (Optional) If the work request that is moving the API deployment fails and you want to review the error logs, enter:

        oci api-gateway work-request-error --work-request-id <work-request-ocid>
      5. (Optional)  To verify that the API deployment has been moved, enter the following command and confirm that the API deployment's new compartment OCID is as you expect:

        oci api-gateway deployment get --deployment-id <deployment-ocid>

    For more information about using the CLI, see Command Line Interface (CLI). For a complete list of flags and options available for CLI commands, see CLI Help.

  • Run the ChangeDeploymentCompartment operation to move an API deployment to a different compartment.