Over the course of these tutorials, you created an EC2 instance in AWS, a Terraform Cloud workspace, and a GitHub repository.
In this tutorial, you will destroy the EC2 instance and delete your Terraform Cloud workspace.
If you plan to complete later tutorials, destroy the resources but not the workspace in this tutorial.
Now that you have provisioned and changed infrastructure with Terraform Cloud, the final stage of your infrastructure's lifecycle is to destroy it. Terraform Cloud allows you to destroy the infrastructure you have provisioned as a part of the standard workflow.
To destroy the infrastructure you provisioned in these tutorials, go to your workspace in the Terraform Cloud UI. Navigate to your workspace's Settings, then to Destruction and Deletion.
This page offers two operations:
- Queue destroy plan destroys all infrastructure managed by the workspace.
- Delete from Terraform Cloud deletes your workspace from Terraform Cloud without destroying the infrastructure the workspace manages.
Deleting a workspace does not destroy its infrastructure. For example, if you were to delete this workspace, the AWS EC2 instance you provisioned earlier would still exist.
Click the red Queue destroy plan button.
Terraform Cloud will prompt you to enter your workspace name before you can queue a destroy plan.
Enter your workspace name and queue the plan.
As it does with all plans, Terraform Cloud will ask you to Confirm and Apply the plan. Do so now to destroy your EC2 instance.
After a few minutes, the apply step should complete successfully.
Verify that Terraform destroyed the EC2 instance by visiting the AWS web console in the region where you created it. The configuration defaults to using the N. California/us-west-1 region.
If you plan to continue to later tutorials and your organization does not contain other workspaces, do not destroy the workspace created.
If you do not plan to run these tutorials again and want to keep your Terraform Cloud organization clean, you can delete the workspace you created. Terraform Cloud does not limit the number of workspaces you have or charge per workspace, so whether you delete the workspace is up to you.
To delete the workspace, return to the Settings -> Destruction & Deletion page, and click the red Delete from Terraform Cloud button.
Terraform Cloud will prompt you to enter your workspace name before you can click Delete workspace. Input the workspace name and click the button to delete the workspace.
In these tutorials you used Terraform Cloud to provision, change, and destroy infrastructure using both the CLI and VCS-driven workflows. Now you are ready to learn more about developing Terraform configurations. Get started with using Terraform to manage resources on your preferred cloud platform:
At the end of the tutorials listed above, you will revisit managing your configuration using the CLI-driven Terraform Cloud workflow.
To explore Terraform Cloud's paid features (which you can enable with a free trial), continue to the next tutorials. These will demonstrate enforcing policies with Sentinel policy-as-code, and estimating the cost of infrastructure changes.
Learn more about the concepts you used in these tutorials by exploring the documentation.