View a markdown version of this page

Use CancelDeployment with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use CancelDeployment with an AWS SDK or CLI

The following code examples show how to use CancelDeployment.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:

CLI
AWS CLI

To cancel a deployment

The following cancel-deployment example stops a continuous deployment to a thing group.

aws greengrassv2 cancel-deployment \ --deployment-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111

Output:

{ "message": "SUCCESS" }

For more information, see Cancel deployments in the AWS IoT Greengrass V2 Developer Guide.

Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

def cancel_deployment(self, deployment_id: str) -> dict[str, Any]: """ Cancels an active deployment. :param deployment_id: The ID of the deployment to cancel. :return: A dictionary containing the cancellation response message. """ try: response = self.client.cancel_deployment(deploymentId=deployment_id) logger.info("Canceled deployment %s.", deployment_id) return response except ClientError as err: if err.response["Error"]["Code"] == "ConflictException": logger.error( "Deployment cannot be canceled because it is in a conflicting state " "(e.g., already canceled or completed). %s", err.response["Error"]["Message"], ) raise
  • For API details, see CancelDeployment in AWS SDK for Python (Boto3) API Reference.