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:
- Get your gcloud authentication credentials:
TOKEN=$(gcloud auth print-access-token)
- 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.
- List the attachments of the environment group and note the
name(attachment ID) of the attachment whoseenvironmentisprod: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" } ] } - 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
namereturned 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.
- List the attachments of the environment group and note the
- 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-envchart for this environment. This is often the same as the environment name. To list the release names in your namespace, runhelm list -n APIGEE_NAMESPACE. - APIGEE_NAMESPACE is the namespace where you installed Apigee hybrid,
apigeeby default.
The
--dry-runoption simulates the uninstall without removing anything, and its output is the same as the output of the actual uninstall. Unlikehelm upgrade,helm deletedoesn't accept a value for--dry-runsuch as--dry-run=server. For example:helm delete prod -n apigee --dry-runrelease "prod" uninstalled - ENV_RELEASE_NAME is the name with which you previously installed the
- If the dry run is error-free, remove the runtime components:
helm delete ENV_RELEASE_NAME -n APIGEE_NAMESPACE
- Open your overrides file and remove the
prodenvironment definition fromenvs, 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" ... - Save the file.
- Delete the environment from the management plane. You can use either the Apigee UI or
the Delete environments API.
Apigee UI
In the Google Cloud console, go to the Apigee > Management > Environments page.
- Select the project of your Apigee organization.
- In the row of the
prodenvironment, 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.