Moving an API Gateway or an API Deployment Between Compartments

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

Having created an API gateway, and deployed an API on the API gateway by creating an API deployment, you might decide to move either or both 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 (or the API gateway on which it is deployed) is being moved to a different compartment. Do not call the API deployment until the move operation is complete.

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

    1. In the Console, open the navigation menu and click Developer Services. Under API Management, click Gateways.
    2. Choose a Compartment you have permission to work in.
    3. On the Gateways page, click the name of the API gateway that you want to move (or that contains the API deployment you want to move) to show the Gateway Details page.
    4. On the Gateway Details page:

      • To move the API gateway, click Move Resource, select the compartment to which you want to move the API gateway, and click Move Resource to start the process of moving the API gateway. Note that API deployments on the API gateway are not moved to the new compartment.
      • To move an API deployment, select Deployments from the Resources list, click Move Resource, select the compartment to which you want to move the API deployment, and click Move Resource to start the process of moving the API deployment.

      Do not call an API deployment while the API deployment (or the API gateway on which it is deployed) is in the process of being moved to the new compartment.

    5. 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 gateways and 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 gateway to a different compartment:

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

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

        where:

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

        For example:

        oci api-gateway gateway change-compartment --gateway-id ocid1.apigateway.oc1..aaaaaaaab______hga --compartment-id ocid1.compartment.oc1..aaaaaaaa7______ysq

        Note that API deployments on the API gateway are not moved.

        The response to the command includes:

        • The lifecycle state (for example, ACTIVE, FAILED).
        • The id of the work request to move the API gateway (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 gateway 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 gateway change-compartment --gateway-id ocid1.apigateway.oc1..aaaaaaaab______hga --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 gateway, 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 gateway, 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 gateway 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 gateway has been moved, enter the following command and confirm that the API gateway's new compartment OCID is as you expect:

        oci api-gateway gateway get --gateway-id <gateway-ocid>
    3. 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 and API Deployments.
        • <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: