Use this task to decommission a client's DigiTrade environment by removing the GCP resources that Terraform manages. It works from the same Terraform project and state that created the deployment. Run it only when you are certain the environment is no longer needed.
Before you begin
Finish all required backups, exports, and data migrations first. Destroy is not reversible.
Terraform identifies what to remove from its state, so a missing or stale state can leave resources behind.
If several environments or workspaces exist, confirm you are targeting the right one before you continue.
Steps
Open a terminal in the Terraform project directory used for the original deployment.
cd <terraform-project-directory>
Optional: If the workspace is new or stale on this machine, initialize it first.
terraform init
Preview exactly what will be removed, and read the output carefully.
terraform plan -destroy
Destroy the resources. Terraform asks for confirmation, so type yes to proceed.
terraform destroy
Optional: To skip the confirmation prompt, add the -auto-approve flag to the destroy command. Use that flag only when you are certain the targeted environment is correct.
Result
The client's managed infrastructure is removed from GCP and no longer serves traffic. Confirm the removal in the GCP console. The project container itself remains in place.
What destroy removes
Destroy removes the resources Terraform created for the deployment.
The compute instance.
The load balancer and its network endpoint groups.
The Cloud NAT resources and reserved static IP addresses.
The Cloud Armor policies.
The deployment service account.
What destroy does not remove
The GCP project itself remains after destroy.
Resources created manually outside Terraform remain.
Resources tracked by a different Terraform state remain.
External dependencies, such as DNS records that point at the destroyed environment, remain. Destroy removes only what this Terraform state records, so anything the state never tracked survives it.
Related
