By following this track, you created a number of different resources, including a DynamoDB table in AWS, the Terraform Cloud workspace, and the GitHub repository. This guide will show you how to delete each of these.
- Destroy infrastructure
- Delete the Terraform Cloud workspace
- Delete the GitHub repository
- Delete or disable the AWS Identity Access Manager (IAM) user
- Next steps
You have already seen how to perform the basic Terraform actions of provisioning
and changing infrastructure with Terraform Cloud. The last part of your
infrastructure's lifecycle will be to destroy it. Just like the
destroy command, Terraform Cloud allows you to destroy the infrastructure you
have provisioned with it.
To destroy the infrastructure you provisioned by following this track, go to your workspace in the Terraform Cloud UI. Next, from the top menu, select "Settings -> Destruction and Deletion".
This page gives two different options:
- Queue destroy plan: Perform a
terraform destroyaction to destroy any infrastructure created by prior
- Delete from Terraform Cloud: Delete your workspace from Terraform Cloud
Important: Deleting a workspace does not destroy infrastructure that has been provisioned by that workspace. For example, if you were to delete this workspace now, the AWS DynamoDB table you provisioned earlier will not be destroyed.
You will notice that the "Queue a destroy plan" button is disabled. Because accidentally destroying infrastructure can be a costly mistake, Terraform Cloud makes it a three step process:
- Set an environment variable
- Queue a destroy plan
- Apply the destroy plan
Set an environment variable
Go to the "Variables" section of your Workspace configuration, and add a
variable to the Environment Variables section called
a value of
Queue a destroy plan
Return to the "Settings -> Destruction & Deletion" page. You should see that the "Queue a destroy plan" button is enabled. Click it now.
Apply the destroy plan
As before, you will be asked to confirm the destroy plan. Do so now, and after a few minutes the apply step should complete successfully. Make sure that it does so before moving on.
Delete the Terraform Cloud workspace
If you would like, you can delete the workspace you created earlier in this track. This is optional, since Terraform Cloud doesn't impose a limit on the number of workspaces you have. To do so, return to the "Settings -> Destruction & Deletion" page, and click the red "Delete from Terraform Cloud" button.
Delete the GitHub repository
This step is also optional.
To delete the GitHub repository you forked earlier in this track, visit your repository in the GitHub UI. From there, go to the "Settings -> Options" page. At the bottom of that page, in the "Danger Zone" section, you will find a "Delete this repository" button.
Delete or disable the AWS IAM user
This step is also optional.
Earlier in this track, you may have created an AWS IAM user for use with Terraform Cloud. You can delete or disable this user in the AWS console, by navigating to the Identity Access Management (IAM) section, and then to the user you created. Once you have found the user, you can use the AWS Console to delete the user, or disable user's access keys.
You have now learned how to use Terraform Cloud to provision infrastructure. If you would like to learn more about Terraform Cloud, here are some next steps: