AWS SDK와 DeleteDBCluster 함께 사용 - AWS SDK 코드 예제

Doc AWS SDK 예제 GitHub 리포지토리에서 더 많은 SDK 예제를 사용할 수 있습니다. AWS

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

AWS SDK와 DeleteDBCluster 함께 사용

다음 코드 예시는 DeleteDBCluster의 사용 방법을 보여 줍니다.

Java
SDK for Java 2.x
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

/** * Deletes a DB instance asynchronously. * * @param clusterId the identifier of the cluster to delete * @return a {@link CompletableFuture} that completes when the cluster has been deleted */ public CompletableFuture<Void> deleteDBClusterAsync(String clusterId) { DeleteDbClusterRequest request = DeleteDbClusterRequest.builder() .dbClusterIdentifier(clusterId) .skipFinalSnapshot(true) .build(); return getAsyncClient().deleteDBCluster(request) .thenAccept(response -> System.out.println("🗑️ Deleting DB Cluster: " + clusterId)); }
  • API 세부 정보는 AWS SDK for Java 2.x API 참조DeleteDBCluster를 참조하십시오.

Python
SDK for Python (Boto3)
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

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
  • API 세부 정보는 AWS SDK for Python (Boto3) API 참조CreateDBInstance를 참조하십시오.