Delete environments

This topic explains how to delete environments in Apigee hybrid. See also About environments and environment groups.

About environment deletion

Environment deletion is the reverse of environment creation and includes the following tasks:

  • Remove the environment's runtime components from your cluster and remove the environment from your overrides file.
  • Delete the environment from the management plane using either the Apigee UI or the Delete environments API.

How to delete an environment

Assume that you have two environments, test and prod. In your overrides file, the definitions might look something like this:

...
envs:
  - name: test
    serviceAccountPaths:
      synchronizer: "your_keypath/PROJECT_ID-apigee-synchronizer.json"
      runtime: "your_keypath/PROJECT_ID-apigee-runtime.json"
  - name: prod
    serviceAccountPaths:
      synchronizer: "your_keypath/PROJECT_ID-apigee-synchronizer.json"
      runtime: "your_keypath/PROJECT_ID-apigee-runtime.json"
...

To delete the prod environment, follow these steps:

  1. Get your gcloud authentication credentials:
    TOKEN=$(gcloud auth print-access-token)
  2. As a precaution, detach the environment from each environment group that it is attached to. This stops traffic from being routed to the environment before you remove its runtime components.
    1. List the attachments of the environment group and note the name (attachment ID) of the attachment whose environment is prod:

      No data residency

      curl -H "Authorization: Bearer $TOKEN" \
        "https://apigee.googleapis.com/v1/organizations/ORG_NAME/envgroups/ENV_GROUP/attachments"

      Data residency

      curl -H "Authorization: Bearer $TOKEN" \
        "https://CONTROL_PLANE_LOCATION-apigee.googleapis.com/v1/organizations/ORG_NAME/envgroups/ENV_GROUP/attachments"

      The output is similar to the following:

      {
        "environmentGroupAttachments": [
          {
            "name": "f6f2958f-a0a1-4260-b9e9-80eead82ff1d",
            "environment": "prod",
            "createdAt": "1789700385118",
            "environmentGroupId": "ENV_GROUP"
          }
        ]
      }
    2. Delete the attachment:

      No data residency

      curl -X DELETE -H "Authorization: Bearer $TOKEN" \
        "https://apigee.googleapis.com/v1/organizations/ORG_NAME/envgroups/ENV_GROUP/attachments/ATTACHMENT_ID"

      Data residency

      curl -X DELETE -H "Authorization: Bearer $TOKEN" \
        "https://CONTROL_PLANE_LOCATION-apigee.googleapis.com/v1/organizations/ORG_NAME/envgroups/ENV_GROUP/attachments/ATTACHMENT_ID"

    Where:

    • ORG_NAME is the name of your Apigee organization.
    • ENV_GROUP is the name of the environment group.
    • ATTACHMENT_ID is the attachment name returned in the previous step. This is a generated ID, not the environment name.
    • CONTROL_PLANE_LOCATION is the control plane location of your organization if you use data residency.

    Repeat these steps for each environment group that the environment is attached to.

  3. Do a dry run to test removal of the runtime components:
    helm delete ENV_RELEASE_NAME -n APIGEE_NAMESPACE --dry-run
    
    • ENV_RELEASE_NAME is the name with which you previously installed the apigee-env chart for this environment. This is often the same as the environment name. To list the release names in your namespace, run helm list -n APIGEE_NAMESPACE.
    • APIGEE_NAMESPACE is the namespace where you installed Apigee hybrid, apigee by default.

    The --dry-run option simulates the uninstall without removing anything, and its output is the same as the output of the actual uninstall. Unlike helm upgrade, helm delete doesn't accept a value for --dry-run such as --dry-run=server. For example:

    helm delete prod -n apigee --dry-run
    release "prod" uninstalled
  4. If the dry run is error-free, remove the runtime components:
    helm delete ENV_RELEASE_NAME -n APIGEE_NAMESPACE
    
  5. Open your overrides file and remove the prod environment definition from envs, leaving only the test definition. For example:
    ...
    envs:
      - name: test
        serviceAccountPaths:
          synchronizer: "your_keypath/PROJECT_ID-apigee-synchronizer.json"
          runtime: "your_keypath/PROJECT_ID-apigee-runtime.json"
    ...
  6. Save the file.
  7. Delete the environment from the management plane. You can use either the Apigee UI or the Delete environments API.

    Apigee UI

    1. In the Google Cloud console, go to the Apigee > Management > Environments page.

      Go to Environments

    2. Select the project of your Apigee organization.
    3. In the row of the prod environment, click Actions > Delete.

    API

    No data residency:

    curl -X DELETE -H "Authorization: Bearer $TOKEN" \
      "https://apigee.googleapis.com/v1/organizations/ORG_NAME/environments/prod"

    Data residency:

    curl -X DELETE -H "Authorization: Bearer $TOKEN" \
      "https://CONTROL_PLANE_LOCATION-apigee.googleapis.com/v1/organizations/ORG_NAME/environments/prod"

    The call returns a long-running operation. Deletion can take a few minutes to complete.