Gunakan DeleteDBSubnetGroup dengan AWS SDK - AWS Contoh Kode SDK

Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh SDK AWS Doc. GitHub

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Gunakan DeleteDBSubnetGroup dengan AWS SDK

Contoh kode berikut menunjukkan cara menggunakanDeleteDBSubnetGroup.

Java
SDK untuk Java 2.x
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS.

/** * Deletes a subnet group. * * @param subnetGroupName the identifier of the subnet group to delete * @return a {@link CompletableFuture} that completes when the cluster has been deleted */ public CompletableFuture<Void> deleteDBSubnetGroupAsync(String subnetGroupName) { DeleteDbSubnetGroupRequest request = DeleteDbSubnetGroupRequest.builder() .dbSubnetGroupName(subnetGroupName) .build(); return getAsyncClient().deleteDBSubnetGroup(request) .thenAccept(response -> logger.info("🗑️ Deleting Subnet Group: " + subnetGroupName)); }
Python
SDK untuk Python (Boto3)
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS.

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