To delete a deployment, you use the Automation Service Broker Deployment API and if needed, the Automation Assembler IaaS API. You make a DELETE request to remove the deployment and clean up the associated resources from the cloud provider.
Prerequisites
- Verify that all general prerequisites and prerequisites for the Automation Service Broker Deployment service have been satisfied. See Prerequisites for API Use Case Examples.
- Verify that you have the Automation Assembler administrator service role.
- 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 Automation Service Broker Deployment service and the Automation Assembler Infrastructure as a Service (IaaS) service have different API version values. You set the API version value for the Automation Service Broker Deployment service when you satisfied the general prerequisites.
Procedure
Example: Delete Your Deployment
This example shows how to delete a deployment with the Automation Service Broker Deployment service and when that deletion fails, force the deletion with the Automation Assembler IaaS service.
Assign variables.
$ url='https://api.mgmt.cloud.vmware.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 Automation Assembler IaaS service.
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'
Use the Automation Service Broker Deployment service 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 "."
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", ...