Undeploying modules using Gruntwork Pipelines
To destroy a module with no downstream dependencies, such as route53-private
in the dev
environment:
Update the
force_destroy
variable indev/us-west-2/dev/networking/route53-private/terragrunt.hcl
. (See theforce_destroy
section.)force_destroy = true
Open a pull request for that change and verify the plan in CI. You should see a trivial change to update the module.
Go through the typical git workflow to get the change merged into the main branch.
As CI runs on the main branch, watch for the job to be held for approval. Approve the job, and wait for the
deployment
step to complete so that the module is fully updated with the new variable.Remove the module folder from the repo. For example:
rm -rf dev/us-west-2/dev/networking/route53-private
Open a pull request for that change and verify the plan in CI.
- Make sure the
plan -destroy
output looks accurate. - If you are deleting multiple modules (e.g., in
dev
,stage
, andprod
) you should see multiple plan outputs -- one per folder deleted. You'll need to scroll through the plan output to see all of them, as it runsplan -destroy
for each folder individually.
- Make sure the
Go through the typical git workflow to get the change merged into the main branch.
As CI runs on the main branch, watch for the job to be held for approval. Approve the job, and wait for the
deployment
step to complete so that the module is fully deleted.
note
Repeat this process for upstream dependencies you may now want to destroy, always starting from the modules that have no existing downstream dependencies.