AWS code-library documentation change
Summary
Added Python SDK example for DeleteDBCluster with error handling for access control
Security assessment
While the example includes AccessDeniedException handling, this is standard permission error management rather than documentation of security features or vulnerability fixes. No evidence of addressing a specific security issue.
Diff
diff --git a/code-library/latest/ug/neptune_example_neptune_DeleteDBCluster_section.md b/code-library/latest/ug/neptune_example_neptune_DeleteDBCluster_section.md index 7d5d094d9..a4e1f941e 100644 --- a//code-library/latest/ug/neptune_example_neptune_DeleteDBCluster_section.md +++ b//code-library/latest/ug/neptune_example_neptune_DeleteDBCluster_section.md @@ -9 +9 @@ There are more AWS SDK examples available in the [AWS Doc SDK Examples](https:// -The following code example shows how to use `DeleteDBCluster`. +The following code examples show how to use `DeleteDBCluster`. @@ -44,0 +45,50 @@ There's more on GitHub. Find the complete example and learn how to set up and ru +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](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/neptune#code-examples). + + + def delete_db_cluster(neptune_client, cluster_id: str): + """ + Deletes a Neptune DB cluster and throws exceptions to the caller. + + Args: + neptune_client (boto3.client): The Neptune client object. + cluster_id (str): The ID of the Neptune DB cluster to be deleted. + + Raises: + ClientError: If the delete operation fails. + """ + request = { + 'DBClusterIdentifier': cluster_id, + 'SkipFinalSnapshot': True + } + + try: + print(f"Deleting DB Cluster: {cluster_id}") + neptune_client.delete_db_cluster(**request) + + except ClientError as err: + code = err.response["Error"]["Code"] + message = err.response["Error"]["Message"] + + if code == "DBClusterNotFoundFault": + print(f"Cluster '{cluster_id}' not found or already deleted.") + elif code == "AccessDeniedException": + print("Access denied. Please ensure you have the necessary permissions.") + else: + print(f"Couldn't delete DB cluster. {code}: {message}") + raise + + + + * For API details, see [DeleteDBCluster](https://docs.aws.amazon.com/goto/boto3/neptune-2014-10-31/DeleteDBCluster) in _AWS SDK for Python (Boto3) API Reference_. + + + +