Delete environments

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

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/synchronizer-manager-service-account.json
      udca: "your_keypath/analytic-agent-service-account.json
  - name: prod
    serviceAccountPaths:
      synchronizer: "your_keypath/synchronizer-manager-service-account.json
      udca: "your_keypath/analytic-agent-service-account.json
...

To delete the prod environment, follow these steps:

  1. Get your gcloud authentication credentials:
    TOKEN=$(gcloud auth print-access-token)
  2. Delete the environment from any associated environment groups, one at a time:
    curl -X DELETE -H "Authorization: Bearer $TOKEN" \
      "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/envgroups/$ENV_GROUP/attachments/$ATTACHMENT_ID"
    Where $ATTACHMENT_ID is the system generated UUID.
  3. Do a dry run to test removal of the runtime components:
    apigeectl delete -f overrides.yaml --env=prod --dry-run=true
  4. If the dry run is error-free, remove the runtime components:
    apigeectl delete -f overrides.yaml --env=prod
  5. Delete the environment from the management plane:
    curl -X DELETE -H "Authorization: Bearer $TOKEN" \
      "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/environments/prod"
  6. Open your overrides file and remove the test environment definition from envs and virtualhosts, leaving only the prod definitions. For example:
    ...
    envs:
      - name: prod
        serviceAccountPaths:
          synchronizer: "your_keypath/synchronizer-manager-service-account.json
          udca: "your_keypath/analytic-agent-service-account.json
    ...
  7. Save the file.