To delete a deployment, you use the Deployments API. You make a DELETE request to remove the deployment and clean up the associated resources from the cloud provider.

If using the Deployments API fails to delete the deployment, you can use the IaaS API to force the deletion. The following procedure shows how to delete a deployment when both APIs are used.

Prerequisites

  • Verify that all general prerequisites have been satisfied. See Prerequisites for Managing Your Deployment.
  • Verify that you know the deployment that you want to delete.
  • Assign an API version variable for the IaaS API.
    api_version_iaas='2021-07-15'
    Note: The Deployment API and IaaS API have different API version values. You set the API version value for the Deployment API when you satisfied the general prerequisites.

Procedure

  1. List all deployments.
    curl -X GET "$url/deployment/api/deployments?apiVersion=$api_version" -H "Authorization: Bearer $access_token" | jq "."
  2. Examine the response to find the name and ID of the deployment that you want to delete.
  3. Assign your deployment ID variable.
    deployment_id='<your_deployment_id>'
  4. Get a list of actions for the deployment.
    curl -X GET \
      "$url/deployment/api/deployments/$deployment_id/actions?apiVersion=$api_version" \
      -H "Authorization: Bearer $access_token" | jq "."
  5. Examine the response.
    • Confirm that you see the action "id": "Deployment.Delete".
    • "valid":true indicates that the action is valid for the deployment.
  6. Delete the deployment.
    curl -X DELETE \
      "$url/deployment/api/deployments/$deployment_id?apiVersion=$api_version" \
      -H "Authorization: Bearer $access_token" | jq "."
  7. Examine the response for the ID of the deletion request.
  8. Assign the ID to the request ID variable.
    request_id='<delete_request_id>'
  9. Get the status of the deployment request.
    curl -X GET \
      "$url/deployment/api/requests/$request_id?apiVersion=$api_version" \
      -H "Authorization: Bearer $access_token" | jq "."
  10. Examine the response.
    • If the response shows "status": "SUCCESSFUL", then the delete request succeeded.
    • If the response shows "status": "FAILED" then the delete request may have failed due to a dependency such as an unreleased IP in an AD account. If you are certain that you want to remove the deployment and all related resources, you can choose to ignore the deletion failures and submit a delete request that uses the IaaS API.
  11. (Optional) If you want to force deletion, use forceDelete=true in the IaaS API delete request.
    curl -X DELETE \
      "$url/iaas/api/deployments/$deployment_id?forceDelete=true&apiVersion=$api_version_iaas" \
      -H "Authorization: Bearer $access_token" | jq "."
  12. (Optional) Repeat steps 7, 8, and 9.
  13. (Optional) Examine the response to verify that "status": "SUCCESSFUL" appears.

Example: Delete Your Deployment

This example shows how to delete a deployment with the Deployments API and when that deletion fails, force the deletion with the IaaS API.

Assign variables.

$ url='https://appliance.domain.com'
$ api_version='2020-08-25'
$ api_version_iaas='2021-07-15'

List all deployments.

curl -X GET "$url/deployment/api/deployments?apiVersion=$api_version" -H "Authorization: Bearer $access_token" | jq "."

Examine the response to find the deployment that you want to delete.

    {
      "id": "164f2d4e-1755-491e-b0a0-583f0ed4ae3e",
      "name": "example_deployment",
      "description": "",
      ...
    },

Assign your deployment variable.

deployment_id='164f2d4e-1755-491e-b0a0-583f0ed4ae3e'

List the actions available for your deployment.

$ curl -X GET \
  "$url/deployment/api/deployments/$deployment_id/actions?apiVersion=$api_version" \
  -H "Authorization: Bearer $access_token" | jq "."

A snippet of the response shows the action "id": "Deployment.Delete" with "valid": true so you can delete the deployment.

...
{
    "id": "Deployment.Delete",
    "name": "Delete",
    "displayName": "Delete",
    "description": "Delete a deployment",
    "valid": true,
    "actionType": "RESOURCE_ACTION"
  }
...

Delete the deployment.

curl -X DELETE \
  "$url/deployment/api/deployments/$deployment_id?apiVersion=$api_version" \
  -H "Authorization: Bearer $access_token" | jq "."

A snippet of the response shows the ID which is the request ID.

...
  "id": "d9541db3-2806-42aa-bde0-fb870d114833",
  "name": "Delete",
  "requestedBy": "[email protected]",
  "actionId": "Deployment.Delete",
  "deploymentId": "164f2d4e-1755-491e-b0a0-583f0ed4ae3e",
  "resourceIds": [
    ...
  ],
  "status": "PENDING",
...

Assign the request ID variable.

$ request_id='d9541db3-2806-42aa-bde0-fb870d114833'

Check the status of the request.

$ curl -X GET \
  "$url/deployment/api/requests/$request_id?apiVersion=$api_version" \
  -H "Authorization: Bearer $access_token" | jq "."

A snippet of the response shows that the request failed.

{
  "id": "d9541db3-2806-42aa-bde0-fb870d114833",
  "name": "Delete",
  "requestedBy": "[email protected]",
  "actionId": "Deployment.Delete",
  "deploymentId": "164f2d4e-1755-491e-b0a0-583f0ed4ae3e",
  "resourceIds": [
    ...
  ],
  "status": "FAILED",
...

If you are certain that you want to delete the deployment, force the deletion using the IaaS API.

curl -X DELETE \
  "$url/iaas/api/deployments/$deployment_id?forceDelete=true&apiVersion=$api_version_iaas" \
  -H "Authorization: Bearer $access_token" | jq "."

Examine the response to get the new request ID.

{
  "progress": 0,
  "status": "INPROGRESS",
  "name": "Delete",
  "id": "a1b674a2-09aa-4b14-9459-35dddddb9bbc1",
  "selfLink": "/iaas/api/request-tracker/a1b674a2-09aa-4b14-9459-35dddddb9bbc1"
...

Assign the new request ID.

$ new_request_id='a1b674a2-09aa-4b14-9459-35dddddb9bbc1'

Check the status of the request.

$ curl -X GET \
  "$url/deployment/api/requests/$new_request_id?apiVersion=$api_version" \
  -H "Authorization: Bearer $access_token" | jq "."

Examine the response to verify that the action is in progress.

{
  "id": "a1b674a2-09aa-4b14-9459-35dddddb9bbc1",
  "name": "Delete",
  "requestedBy": "[email protected]",
  "actionId": "Deployment.Delete",
  "deploymentId": "164f2d4e-1755-491e-b0a0-583f0ed4ae3e",
  "resourceIds": [
  ...
  ],
  "status": "INPROGRESS",
...

Continue to check the status of the request.

$ curl -X GET \
  "$url/deployment/api/requests/$new_request_id?apiVersion=$api_version" \
  -H "Authorization: Bearer $access_token" | jq "."

The response shows when the deployment deletion request is successful.

{
  "id": "a1b674a2-09aa-4b14-9459-35dddddb9bbc1",
  "name": "Delete",
  "requestedBy": "[email protected]",
  "actionId": "Deployment.Delete",
  "deploymentId": "164f2d4e-1755-491e-b0a0-583f0ed4ae3e",
  "resourceIds": [
  ...
  ],
  "status": "SUCCESSFUL",
...