AWS 문서 AWS SDK SDK 예제
기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
DeleteDocument
OR와 함께 사용 AWS SDK CLI
다음 코드 예제는 DeleteDocument
의 사용 방법을 보여 줍니다.
- CLI
-
- AWS CLI
-
문서를 삭제하는 방법
다음
delete-document
예제에서는 Systems Manager 문서를 삭제합니다.aws ssm delete-document \ --name
"Example"
이 명령은 출력을 생성하지 않습니다.
자세한 내용은 AWS Systems Manager 사용 설명서의 Systems Manager 문서 생성을 참조하세요.
-
자세한 API 내용은 AWS CLI 명령 DeleteDocument
참조를 참조하십시오.
-
- Java
-
- SDK자바 2.x의 경우
-
참고
더 많은 내용이 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. /** * Deletes an AWS SSM document asynchronously. * * @param documentName The name of the document to delete. * <p> * This method initiates an asynchronous request to delete an SSM document. * If an exception occurs, it handles the error appropriately. */ public void deleteDoc(String documentName) { DeleteDocumentRequest documentRequest = DeleteDocumentRequest.builder() .name(documentName) .build(); CompletableFuture<Void> future = CompletableFuture.runAsync(() -> { getAsyncClient().deleteDocument(documentRequest) .thenAccept(response -> { System.out.println("The SSM document was successfully deleted."); }) .exceptionally(ex -> { throw new CompletionException(ex); }).join(); }).exceptionally(ex -> { Throwable cause = (ex instanceof CompletionException) ? ex.getCause() : ex; if (cause instanceof SsmException) { throw new RuntimeException("SSM error: " + cause.getMessage(), cause); } else { throw new RuntimeException("Unexpected error: " + cause.getMessage(), cause); } }); try { future.join(); } catch (CompletionException ex) { throw ex.getCause() instanceof RuntimeException ? (RuntimeException) ex.getCause() : ex; } }
-
자세한 API 내용은 DeleteDocument AWS SDK for Java 2.xAPI참조를 참조하십시오.
-
- PowerShell
-
- 에 대한 도구 PowerShell
-
예제 1: 이 예제에서는 문서를 삭제합니다. 명령이 성공해도 출력은 없습니다.
Remove-SSMDocument -Name "RunShellScript"
-
자세한 API 내용은 AWS Tools for PowerShell Cmdlet 참조를 참조하십시오 DeleteDocument.
-
- Python
-
- SDK파이썬용 (보토3)
-
참고
더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. class DocumentWrapper: """Encapsulates AWS Systems Manager Document actions.""" def __init__(self, ssm_client): """ :param ssm_client: A Boto3 Systems Manager client. """ self.ssm_client = ssm_client self.name = None @classmethod def from_client(cls): ssm_client = boto3.client("ssm") return cls(ssm_client) def delete(self): """ Deletes an AWS Systems Manager document. """ if self.name is None: return try: self.ssm_client.delete_document(Name=self.name) print(f"Deleted document {self.name}.") self.name = None except ClientError as err: logger.error( "Couldn't delete %s. Here's why: %s: %s", self.name, err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise
-
자세한 API AWS SDK내용은 Python (Boto3) API 참조를 참조하십시오 DeleteDocument.
-
DeleteAssociation
DeleteMaintenanceWindow