AWS code-library documentation change
Summary
Added Python (Boto3) code example for DeleteDBSubnetGroup with error handling for AccessDeniedException and DBSubnetGroupNotFoundFault
Security assessment
The change adds standard API usage documentation with error handling. While it mentions AccessDeniedException, this is routine permission checking rather than addressing a specific security vulnerability. No evidence of patching a security issue or introducing new security features.
Diff
diff --git a/code-library/latest/ug/neptune_example_neptune_DeleteDBSubnetGroup_section.md b/code-library/latest/ug/neptune_example_neptune_DeleteDBSubnetGroup_section.md index 952791857..58c53597c 100644 --- a//code-library/latest/ug/neptune_example_neptune_DeleteDBSubnetGroup_section.md +++ b//code-library/latest/ug/neptune_example_neptune_DeleteDBSubnetGroup_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 `DeleteDBSubnetGroup`. +The following code examples show how to use `DeleteDBSubnetGroup`. @@ -43,0 +44,49 @@ 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_subnet_group(neptune_client, subnet_group_name): + """ + Deletes a Neptune DB subnet group synchronously using Boto3. + + Args: + neptune_client (boto3.client): The Neptune client. + subnet_group_name (str): The name of the DB subnet group to delete. + + Raises: + ClientError: If the delete operation fails. + """ + delete_group_request = { + 'DBSubnetGroupName': subnet_group_name + } + + try: + neptune_client.delete_db_subnet_group(**delete_group_request) + print(f"️ Deleting Subnet Group: {subnet_group_name}") + + except ClientError as err: + code = err.response["Error"]["Code"] + message = err.response["Error"]["Message"] + + if code == "DBSubnetGroupNotFoundFault": + print(f"Subnet group '{subnet_group_name}' not found or already deleted.") + elif code == "AccessDeniedException": + print("Access denied. Please ensure you have the necessary permissions.") + else: + print(f"Couldn't delete subnet group. {code}: {message}") + raise + + + + * For API details, see [DeleteDBSubnetGroup](https://docs.aws.amazon.com/goto/boto3/neptune-2014-10-31/DeleteDBSubnetGroup) in _AWS SDK for Python (Boto3) API Reference_. + + + +