기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
다음과 ListGrants
함께 사용하십시오. AWS SDK또는 CLI
다음 코드 예제는 ListGrants
의 사용 방법을 보여 줍니다.
- .NET
-
- AWS SDK for .NET
-
참고
더 많은 정보가 있습니다 GitHub. 전체 예제를 찾아 설치 및 실행 방법을 알아보십시오. AWS 코드 예제 리포지토리
. using System; using System.Threading.Tasks; using Amazon.KeyManagementService; using Amazon.KeyManagementService.Model; /// <summary> /// List the AWS Key Management Service (AWS KMS) grants that are associated with /// a specific key. /// </summary> public class ListGrants { public static async Task Main() { // The identifier of the AWS KMS key to disable. You can use the // key Id or the Amazon Resource Name (ARN) of the AWS KMS key. var keyId = "1234abcd-12ab-34cd-56ef-1234567890ab"; var client = new AmazonKeyManagementServiceClient(); var request = new ListGrantsRequest { KeyId = keyId, }; var response = new ListGrantsResponse(); do { response = await client.ListGrantsAsync(request); response.Grants.ForEach(grant => { Console.WriteLine($"{grant.GrantId}"); }); request.Marker = response.NextMarker; } while (response.Truncated); } }
-
자세한 API 내용은 ListGrants을 참조하십시오. AWS SDK for .NET API참조.
-
- CLI
-
- AWS CLI
-
보조금을 보려면 AWS KMS키
다음
list-grants
예제는 지정된 항목에 대한 모든 보조금을 표시합니다. AWS 사용자 계정의 Amazon DynamoDB용 관리 KMS 키입니다. 이 권한 부여를 통해 DynamoDB는 DynamoDB KMS 테이블을 디스크에 쓰기 전에 사용자 대신 키를 사용하여 DynamoDB 테이블을 암호화할 수 있습니다. 다음과 같은 명령을 사용하여 다음에 대한 권한 부여를 확인할 수 있습니다. AWS 내 관리 KMS 키 및 고객 관리 KMS 키 AWS 계정 및 지역.이 명령은 키 ID가 있는
key-id
파라미터를 사용하여 KMS 키를 식별합니다. 키 ID 또는 키를 사용하여 키를 ARN 식별할 수 있습니다. KMS 키 ID 또는 키를 ARN 가져오려면 AWS 관리 KMS 키는list-keys
orlist-aliases
명령을 사용합니다.aws kms list-grants \ --key-id
1234abcd-12ab-34cd-56ef-1234567890ab
출력 결과는 Amazon DynamoDB에 암호화 작업에 키를 사용할 KMS 권한을 부여하고 키 () 에 대한 KMS 세부 정보를 보고 권한 부여를 취소할 수 있는 권한
DescribeKey
() 을 부여했음을 보여줍니다.RetireGrant
EncryptionContextSubset
제약 조건은 이러한 권한을 지정된 암호화 컨텍스트 페어를 포함하는 요청으로 제한합니다. 따라서 권한 부여의 권한은 지정된 계정 및 DynamoDB 테이블에만 유효합니다.{ "Grants": [ { "Constraints": { "EncryptionContextSubset": { "aws:dynamodb:subscriberId": "123456789012", "aws:dynamodb:tableName": "Services" } }, "IssuingAccount": "arn:aws:iam::123456789012:root", "Name": "8276b9a6-6cf0-46f1-b2f0-7993a7f8c89a", "Operations": [ "Decrypt", "Encrypt", "GenerateDataKey", "ReEncryptFrom", "ReEncryptTo", "RetireGrant", "DescribeKey" ], "GrantId": "1667b97d27cf748cf05b487217dd4179526c949d14fb3903858e25193253fe59", "KeyId": "arn:aws:kms:us-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab", "RetiringPrincipal": "dynamodb.us-west-2.amazonaws.com", "GranteePrincipal": "dynamodb.us-west-2.amazonaws.com", "CreationDate": "2021-05-13T18:32:45.144000+00:00" } ] }
자세한 내용은 다음 권한 부여를 참조하십시오. AWS KMS에서 AWS 키 관리 서비스 개발자 가이드.
-
자세한 API 내용은 ListGrants
을 참조하십시오. AWS CLI 명령 참조.
-
- Java
-
- SDK자바 2.x의 경우
-
참고
더 많은 내용이 있습니다. GitHub 전체 예제를 찾아 설치 및 실행 방법을 알아보십시오. AWS 코드 예제 리포지토리
. /** * Asynchronously displays the grant IDs for the specified key ID. * * @param keyId the ID of the AWS KMS key for which to list the grants * @return a {@link CompletableFuture} that, when completed, will be null if the operation succeeded, or will throw a {@link RuntimeException} if the operation failed * @throws RuntimeException if there was an error listing the grants, either due to an {@link KmsException} or an unexpected error */ public CompletableFuture<Object> displayGrantIdsAsync(String keyId) { ListGrantsRequest grantsRequest = ListGrantsRequest.builder() .keyId(keyId) .limit(15) .build(); ListGrantsPublisher paginator = getAsyncClient().listGrantsPaginator(grantsRequest); return paginator.subscribe(response -> { response.grants().forEach(grant -> { logger.info("The grant Id is: " + grant.grantId()); }); }) .thenApply(v -> null) .exceptionally(ex -> { Throwable cause = ex.getCause(); if (cause instanceof KmsException) { throw new RuntimeException("Failed to list grants: " + cause.getMessage(), cause); } else { throw new RuntimeException("An unexpected error occurred: " + cause.getMessage(), cause); } }); }
-
자세한 API 내용은 ListGrants을 참조하십시오. AWS SDK for Java 2.x API참조.
-
- Kotlin
-
- SDK코틀린의 경우
-
참고
더 많은 정보가 있습니다. GitHub 전체 예제를 찾아 설치 및 실행 방법을 알아보십시오. AWS 코드 예제 리포지토리
. suspend fun displayGrantIds(keyIdVal: String?) { val request = ListGrantsRequest { keyId = keyIdVal limit = 15 } KmsClient { region = "us-west-2" }.use { kmsClient -> val response = kmsClient.listGrants(request) response.grants?.forEach { grant -> println("The grant Id is ${grant.grantId}") } } }
-
자세한 API 내용은 ListGrants
을 참조하십시오. AWS SDKKotlin API 레퍼런스는 여기를 참조하세요.
-
- Python
-
- SDK파이썬용 (보토3)
-
참고
더 많은 정보가 있습니다. GitHub 전체 예제를 찾아 설치 및 실행 방법을 알아보십시오. AWS 코드 예제 리포지토리
. class GrantManager: def __init__(self, kms_client): self.kms_client = kms_client def list_grants(self, key_id): """ Lists grants for a key. :param key_id: The ARN or ID of the key to query. :return: The grants for the key. """ answer = input(f"Ready to list grants on key {key_id} (y/n)? ") if answer.lower() == "y": try: grants = self.kms_client.list_grants(KeyId=key_id)["Grants"] except ClientError as err: logger.error( "Couldn't list grants for key %s. Here's why: %s", key_id, err.response["Error"]["Message"], ) else: print(f"Grants for key {key_id}:") pprint(grants) return grants
-
자세한 API 내용은 ListGrants을 참조하십시오. AWS SDK파이썬 (Boto3) API 참조용.
-
전체 목록은 다음과 같습니다. AWS SDK개발자 가이드 및 코드 예제는 을 참조하십시오사용 AWS KMS 와 함께 AWS SDK. 이 항목에는 시작에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.