// Module included in the following assemblies:
//
// * rosa_hcp/terraform/rosa-hcp-creating-a-cluster-quickly-terraform.adoc
// * rosa_install_access_delete_clusters/terraform/rosa-classic-creating-a-cluster-quickly-terraform.adoc

:_mod-docs-content-type: PROCEDURE
ifeval::["{context}" == "rosa-classic-creating-a-cluster-quickly-terraform"]
:tf-defaults:
endif::[]
ifeval::["{context}" == "rosa-hcp-creating-a-cluster-quickly-terraform"]
:tf-rosa-hcp:
endif::[]

[id="sd-terraform-cluster-destroy_{context}"]
= Deleting your {product-title} cluster with Terraform

[role="_abstract"]
Use the `terraform destroy` command to remove all resources you create with the `terraform apply` command.

[NOTE]
====
Keep your Terraform .tf files unchanged before destroying your resources. These variables are matched to resources to delete.
====

.Procedure
. In the directory where you ran the `terraform apply` command to create your cluster, run the following command to delete the cluster:
+
[source,terminal]
----
$ terraform destroy
----
+
The Terraform interface prompts you for two variables. These should match the answers you provided when creating a cluster:
+
[source,terminal]
----
var.create_vpc
  If you would like to create a new VPC, set this value to 'true.' If you do not want to create a new VPC, set this value to 'false.'

  Enter a value: 

var.private_cluster
  If you want to create a private cluster, set this value to 'true.' If you want a publicly available cluster, set this value to 'false.'

  Enter a value: 
----

. Enter `yes` to start the role and cluster deletion:
ifdef::tf-rosa-hcp[]
+
.Example output
[source,terminal]
----
Plan: 0 to add, 0 to change, 63 to destroy.

Do you really want to destroy all resources?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes
----
endif::tf-rosa-hcp[]
ifdef::tf-rosa-classic[]
+
.Example output
[source,terminal]
----
Plan: 0 to add, 0 to change, 74 to destroy.

Do you really want to destroy all resources?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes
----
endif::tf-rosa-classic[]

.Verification
. Verify that your cluster was destroyed by running the following command:
+
[source,terminal]
----
$ rosa list clusters
----
+
.Example output showing no cluster
[source,terminal]
----
I: No clusters available
----

. Verify that the account roles were destroyed by running the following command:
+
[source,terminal]
----
$ rosa list account-roles
----
+
.Example output showing no Terraform-created account roles
[source,terminal]
----
I: Fetching account roles
I: No account roles available
----

. Verify that the Operator roles were destroyed by running the following command:
+
[source,terminal]
----
$ rosa list operator-roles
----
+
.Example output showing no Terraform-created Operator roles
[source,terminal]
----
I: Fetching operator roles
I: No operator roles available
----

ifeval::["{context}" == "rosa-classic-creating-a-cluster-quickly-terraform"]
:tf-defaults:
endif::[]
ifeval::["{context}" == "rosa-hcp-creating-a-cluster-quickly-terraform"]
:tf-rosa-hcp:
endif::[]