Use this task to decommission a client's DigiTrade environment by removing its Terraform-managed GCP resources.
Before you begin
Complete all required backups, exports, and data migrations before continuing. Destroy is not reversible.
Use the same Terraform project and state that created the deployment. A missing or stale state can leave resources behind because Terraform identifies what to remove from its state.
If several environments or workspaces exist, confirm that you are targeting the right one before continuing.
Steps
Open a terminal in the Terraform project directory used for the original deployment.
cd <terraform-project-directory>
Optional: Initialize the workspace first if it is new or stale on this machine.
terraform init
Preview exactly what will be removed and read the output carefully.
terraform plan -destroy
Destroy the resources. Type
yeswhen Terraform asks for confirmation to proceed. To skip the prompt, useterraform destroy -auto-approveonly when you are certain that the targeted environment is correct.terraform destroy
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 this removes
Destroy removes the compute instance created by Terraform for the deployment.
Destroy removes the load balancer and its network endpoint groups created by Terraform for the deployment.
Destroy removes the Cloud NAT resources and reserved static IP addresses created by Terraform for the deployment.
Destroy removes the Cloud Armor policies created by Terraform for the deployment.
Destroy removes the deployment service account created by Terraform.
What this does not remove
Destroy does not remove the GCP project itself; the project container remains after destroy. To remove the project as well, see GCP deployment troubleshooting and recovery.
Destroy does not remove resources created manually outside Terraform.
Destroy does not remove resources tracked by a different Terraform state.
Destroy does not remove external dependencies, such as DNS records that point to the destroyed environment. Destroy removes what this Terraform state records, so anything the state never tracked survives it.
Related
