기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
Amazon SQS 대기열에서 서버 측 암호화 사용
를 사용하여 Amazon SQS AWS SDK for Java 대기열에 서버 측 암호화 (SSE) 를 추가할 수 있습니다. 각 대기열은 AWS Key Management Service (AWS KMS) KMS 키를 사용하여 데이터 암호화 키를 생성합니다. 이 예시에서는 Amazon AWS SQS의 관리형 KMS 키를 사용합니다. SSE 사용 및 KMS 키의 역할에 대한 자세한 정보는 Amazon의 저장 중 암호화 SQS 섹션을 참조하세요.
기존 대기열에 SSE 추가
기존 대기열에 대해 서버 측 암호화를 활성화하려면 SetQueueAttributes
메서드를 사용하여 KmsMasterKeyId
속성을 설정합니다.
다음 코드 예제는 를 Amazon AWS KMS key SQS의 AWS 관리형 KMS 키로 설정합니다. 또한 이 예제에서는 AWS KMS key 재사용 기간을 140초로 설정합니다.
예제 코드를 실행하기 전에 자격 증명을 설정했는지 확인하십시오. AWS 자세한 내용은 AWS SDK for Java 2.x 개발자 안내서의 개발용 AWS 자격 증명 및 지역 설정을 참조하십시오.
// Create an SqsClient for the specified Region. SqsClient sqsClient = SqsClient.builder().region(Region.US_WEST_1).build(); // Get the URL of your queue. String myQueueName = "my queue"; GetQueueUrlResponse getQueueUrlResponse = sqsClient.getQueueUrl(GetQueueUrlRequest.builder().queueName(myQueueName).build()); String queueUrl = getQueueUrlResponse.queueUrl(); // Create a hashmap for the attributes. Add the key alias and reuse period to the hashmap. HashMap<QueueAttributeName, String> attributes = new HashMap<QueueAttributeName, String>(); final String kmsMasterKeyAlias = "alias/aws/sqs"; // the alias of the AWS managed KMS key for Amazon SQS. attributes.put(QueueAttributeName.KMS_MASTER_KEY_ID, kmsMasterKeyAlias); attributes.put(QueueAttributeName.KMS_DATA_KEY_REUSE_PERIOD_SECONDS, "140"); // Create the SetQueueAttributesRequest. SetQueueAttributesRequest set_attrs_request = SetQueueAttributesRequest.builder() .queueUrl(queueUrl) .attributes(attributes) .build(); sqsClient.setQueueAttributes(set_attrs_request);
대기열에 SSE 비활성화
기존 대기열의 서버 측 암호화를 비활성화하려면 SetQueueAttributes
메서드를 사용하여 KmsMasterKeyId
속성을 빈 문자열로 설정하세요.
중요
null
은 유효한 KmsMasterKeyId
값이 아닙니다.
SSE를 사용하여 대기열 생성
대기열을 생성할 때 SSE를 활성화하려면 CreateQueue
API 메서드에 KmsMasterKeyId
속성을 추가합니다.
다음 예제에서는 SSE가 활성화된 새 대기열을 만듭니다. 대기열은 Amazon SQS에 AWS 관리형 KMS 키를 사용합니다. 또한 이 예제에서는 AWS KMS key 재사용 기간을 160초로 설정합니다.
예제 코드를 실행하기 전에 AWS 자격 증명을 설정했는지 확인하십시오. 자세한 내용은 AWS SDK for Java 2.x 개발자 안내서의 개발용 AWS 자격 증명 및 지역 설정을 참조하십시오.
// Create an SqsClient for the specified Region. SqsClient sqsClient = SqsClient.builder().region(Region.US_WEST_1).build(); // Create a hashmap for the attributes. Add the key alias and reuse period to the hashmap. HashMap<QueueAttributeName, String> attributes = new HashMap<QueueAttributeName, String>(); final String kmsMasterKeyAlias = "alias/aws/sqs"; // the alias of the AWS managed KMS key for Amazon SQS. attributes.put(QueueAttributeName.KMS_MASTER_KEY_ID, kmsMasterKeyAlias); attributes.put(QueueAttributeName.KMS_DATA_KEY_REUSE_PERIOD_SECONDS, "140"); // Add the attributes to the CreateQueueRequest. CreateQueueRequest createQueueRequest = CreateQueueRequest.builder() .queueName(queueName) .attributes(attributes) .build(); sqsClient.createQueue(createQueueRequest);
SSE 속성 검색
대기열 속성 검색에 대한 자세한 내용은 Amazon Simple Queue Service API 참조의 예를 참조합니다.
특정 대기열의 KMS 키 ID 또는 데이터 키 재사용 기간을 검색하려면 GetQueueAttributes
메서드를 실행하고 KmsMasterKeyId
및 KmsDataKeyReusePeriodSeconds
값을 검색합니다.