AWS Security ChangesHomeSearch

AWS AWSSimpleQueueService documentation change

Service: AWSSimpleQueueService · 2025-03-10 · Documentation low

File: AWSSimpleQueueService/latest/SQSDeveloperGuide/example_sqs_SetQueueAttributes_section.md

Summary

Added Java example for configuring SQS queue with server-side encryption using a custom KMS key

Security assessment

The change adds documentation about enabling server-side encryption (SSE) with KMS, which is a security feature. However, there's no evidence this addresses a specific security vulnerability.

Diff

diff --git a/AWSSimpleQueueService/latest/SQSDeveloperGuide/example_sqs_SetQueueAttributes_section.md
index 5dae5d0e5..07cdd5eb6 100644
--- a/AWSSimpleQueueService/latest/SQSDeveloperGuide/example_sqs_SetQueueAttributes_section.md
+++ b/AWSSimpleQueueService/latest/SQSDeveloperGuide/example_sqs_SetQueueAttributes_section.md
@@ -365,0 +366,57 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
+Java
+    
+
+**SDK for Java 2.x**
+    
+
+###### Note
+
+There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/sqs#code-examples). 
+
+Configure an Amazon SQS to use server-side encryption (SSE) using a custom KMS key.
+    
+    
+        public static void addEncryption(String queueName, String kmsMasterKeyAlias) {
+            SqsClient sqsClient = SqsClient.create();
+    
+            GetQueueUrlRequest urlRequest = GetQueueUrlRequest.builder()
+                    .queueName(queueName)
+                    .build();
+    
+            GetQueueUrlResponse getQueueUrlResponse;
+            try {
+                getQueueUrlResponse = sqsClient.getQueueUrl(urlRequest);
+            } catch (QueueDoesNotExistException e) {
+                LOGGER.error(e.getMessage(), e);
+                throw new RuntimeException(e);
+            }
+            String queueUrl = getQueueUrlResponse.queueUrl();
+    
+    
+            Map<QueueAttributeName, String> attributes = Map.of(
+                    QueueAttributeName.KMS_MASTER_KEY_ID, kmsMasterKeyAlias,
+                    QueueAttributeName.KMS_DATA_KEY_REUSE_PERIOD_SECONDS, "140" // Set the data key reuse period to 140 seconds.
+            );                                                                  // This is how long SQS can reuse the data key before requesting a new one from KMS.
+    
+            SetQueueAttributesRequest attRequest = SetQueueAttributesRequest.builder()
+                    .queueUrl(queueUrl)
+                    .attributes(attributes)
+                    .build();
+            try {
+                sqsClient.setQueueAttributes(attRequest);
+                LOGGER.info("The attributes have been applied to {}", queueName);
+            } catch (InvalidAttributeNameException | InvalidAttributeValueException e) {
+                LOGGER.error(e.getMessage(), e);
+                throw new RuntimeException(e);
+            } finally {
+                sqsClient.close();
+            }
+        }
+    
+    
+
+  * For API details, see [SetQueueAttributes](https://docs.aws.amazon.com/goto/SdkForJavaV2/sqs-2012-11-05/SetQueueAttributes) in _AWS SDK for Java 2.x API Reference_. 
+
+
+
+