Tip Tuesday | Destroy An OCI Stack Before Deleting It

Tip Tuesday | Destroy An OCI Stack Before Deleting It

Creating a stack in OCI will also create a range of underlying resources needed to support the stack. If you no longer require the stack it's important that you clean up all of the associated resources as well as deleting the stack. Deleting unused resources can save you cash.

This can be easily done by “destroying” the stack before you delete it, in the steps I show below. 

Navigate to Developer Services → Resource Manager → Stacks, change the compartment to correspond to where the stack is located.

Click on the stack to be deleted. 

You can identify the underlying resources which will be deleted when you Destroy the stack under “Stack resources”.

If you're happy for all of these resources to be removed then you can then click the “Destroy” button at the top of the page. 

This will create a destroy job to delete all of these resources. 

I find it useful to tick the “Upgrade provider versions” under “Advanced options” to ensure that older stacks can be destroyed without issue even if they were created using older Terraform versions. 

Clicking “Destroy” will then create a Destroy job. 

When this succeeds you will see that each of the stack resources are destroyed. 

They will no longer be listed under the stack resources tab. 

Your stack can then be safely deleted.