Getting Started - Terraform Cloud

Clean Up Cloud Resources

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.

  1. Destroy infrastructure
  2. Delete the Terraform Cloud workspace
  3. Delete the GitHub repository
  4. Delete or diisable the AWS Identity Access Manager (IAM) user
  5. Next steps

Destroy infrastructure

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 terraform 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".

Destruction and Deletion

This page gives two different options:

  • Queue destroy plan: Perform a terraform destroy action to destroy any infrastructure created by prior terraform apply actions
  • Delete from Terraform Cloud: Delete your workspace from Terraform Cloud

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:

  1. Set an environment variable
  2. Queue a destroy plan
  3. 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 CONFIRM_DESTROY, with a value of 1.

CONFIRM_DESTROY environment variable

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.

Next steps

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: