Remove Provisioned Infra with the Terraform Destroy Step
You can add a Terraform Destroy step to remove any provisioned infrastructure, just like running the
terraform destroy command. See destroy from Terraform.
The Terraform Destroy step is independent of any other Terraform provisioning steps. It's not restricted to removing the infrastructure deployed in its stage. It can remove any infrastructure you've provisioned using Harness.
In this topic:
- Before You Begin
- Review: What Gets Destroyed?
- Step 2: Configuration Type
- Step 3: Reference the Provisioner Identifier
- See Also
Before You Begin
Review: What Gets Destroyed?
When you add Terraform Plan and Apply steps, you specify the Terraform script that Harness will use for provisioning. You add a Provisioner Identifier to each step to identify the provisioning.
When you destroy the provisioned infrastructure, you specify the same Provisioner Identifier in the Terraform Destroy step. The Provisioner Identifier enables Harness to locate the same Terraform script used for provisioning.
Step 1: Add the Terraform Destroy Step
You can add the Terraform Destroy step in the following places:
- The Execution steps of a stage.
- The steps of an Infrastructure's Dynamic Provisioning section.
- The Rollback steps of a stage's Execution or Infrastructure using Dynamic Provisioning.
In Name, enter a name for the step. You can use the name to reference the Terraform Destroy settings.
Step 2: Configuration Type
There are three options:
- Inline: Removes the provisioned resources you identify using Provisioner Identifier and other settings.
- Inherit from Plan: Removes the resources defined in the Harness Terraform Plan step that you identify using Provisioner Identifier. Similar to
terraform plan -destroy.
- Inherit from Apply: Removes the resources defined in the Harness Terraform Apply step that you identify using Provisioner Identifier. Similar to
Step 3: Reference the Provisioner Identifier
In Provisioner Identifier, enter the same Provisioner Identifier you used in the Terraform Apply step that provisioning the resources you want to destroy.
Click Apply Changes.
The Terraform Destroy step is added.