Skip to main content

Deleting an Environment

To delete a Depot environment, you can either destroy the parent or 'project' CloudFormation stack that houses the Depot environment, or you can destroy the actual depot environment stack itself (named sdp-{envid}) using the CloudFormation console.

Stacks with Datasets will usually have a Termination Protection policy enabled - you will need to disable that first if you are happy deleting an environment that houses Datasets.

Use the CloudFormation stack Delete button to delete the relevant stack (after double checking it is definitely the correct stack to delete).

Destroy environment using Depot CLI project template (deprecated)

info

Deprecation notice: Depot CLI project templates are no longer available in the latest Depot CLI versions. The information below may be out of date, and no-longer applicable. However, it may still be useful if you have an older environment that was created using this method.

If you can created an Depot environment using a precanned Depot CLI project template and used the CLI command create-env, then you will also have an automated CodeBuild project tied to a GitHub project repository which corresponds to your environment name.

To delete an environment in this scenario you can follow this general approach:

  • Destroy the environment stack by either:

    • Commenting out the contents of the constructor of your environment stack (leaving just the super(...); line) and pushing your changes, or
    • Deleting the 'DepotStack-…' stack in CloudFormation, or
    • Setting an environment variable ENV_NAME="envName" (where envName is the alias of your environment - i.e. the name of the branch) and running cdk destroy in the correct branch in the project repo
  • Manually delete:

    • IAM roles (1 x for codepipeline 1x for codebuild)
    • CodePipeline
    • CodeBuild
    • S3 bucket for codepipeline
    • S3 bucket for data
  • If retaining the project, delete the environment branch from the project repo

To delete the project (in addition to the environments housed within the project):

  • Destroy resources for each environment using the steps above
  • Using the Depot CLI, run the delete-project command, which will
    • Delete the GitHub secret from Secrets Manager
    • Remove the project’s entry in the local Depot configuration file (~/.depotrc)
  • Delete the project GitHub repo