Creating a Destroy Job
Create a destroy job in Resource Manager to release (tear down) resources associated with a stack and clean up the tenancy. Released resources are eventually deleted by the related OCI service. For example, a released compute instance is eventually deleted by the OCI Compute service.
The stack's job history and state remain after running a destroy job. You can monitor the status and review the results of a destroy job by inspecting the stack's log files.
The destroy job is available when resources exist that were created by the stack.
We recommend running a destroy job before deleting a stack to release associated resources first. When you delete a stack, its associated state file is also deleted; therefore, you lose track of the state of its associated resources. Cleaning up resources associated with a deleted stack can be difficult without the state file, especially when those resources are spread across multiple compartments. To avoid difficult cleanup later, we recommend that you release associated resources first by running a destroy job. If the stack has no associated resources, then a destroy job isn't available. You can safely delete such a stack without concern about missing state files.
Data cannot be recovered from destroyed resources.
The destroy job is created. The new job is listed under Jobs.
Use the
oci resource-manager job create-destroy-job
command and required parameters to run a destroy job.oci resource-manager job create-destroy-job [OPTIONS]
For a complete list of parameters and values for CLI commands, see the Command Line Reference for Resource Manager.
Use the CreateJob operation to create a destroy job.
For an example of the
operation
part of the request, see CreateDestroyJobOperationDetails.
What's Next
After running a destroy job, get the job's details to check its status. You can optionally view the Terraform state file, view the logs, and confirm deletion of the resources. You can also re-create destroyed resources.
Monitor the job status (lifecycle state) by getting the job's details. Succeeded (SUCCEEDED
) indicates that the job has completed. Depending on the complexity of the job, the operation can take some time. While the job runs, or after it finishes, you can get the job logs content.
To view the Terraform state file (shows the state of your resources after running the job), select the name of the job to display the Job details page, then select View state under Resources. Optionally select Show changes in this version.
To view the logs for the job, select the job to open its details page, then select Logs under Resources.
To confirm deletion of the resources, inspect resources in the compartment.
To re-create a stack's resources after the resources are destroyed, run an apply job. The new resources differ from previously destroyed resources by their unique OCIDs and other metadata.