capabilities.work

Destroy Infrastructure and Delete the Workspace

A 6-step recipe with Terraform. We can help you get access.

Recipe · 6 steps

Destroy Infrastructure and Delete the Workspace

with Terraform · IT Infrastructure Management

Destroy a workspace's managed infrastructure and then remove the workspace.

  1. Read the workspace to confirm it exists and is unlocked before queueing a destructive run against it.
  2. Queue a destroy run against the workspace. The run plans the removal of every resource the workspace manages but does not apply it yet.
  3. Poll the destroy run until its plan settles, repeating while it is still pending, fetching, or planning.
  4. Confirm and apply the destroy plan, tearing down the infrastructure the workspace manages.
  5. Poll the run until the destroy apply reaches a terminal state, so the workspace is only deleted after its resources are actually gone.
  6. Delete the workspace now that its managed infrastructure has been destroyed and the apply reported success.
What you'll need to have ready
  • workspaceId: The workspace identifier to tear down (e.g. ws-XXXXXXXXXXXX).
  • destroyMessage: The message recorded against the destroy run.
  • applyComment: The comment recorded when the destroy plan is confirmed.
  • deleteWorkspace: Whether to delete the workspace record after the destroy applies.
For your developer

Arazzo workflow terraform:destroy-workspace, 6 operations: GetWorkspace → CreateRun → GetRun → ApplyRun → GetRun → DeleteWorkspace. Specs on APIs.io.