From be04ef844d441c00ff46b9e22ff5ab633ac0fb0b Mon Sep 17 00:00:00 2001
From: Scott Gerring
Date: Fri, 4 Aug 2023 15:23:13 +0100
Subject: [PATCH 01/16] chore: Start V2 branch (#1346)
* Initial commit
* Add warning
---
README.md | 4 +-
docs/utilities/large_messages.md | 6 -
docs/utilities/sqs_batch.md | 489 -------------
docs/utilities/sqs_large_message_handling.md | 296 --------
examples/pom.xml | 1 -
examples/powertools-examples-sqs/README.md | 56 --
.../powertools-examples-sqs/events/event.json | 63 --
examples/powertools-examples-sqs/pom.xml | 196 ------
.../java/org/demo/sqs/SqsMessageSender.java | 92 ---
.../src/main/java/org/demo/sqs/SqsPoller.java | 76 --
.../src/main/resources/log4j2.xml | 16 -
.../powertools-examples-sqs/template.yaml | 148 ----
mkdocs.yml | 3 -
pom.xml | 2 -
powertools-sqs/pom.xml | 144 ----
.../sqs/SQSBatchProcessingException.java | 93 ---
.../lambda/powertools/sqs/SqsBatch.java | 104 ---
.../powertools/sqs/SqsLargeMessage.java | 85 ---
.../powertools/sqs/SqsMessageHandler.java | 44 --
.../lambda/powertools/sqs/SqsUtils.java | 653 ------------------
...ippedMessageDueToFailedBatchException.java | 26 -
.../powertools/sqs/internal/BatchContext.java | 281 --------
.../sqs/internal/SqsLargeMessageAspect.java | 170 -----
.../SqsMessageBatchProcessorAspect.java | 55 --
.../powertools/sqs/SampleSqsHandler.java | 26 -
.../sqs/SqsUtilsBatchProcessorTest.java | 386 -----------
.../sqs/SqsUtilsFifoBatchProcessorTest.java | 188 -----
.../sqs/SqsUtilsLargeMessageTest.java | 228 ------
.../sqs/handlers/LambdaHandlerApiGateway.java | 32 -
.../PartialBatchFailureSuppressedHandler.java | 46 --
.../PartialBatchPartialFailureHandler.java | 46 --
.../handlers/PartialBatchSuccessHandler.java | 42 --
.../sqs/handlers/SqsMessageHandler.java | 29 -
...MessageHandlerWithNonRetryableHandler.java | 52 --
...dlerWithNonRetryableHandlerWithDelete.java | 53 --
.../handlers/SqsNoDeleteMessageHandler.java | 29 -
.../internal/SqsLargeMessageAspectTest.java | 222 ------
.../SqsMessageBatchProcessorAspectTest.java | 331 ---------
.../src/test/resources/SqsFifoBatchEvent.json | 73 --
.../test/resources/sampleSqsBatchEvent.json | 36 -
.../sampleSqsBatchEventBatchSize25.json | 404 -----------
.../resources/threeMessageSqsBatchEvent.json | 70 --
powertools-test-suite/pom.xml | 164 -----
.../testsuite/LoggingOrderTest.java | 193 ------
.../handler/LoggingOrderMessageHandler.java | 31 -
.../TracingLoggingStreamMessageHandler.java | 36 -
.../src/test/resources/log4j2.xml | 20 -
47 files changed, 3 insertions(+), 5837 deletions(-)
delete mode 100644 docs/utilities/sqs_batch.md
delete mode 100644 docs/utilities/sqs_large_message_handling.md
delete mode 100644 examples/powertools-examples-sqs/README.md
delete mode 100644 examples/powertools-examples-sqs/events/event.json
delete mode 100644 examples/powertools-examples-sqs/pom.xml
delete mode 100644 examples/powertools-examples-sqs/src/main/java/org/demo/sqs/SqsMessageSender.java
delete mode 100644 examples/powertools-examples-sqs/src/main/java/org/demo/sqs/SqsPoller.java
delete mode 100644 examples/powertools-examples-sqs/src/main/resources/log4j2.xml
delete mode 100644 examples/powertools-examples-sqs/template.yaml
delete mode 100644 powertools-sqs/pom.xml
delete mode 100644 powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SQSBatchProcessingException.java
delete mode 100644 powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsBatch.java
delete mode 100644 powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsLargeMessage.java
delete mode 100644 powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsMessageHandler.java
delete mode 100644 powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsUtils.java
delete mode 100644 powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/exception/SkippedMessageDueToFailedBatchException.java
delete mode 100644 powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/BatchContext.java
delete mode 100644 powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/SqsLargeMessageAspect.java
delete mode 100644 powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/SqsMessageBatchProcessorAspect.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SampleSqsHandler.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsBatchProcessorTest.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsFifoBatchProcessorTest.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsLargeMessageTest.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/LambdaHandlerApiGateway.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchFailureSuppressedHandler.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchPartialFailureHandler.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchSuccessHandler.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandler.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandlerWithNonRetryableHandler.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandlerWithNonRetryableHandlerWithDelete.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsNoDeleteMessageHandler.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/internal/SqsLargeMessageAspectTest.java
delete mode 100644 powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/internal/SqsMessageBatchProcessorAspectTest.java
delete mode 100644 powertools-sqs/src/test/resources/SqsFifoBatchEvent.json
delete mode 100644 powertools-sqs/src/test/resources/sampleSqsBatchEvent.json
delete mode 100644 powertools-sqs/src/test/resources/sampleSqsBatchEventBatchSize25.json
delete mode 100644 powertools-sqs/src/test/resources/threeMessageSqsBatchEvent.json
delete mode 100644 powertools-test-suite/pom.xml
delete mode 100644 powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/LoggingOrderTest.java
delete mode 100644 powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/handler/LoggingOrderMessageHandler.java
delete mode 100644 powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/handler/TracingLoggingStreamMessageHandler.java
delete mode 100644 powertools-test-suite/src/test/resources/log4j2.xml
diff --git a/README.md b/README.md
index 70cfab314..47fb59bd7 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
-# Powertools for AWS Lambda (Java)
+# Powertools for AWS Lambda (Java) V2
+
+**This is pre-release code for Powertools for AWS Lambda (Java) V2! Please check out the `main` branch for the stable release**
   [](https://app.codecov.io/gh/aws-powertools/powertools-lambda-java)
diff --git a/docs/utilities/large_messages.md b/docs/utilities/large_messages.md
index c4947a6e8..c0c1cd599 100644
--- a/docs/utilities/large_messages.md
+++ b/docs/utilities/large_messages.md
@@ -6,12 +6,6 @@ description: Utility
The large message utility handles SQS and SNS messages which have had their payloads
offloaded to S3 if they are larger than the maximum allowed size (256 KB).
-!!! Notice
- The large message utility (available in the `powertools-sqs` module for versions v1.16.1 and earlier) is now deprecated
- and replaced by the `powertools-large-messages` described in this page.
- You can still get the documentation [here](sqs_large_message_handling.md)
- and the migration guide [here](#migration-from-the-sqs-large-message-utility).
-
## Features
- Automatically retrieve the content of S3 objects when SQS or SNS messages have been offloaded to S3.
diff --git a/docs/utilities/sqs_batch.md b/docs/utilities/sqs_batch.md
deleted file mode 100644
index 658f7b085..000000000
--- a/docs/utilities/sqs_batch.md
+++ /dev/null
@@ -1,489 +0,0 @@
----
-title: SQS Batch Processing (Deprecated)
-description: Utility
----
-
-!!! warning
- The SQS batch module is now deprecated and will be removed in v2 of the library. Use the [batch module](batch.md),
- and check out **[migrating to the batch library](#migrating-to-the-batch-library)** for migration instructions.
-
-The SQS batch processing utility provides a way to handle partial failures when processing batches of messages from SQS.
-The utility handles batch processing for both
-[standard](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/standard-queues.html) and
-[FIFO](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html) SQS queues.
-
-**Key Features**
-
-* Prevent successfully processed messages from being returned to SQS
-* A simple interface for individually processing messages from a batch
-
-**Background**
-
-When using SQS as a Lambda event source mapping, Lambda functions can be triggered with a batch of messages from SQS.
-If your function fails to process any message from the batch, the entire batch returns to your SQS queue, and your
-Lambda function will be triggered with the same batch again. With this utility, messages within a batch will be handled individually - only messages that were not successfully processed
-are returned to the queue.
-
-!!! warning
- While this utility lowers the chance of processing messages more than once, it is not guaranteed. We recommend implementing processing logic in an idempotent manner wherever possible.
- More details on how Lambda works with SQS can be found in the [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html)
-
-## Install
-
-Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes.
-
-=== "Maven Java 11+"
-
- ```xml hl_lines="3-7 16 18 24-27""
-
- ...
-
- software.amazon.lambda
- powertools-sqs
- {{ powertools.version }}
-
- ...
-
- ...
-
-
-
- ...
-
- dev.aspectj
- aspectj-maven-plugin
- 1.13.1
-
- 11
- 11
- 11
-
-
- software.amazon.lambda
- powertools-sqs
-
-
-
-
-
-
- compile
-
-
-
-
- ...
-
-
- ```
-
-=== "Maven Java 1.8"
-
- ```xml hl_lines="3-7 16 18 24-27"
-
- ...
-
- software.amazon.lambda
- powertools-sqs
- {{ powertools.version }}
-
- ...
-
- ...
-
-
-
- ...
-
- org.codehaus.mojo
- aspectj-maven-plugin
- 1.14.0
-
- 1.8
- 1.8
- 1.8
-
-
- software.amazon.lambda
- powertools-sqs
-
-
-
-
-
-
- compile
-
-
-
-
- ...
-
-
- ```
-
-=== "Gradle Java 11+"
-
- ```groovy hl_lines="3 11"
- plugins {
- id 'java'
- id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0'
- }
-
- repositories {
- mavenCentral()
- }
-
- dependencies {
- aspect 'software.amazon.lambda:powertools-sqs:{{ powertools.version }}'
- }
-
- sourceCompatibility = 11 // or higher
- targetCompatibility = 11 // or higher
- ```
-
-=== "Gradle Java 1.8"
-
- ```groovy hl_lines="3 11"
- plugins {
- id 'java'
- id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3'
- }
-
- repositories {
- mavenCentral()
- }
-
- dependencies {
- aspect 'software.amazon.lambda:powertools-sqs:{{ powertools.version }}'
- }
-
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
- ```
-
-## IAM Permissions
-
-This utility requires additional permissions to work as expected. Lambda functions using this utility require the `sqs:DeleteMessageBatch` permission.
-
-If you are also using [nonRetryableExceptions](#move-non-retryable-messages-to-a-dead-letter-queue) attribute, utility will need additional permission of `sqs:GetQueueAttributes` on source SQS.
-It also needs `sqs:SendMessage` and `sqs:SendMessageBatch` on configured dead letter queue.
-
-If source or dead letter queue is configured to use encryption at rest using [AWS Key Management Service (KMS)](https://aws.amazon.com/kms/), function will need additional permissions of
-`kms:GenerateDataKey` and `kms:Decrypt` on the KMS key being used for encryption. Refer [docs](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-key-management.html#compatibility-with-aws-services) for more details.
-
-Refer [example project](https://github.com/aws-samples/aws-lambda-powertools-examples/blob/main/java/SqsBatchProcessing/template.yaml#L105) for policy details example.
-
-
-## Processing messages from SQS
-
-You can use either **[SqsBatch annotation](#sqsbatch-annotation)**, or **[SqsUtils Utility API](#sqsutils-utility-api)** as a fluent API.
-
-Both have nearly the same behaviour when it comes to processing messages from the batch:
-
-* **Entire batch has been successfully processed**, where your Lambda handler returned successfully, we will let SQS delete the batch to optimize your cost
-* **Entire Batch has been partially processed successfully**, where exceptions were raised within your `SqsMessageHandler` interface implementation, we will:
- - **1)** Delete successfully processed messages from the queue by directly calling `sqs:DeleteMessageBatch`
- - **2)** If a message with a [message group ID](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagegroupid-property.html) fails,
- the processing of the batch will be stopped and the remainder of the messages will be returned to SQS.
- This behaviour [is required to handle SQS FIFO queues](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting).
- - **3)** if non retryable exceptions occur, messages resulting in configured exceptions during processing will be immediately moved to the dead letter queue associated to the source SQS queue or deleted from the source SQS queue if `deleteNonRetryableMessageFromQueue` is set to `true`.
- - **4)** Raise `SQSBatchProcessingException` to ensure failed messages return to your SQS queue
-
-The only difference is that **SqsUtils Utility API** will give you access to return from the processed messages if you need. Exception `SQSBatchProcessingException` thrown from the
-utility will have access to both successful and failed messaged along with failure exceptions.
-
-## Functional Interface SqsMessageHandler
-
-Both [annotation](#sqsbatch-annotation) and [SqsUtils Utility API](#sqsutils-utility-api) requires an implementation of functional interface `SqsMessageHandler`.
-
-This implementation is responsible for processing each individual message from the batch, and to raise an exception if unable to process any of the messages sent.
-
-**Any non-exception/successful return from your record handler function** will instruct utility to queue up each individual message for deletion.
-
-### SqsBatch annotation
-
-When using this annotation, you need provide a class implementation of `SqsMessageHandler` that will process individual messages from the batch - It should raise an exception if it is unable to process the record.
-
-All records in the batch will be passed to this handler for processing, even if exceptions are thrown - Here's the behaviour after completing the batch:
-
-* **Any successfully processed messages**, we will delete them from the queue via `sqs:DeleteMessageBatch`.
-* **if, nonRetryableExceptions attribute is used**, messages resulting in configured exceptions during processing will be immediately moved to the dead letter queue associated to the source SQS queue or deleted from the source SQS queue if `deleteNonRetryableMessageFromQueue` is set to `true`.
-* **Any unprocessed messages detected**, we will raise `SQSBatchProcessingException` to ensure failed messages return to your SQS queue.
-
-!!! warning
- You will not have access to the **processed messages** within the Lambda Handler - all processing logic will and should be performed by the implemented `#!java SqsMessageHandler#process()` function.
-
-=== "AppSqsEvent.java"
-
- ```java hl_lines="7"
- import software.amazon.lambda.powertools.sqs.SqsBatch;
- import software.amazon.lambda.powertools.sqs.SqsMessageHandler;
- import software.amazon.lambda.powertools.sqs.SqsUtils;
-
- public class AppSqsEvent implements RequestHandler {
- @Override
- @SqsBatch(SampleMessageHandler.class)
- public String handleRequest(SQSEvent input, Context context) {
- return "{\"statusCode\": 200}";
- }
-
- public class SampleMessageHandler implements SqsMessageHandler {
-
- @Override
- public String process(SQSMessage message) {
- // This will be called for each individual message from a batch
- // It should raise an exception if the message was not processed successfully
- String returnVal = doSomething(message.getBody());
- return returnVal;
- }
- }
- }
- ```
-
-=== "AppSqsEventWithNonRetryableExceptions.java"
-
- ```java hl_lines="7 21"
- import software.amazon.lambda.powertools.sqs.SqsBatch;
- import software.amazon.lambda.powertools.sqs.SqsMessageHandler;
- import software.amazon.lambda.powertools.sqs.SqsUtils;
-
- public class AppSqsEvent implements RequestHandler {
- @Override
- @SqsBatch(value = SampleMessageHandler.class, nonRetryableExceptions = {IllegalArgumentException.class})
- public String handleRequest(SQSEvent input, Context context) {
- return "{\"statusCode\": 200}";
- }
-
- public class SampleMessageHandler implements SqsMessageHandler {
-
- @Override
- public String process(SQSMessage message) {
- // This will be called for each individual message from a batch
- // It should raise an exception if the message was not processed successfully
- String returnVal = doSomething(message.getBody());
-
- if(/**Business validation failure**/) {
- throw new IllegalArgumentException("Failed business validation. No point of retrying. Move me to DLQ." + message.getMessageId());
- }
-
- return returnVal;
- }
- }
- }
- ```
-
-
-### SqsUtils Utility API
-
-If you require access to the result of processed messages, you can use this utility. The result from calling **`#!java SqsUtils#batchProcessor()`** on the context manager will be a list of all the return values
-from your **`#!java SqsMessageHandler#process()`** function.
-
-You can also use the utility in functional way by providing inline implementation of functional interface **`#!java SqsMessageHandler#process()`**
-
-
-=== "Utility API"
-
- ```java hl_lines="4"
- public class AppSqsEvent implements RequestHandler> {
- @Override
- public List handleRequest(SQSEvent input, Context context) {
- List returnValues = SqsUtils.batchProcessor(input, SampleMessageHandler.class);
-
- return returnValues;
- }
-
- public class SampleMessageHandler implements SqsMessageHandler {
-
- @Override
- public String process(SQSMessage message) {
- // This will be called for each individual message from a batch
- // It should raise an exception if the message was not processed successfully
- String returnVal = doSomething(message.getBody());
- return returnVal;
- }
- }
- }
- ```
-
-=== "Function implementation"
-
- ```java hl_lines="5 6 7 8 9 10"
- public class AppSqsEvent implements RequestHandler> {
-
- @Override
- public List handleRequest(SQSEvent input, Context context) {
- List returnValues = SqsUtils.batchProcessor(input, (message) -> {
- // This will be called for each individual message from a batch
- // It should raise an exception if the message was not processed successfully
- String returnVal = doSomething(message.getBody());
- return returnVal;
- });
-
- return returnValues;
- }
- }
- ```
-
-## Passing custom SqsClient
-
-If you need to pass custom SqsClient such as region to the SDK, you can pass your own `SqsClient` to be used by utility either for
-**[SqsBatch annotation](#sqsbatch-annotation)**, or **[SqsUtils Utility API](#sqsutils-utility-api)**.
-
-=== "App.java"
-
- ```java hl_lines="3 4"
- public class AppSqsEvent implements RequestHandler> {
- static {
- SqsUtils.overrideSqsClient(SqsClient.builder()
- .build());
- }
-
- @Override
- public List handleRequest(SQSEvent input, Context context) {
- List returnValues = SqsUtils.batchProcessor(input, SampleMessageHandler.class);
-
- return returnValues;
- }
-
- public class SampleMessageHandler implements SqsMessageHandler {
-
- @Override
- public String process(SQSMessage message) {
- // This will be called for each individual message from a batch
- // It should raise an exception if the message was not processed successfully
- String returnVal = doSomething(message.getBody());
- return returnVal;
- }
- }
- }
- ```
-
-## Suppressing exceptions
-
-If you want to disable the default behavior where `SQSBatchProcessingException` is raised if there are any exception, you can pass the `suppressException` boolean argument.
-
-=== "Within SqsBatch annotation"
-
- ```java hl_lines="2"
- @Override
- @SqsBatch(value = SampleMessageHandler.class, suppressException = true)
- public String handleRequest(SQSEvent input, Context context) {
- return "{\"statusCode\": 200}";
- }
- ```
-
-=== "Within SqsUtils Utility API"
-
- ```java hl_lines="3"
- @Override
- public List handleRequest(SQSEvent input, Context context) {
- List returnValues = SqsUtils.batchProcessor(input, true, SampleMessageHandler.class);
-
- return returnValues;
- }
- ```
-
-## Move non retryable messages to a dead letter queue
-
-If you want certain exceptions to be treated as permanent failures during batch processing, i.e. exceptions where the result of retrying will
-always be a failure and want these can be immediately moved to the dead letter queue associated to the source SQS queue, you can use `SqsBatch#nonRetryableExceptions()`
-to configure such exceptions.
-
-If you want such messages to be deleted instead, set `SqsBatch#deleteNonRetryableMessageFromQueue()` to `true`. By default, its value is `false`.
-
-Same capability is also provided by [SqsUtils Utility API](#sqsutils-utility-api).
-
-!!! info
- Make sure the lambda function has required permissions needed by utility. Refer [this section](#iam-permissions).
-
-=== "SqsBatch annotation"
-
- ```java hl_lines="7 21"
- import software.amazon.lambda.powertools.sqs.SqsBatch;
- import software.amazon.lambda.powertools.sqs.SqsMessageHandler;
- import software.amazon.lambda.powertools.sqs.SqsUtils;
-
- public class AppSqsEvent implements RequestHandler {
- @Override
- @SqsBatch(value = SampleMessageHandler.class, nonRetryableExceptions = {IllegalArgumentException.class})
- public String handleRequest(SQSEvent input, Context context) {
- return "{\"statusCode\": 200}";
- }
-
- public class SampleMessageHandler implements SqsMessageHandler {
-
- @Override
- public String process(SQSMessage message) {
- // This will be called for each individual message from a batch
- // It should raise an exception if the message was not processed successfully
- String returnVal = doSomething(message.getBody());
-
- if(/**Business validation failure**/) {
- throw new IllegalArgumentException("Failed business validation. No point of retrying. Move me to DLQ." + message.getMessageId());
- }
-
- return returnVal;
- }
- }
- }
- ```
-
-=== "SqsBatch API"
-
- ```java hl_lines="9 23"
- import software.amazon.lambda.powertools.sqs.SqsBatch;
- import software.amazon.lambda.powertools.sqs.SqsMessageHandler;
- import software.amazon.lambda.powertools.sqs.SqsUtils;
-
- public class AppSqsEvent implements RequestHandler {
- @Override
- public String handleRequest(SQSEvent input, Context context) {
-
- SqsUtils.batchProcessor(input, BatchProcessor.class, IllegalArgumentException.class);
-
- return "{\"statusCode\": 200}";
- }
-
- public class SampleMessageHandler implements SqsMessageHandler {
-
- @Override
- public String process(SQSMessage message) {
- // This will be called for each individual message from a batch
- // It should raise an exception if the message was not processed successfully
- String returnVal = doSomething(message.getBody());
-
- if(/**Business validation failure**/) {
- throw new IllegalArgumentException("Failed business validation. No point of retrying. Move me to DLQ." + message.getMessageId());
- }
-
- return returnVal;
- }
- }
- }
- ```
-
-## Migrating to the Batch Library
-The [batch processing library](batch.md) provides a way to process messages and gracefully handle partial failures for
-SQS, Kinesis Streams, and DynamoDB Streams batch sources. In comparison the legacy SQS Batch library, it relies on
-[Lambda partial batch responses](https://aws.amazon.com/about-aws/whats-new/2021/11/aws-lambda-partial-batch-response-sqs-event-source/),
-which allows the library to provide a simpler, reliable interface for processing batches.
-
-In order to get started, check out the [processing messages from SQS](batch/#processing-messages-from-sqs) documentation.
-In most cases, you will simply be able to retain your existing batch message handler function, and wrap it with the new
-batch processing interface. Unlike this module, As the batch processor uses *partial batch responses* to communicate to
-Lambda which messages have been processed and must be removed from the queue, the return of the handler's process function
-must be returned to Lambda.
-
-The new library also no longer requires the `SQS:DeleteMessage` action on the Lambda function's role policy, as Lambda
-itself now manages removal of messages from the queue.
-
-!!! info
- Some tuneables from this library are no longer provided.
-
- * **Non-retryable Exceptions** - there is no mechanism to indicate in a partial batch response that a particular message
- should not be retried and instead moved to DLQ - a message either succeeds, or fails and is retried. A message
- will be moved to the DLQ once the normal retry process has expired.
- * **Suppress Exception** - The new batch processor does not throw an exception on failure of a handler. Instead,
- its result must be returned by your code from your message handler to Lambda, so that Lambda can manage
- the completed messages and retry behaviour.
\ No newline at end of file
diff --git a/docs/utilities/sqs_large_message_handling.md b/docs/utilities/sqs_large_message_handling.md
deleted file mode 100644
index 0924d01cf..000000000
--- a/docs/utilities/sqs_large_message_handling.md
+++ /dev/null
@@ -1,296 +0,0 @@
----
-title: SQS Large Message Handling (Deprecated)
-description: Utility
----
-
-!!! warning
- This module is now deprecated and will be removed in version 2.
- See [Large Message Handling](large_messages.md) and
- [the migration guide](http://localhost:8000/lambda-java/utilities/large_messages/#migration-from-the-sqs-large-message-utility)
- for the new module (`powertools-large-messages`) documentation
-
-The large message handling utility handles SQS messages which have had their payloads
-offloaded to S3 due to them being larger than the SQS maximum.
-
-The utility automatically retrieves messages which have been offloaded to S3 using the
-[amazon-sqs-java-extended-client-lib](https://github.com/awslabs/amazon-sqs-java-extended-client-lib)
-client library. Once the message payloads have been processed successful the
-utility can delete the message payloads from S3.
-
-This utility is compatible with versions *[1.1.0+](https://github.com/awslabs/amazon-sqs-java-extended-client-lib)* of
-amazon-sqs-java-extended-client-lib.
-
-=== "Maven"
-
-```xml
-
-
- com.amazonaws
- amazon-sqs-java-extended-client-lib
- 1.1.0
-
-```
-=== "Gradle"
-
- ```groovy
- dependencies {
- implementation 'com.amazonaws:amazon-sqs-java-extended-client-lib:1.1.0'
- }
- ```
-
-## Install
-Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes.
-
-=== "Maven Java 11+"
-
-```xml hl_lines="3-7 16 18 24-27"
-
-...
-
-software.amazon.lambda
-powertools-sqs
-{{ powertools.version }}
-
-...
-
-...
-
-
-
-...
-
-dev.aspectj
-aspectj-maven-plugin
-1.13.1
-
-11
-11
-11
-
-
-software.amazon.lambda
-powertools-sqs
-
-
-
-
-
-
-compile
-
-
-
-
-...
-
-
-```
-
-=== "Maven Java 1.8"
-
- ```xml hl_lines="3-7 16 18 24-27"
-
- ...
-
- software.amazon.lambda
- powertools-sqs
- {{ powertools.version }}
-
- ...
-
- ...
-
-
-
- ...
-
- org.codehaus.mojo
- aspectj-maven-plugin
- 1.14.0
-
- 1.8
- 1.8
- 1.8
-
-
- software.amazon.lambda
- powertools-sqs
-
-
-
-
-
-
- compile
-
-
-
-
- ...
-
-
- ```
-
-=== "Gradle Java 11+"
-
- ```groovy hl_lines="3 11"
- plugins {
- id 'java'
- id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0'
- }
-
- repositories {
- mavenCentral()
- }
-
- dependencies {
- aspect 'software.amazon.lambda:powertools-sqs:{{ powertools.version }}'
- }
-
- sourceCompatibility = 11 // or higher
- targetCompatibility = 11 // or higher
- ```
-
-=== "Gradle Java 1.8"
-
- ```groovy hl_lines="3 11"
- plugins {
- id 'java'
- id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3'
- }
-
- repositories {
- mavenCentral()
- }
-
- dependencies {
- aspect 'software.amazon.lambda:powertools-sqs:{{ powertools.version }}'
- }
-
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
- ```
-
-## Lambda handler
-
-The annotation `@SqsLargeMessage` should be used with the handleRequest method of a class
-which implements `com.amazonaws.services.lambda.runtime.RequestHandler` with
-`com.amazonaws.services.lambda.runtime.events.SQSEvent` as the first parameter.
-
-=== "SqsMessageHandler.java"
-
- ```java hl_lines="6"
- import software.amazon.lambda.powertools.sqs.SqsLargeMessage;
-
- public class SqsMessageHandler implements RequestHandler {
-
- @Override
- @SqsLargeMessage
- public String handleRequest(SQSEvent sqsEvent, Context context) {
- // process messages
-
- return "ok";
- }
- }
- ```
-
-`@SqsLargeMessage` creates a default S3 Client `AmazonS3 amazonS3 = AmazonS3ClientBuilder.defaultClient()`.
-
-!!! tip
-When the Lambda function is invoked with an event from SQS, each received record
-in the SQSEvent is checked to see to validate if it is offloaded to S3.
-If it does then `getObject(bucket, key)` will be called, and the payload retrieved.
-If there is an error during this process then the function will fail with a `FailedProcessingLargePayloadException`
-exception.
-
- If the request handler method returns without error then each payload will be
- deleted from S3 using `deleteObject(bucket, key)`
-
-To disable deletion of payloads setting the following annotation parameter:
-
-=== "Disable payload deletion"
-
- ```java hl_lines="3"
- import software.amazon.lambda.powertools.sqs.SqsLargeMessage;
-
- @SqsLargeMessage(deletePayloads=false)
- public class SqsMessageHandler implements RequestHandler {
-
- }
- ```
-
-## Utility
-
-If you want to avoid using annotation and have control over error that can happen during payload enrichment use `SqsUtils.enrichedMessageFromS3()`.
-It provides you access with a list of `SQSMessage` object enriched from S3 payload.
-
-Original `SQSEvent` object is never mutated. You can also control if the S3 payload should be deleted after successful
-processing.
-
-=== "Functional API without annotation"
-
- ```java hl_lines="9 10 11 14 15 16 17 18 19 20 21 22 27 28 29"
- import software.amazon.lambda.powertools.sqs.SqsLargeMessage;
- import software.amazon.lambda.powertools.sqs.SqsUtils;
-
- public class SqsMessageHandler implements RequestHandler {
-
- @Override
- public String handleRequest(SQSEvent sqsEvent, Context context) {
-
- Map sqsMessage = SqsUtils.enrichedMessageFromS3(sqsEvent, sqsMessages -> {
- // Some business logic
- Map someBusinessLogic = new HashMap<>();
- someBusinessLogic.put("Message", sqsMessages.get(0).getBody());
- return someBusinessLogic;
- });
-
- // Do not delete payload after processing.
- Map sqsMessage = SqsUtils.enrichedMessageFromS3(sqsEvent, false, sqsMessages -> {
- // Some business logic
- Map someBusinessLogic = new HashMap<>();
- someBusinessLogic.put("Message", sqsMessages.get(0).getBody());
- return someBusinessLogic;
- });
-
- // Better control over exception during enrichment
- try {
- // Do not delete payload after processing.
- SqsUtils.enrichedMessageFromS3(sqsEvent, false, sqsMessages -> {
- // Some business logic
- });
- } catch (FailedProcessingLargePayloadException e) {
- // handle any exception.
- }
-
- return "ok";
- }
- }
- ```
-
-## Overriding the default S3Client
-
-If you require customisations to the default S3Client, you can create your own `S3Client` and pass it to be used by utility either for
-**[SqsLargeMessage annotation](#lambda-handler)**, or **[SqsUtils Utility API](#utility)**.
-
-=== "App.java"
-
- ```java hl_lines="4 5 11"
- import software.amazon.lambda.powertools.sqs.SqsLargeMessage;
-
- static {
- SqsUtils.overrideS3Client(S3Client.builder()
- .build());
- }
-
- public class SqsMessageHandler implements RequestHandler {
-
- @Override
- @SqsLargeMessage
- public String handleRequest(SQSEvent sqsEvent, Context context) {
- // process messages
-
- return "ok";
- }
- }
- ```
\ No newline at end of file
diff --git a/examples/pom.xml b/examples/pom.xml
index 5d19a20fb..0cd62e326 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -33,7 +33,6 @@
powertools-examples-idempotency
powertools-examples-parameters
powertools-examples-serialization
- powertools-examples-sqs
powertools-examples-batch
powertools-examples-validation
powertools-examples-cloudformation
diff --git a/examples/powertools-examples-sqs/README.md b/examples/powertools-examples-sqs/README.md
deleted file mode 100644
index 45f4a4a74..000000000
--- a/examples/powertools-examples-sqs/README.md
+++ /dev/null
@@ -1,56 +0,0 @@
-# Powertools for AWS Lambda (Java) - SQS Batch Processing Example
-
-This project contains an example of Lambda function using the batch processing utilities module of Powertools for AWS Lambda (Java).
-For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda/java/utilities/batch/).
-
-The project contains two functions:
-
-* [SqsMessageSender](src/main/java/org/demo/sqs/SqsMessageSender.java) - Sends a set of messages to an SQS queue.
-This function is triggered every 5 minutes by an EventBridge schedule rule.
-* [SqsPoller](src/main/java/org/demo/sqs/SqsPoller.java) - Listens to the same queue, processing items off in batches
-
-The poller intentionally fails intermittently processing messages to demonstrate the replay behaviour of the batch
-module:
-
-
-
-SqsPoller.java
-
-[SqsPoller.java:43](src/main/java/org/demo/sqs/SqsPoller.java)
-
-```java
- public String process(SQSMessage message) {
- log.info("Processing message with id {}", message.getMessageId());
-
- int nextInt = random.nextInt(100);
-
- if(nextInt <= 10) {
- log.info("Randomly picked message with id {} as business validation failure.", message.getMessageId());
- throw new IllegalArgumentException("Failed business validation. No point of retrying. Move me to DLQ." + message.getMessageId());
- }
-
- if(nextInt > 90) {
- log.info("Randomly picked message with id {} as intermittent failure.", message.getMessageId());
- throw new RuntimeException("Failed due to intermittent issue. Will be sent back for retry." + message.getMessageId());
- }
-
- return "Success";
- }
-```
-
-
-
-## Deploy the sample application
-
-This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting
-started with SAM in [the examples directory](../README.md)
-
-## Test the application
-
-As the test is pushing through a batch every 5 minutes, we can simply watch the logs to see the batches being processed:
-
-```bash
- sam logs --tail --stack-name $MY_STACK
-```
-
-As the handler intentionally introduces intermittent failures, we should expect to see error messages too!
diff --git a/examples/powertools-examples-sqs/events/event.json b/examples/powertools-examples-sqs/events/event.json
deleted file mode 100644
index 3822fadaa..000000000
--- a/examples/powertools-examples-sqs/events/event.json
+++ /dev/null
@@ -1,63 +0,0 @@
-{
- "body": "{\"message\": \"hello world\"}",
- "resource": "/{proxy+}",
- "path": "/path/to/resource",
- "httpMethod": "POST",
- "isBase64Encoded": false,
- "queryStringParameters": {
- "foo": "bar"
- },
- "pathParameters": {
- "proxy": "/path/to/resource"
- },
- "stageVariables": {
- "baz": "qux"
- },
- "headers": {
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
- "Accept-Encoding": "gzip, deflate, sdch",
- "Accept-Language": "en-US,en;q=0.8",
- "Cache-Control": "max-age=0",
- "CloudFront-Forwarded-Proto": "https",
- "CloudFront-Is-Desktop-Viewer": "true",
- "CloudFront-Is-Mobile-Viewer": "false",
- "CloudFront-Is-SmartTV-Viewer": "false",
- "CloudFront-Is-Tablet-Viewer": "false",
- "CloudFront-Viewer-Country": "US",
- "Host": "1234567890.execute-api.us-east-1.amazonaws.com",
- "Upgrade-Insecure-Requests": "1",
- "User-Agent": "Custom User Agent String",
- "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)",
- "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==",
- "X-Forwarded-For": "127.0.0.1, 127.0.0.2",
- "X-Forwarded-Port": "443",
- "X-Forwarded-Proto": "https"
- },
- "requestContext": {
- "accountId": "123456789012",
- "resourceId": "123456",
- "stage": "prod",
- "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
- "requestTime": "09/Apr/2015:12:34:56 +0000",
- "requestTimeEpoch": 1428582896000,
- "identity": {
- "cognitoIdentityPoolId": null,
- "accountId": null,
- "cognitoIdentityId": null,
- "caller": null,
- "accessKey": null,
- "sourceIp": "127.0.0.1",
- "cognitoAuthenticationType": null,
- "cognitoAuthenticationProvider": null,
- "userArn": null,
- "userAgent": "Custom User Agent String",
- "user": null
- },
- "path": "/prod/path/to/resource",
- "resourcePath": "/{proxy+}",
- "httpMethod": "POST",
- "apiId": "1234567890",
- "protocol": "HTTP/1.1"
- }
- }
-
\ No newline at end of file
diff --git a/examples/powertools-examples-sqs/pom.xml b/examples/powertools-examples-sqs/pom.xml
deleted file mode 100644
index aeffcac40..000000000
--- a/examples/powertools-examples-sqs/pom.xml
+++ /dev/null
@@ -1,196 +0,0 @@
-
- 4.0.0
- software.amazon.lambda.examples
- 1.17.0-SNAPSHOT
- powertools-examples-sqs
- jar
- Powertools for AWS Lambda (Java) library Examples - SQS
-
-
- 2.20.0
- 1.8
- 1.8
- true
-
-
-
-
- software.amazon.lambda
- powertools-logging
- ${project.version}
-
-
- software.amazon.lambda
- powertools-sqs
- ${project.version}
-
-
- software.amazon.awssdk
- url-connection-client
- 2.20.119
-
-
- com.amazonaws
- aws-lambda-java-core
- 1.2.2
-
-
- com.amazonaws
- aws-lambda-java-events
- 3.11.2
-
-
- org.apache.logging.log4j
- log4j-core
- ${log4j.version}
-
-
- org.apache.logging.log4j
- log4j-api
- ${log4j.version}
-
-
- com.fasterxml.jackson.datatype
- jackson-datatype-joda
- 2.15.2
-
-
-
- junit
- junit
- 4.13.2
- test
-
-
-
-
-
-
- dev.aspectj
- aspectj-maven-plugin
- 1.13.1
-
- ${maven.compiler.source}
- ${maven.compiler.target}
- ${maven.compiler.target}
-
-
- software.amazon.lambda
- powertools-logging
-
-
- software.amazon.lambda
- powertools-sqs
-
-
-
-
-
-
- compile
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.5.0
-
-
- package
-
- shade
-
-
-
-
-
-
-
-
-
-
-
- com.github.edwgiz
- maven-shade-plugin.log4j2-cachefile-transformer
- 2.15
-
-
-
-
-
-
-
-
- jdk8
-
- (,11)
-
-
- 1.9.7
-
-
-
-
- org.aspectj
- aspectjtools
- ${aspectj.version}
-
-
-
-
-
-
-
- dev.aspectj
- aspectj-maven-plugin
- ${aspectj.plugin.version}
-
- ${maven.compiler.source}
- ${maven.compiler.target}
- ${maven.compiler.target}
-
-
- software.amazon.lambda
- powertools-logging
-
-
- software.amazon.lambda
- powertools-sqs
-
-
-
-
-
-
- compile
- test-compile
-
-
-
-
-
-
- org.aspectj
- aspectjtools
- ${aspectj.version}
-
-
-
-
-
-
-
-
-
diff --git a/examples/powertools-examples-sqs/src/main/java/org/demo/sqs/SqsMessageSender.java b/examples/powertools-examples-sqs/src/main/java/org/demo/sqs/SqsMessageSender.java
deleted file mode 100644
index 701d6808f..000000000
--- a/examples/powertools-examples-sqs/src/main/java/org/demo/sqs/SqsMessageSender.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.demo.sqs;
-
-import static java.util.stream.Collectors.toList;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.ScheduledEvent;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.datatype.joda.JodaModule;
-import java.security.SecureRandom;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.stream.IntStream;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
-import software.amazon.awssdk.services.sqs.SqsClient;
-import software.amazon.awssdk.services.sqs.model.MessageAttributeValue;
-import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequest;
-import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequestEntry;
-import software.amazon.awssdk.services.sqs.model.SendMessageBatchResponse;
-import software.amazon.lambda.powertools.logging.Logging;
-import software.amazon.lambda.powertools.logging.LoggingUtils;
-
-public class SqsMessageSender implements RequestHandler {
-
- private static final Logger log = LogManager.getLogger(SqsMessageSender.class);
-
- private static final SqsClient sqsClient = SqsClient.builder()
- .httpClient(UrlConnectionHttpClient.create())
- .build();
-
- private static final Random random = new SecureRandom();
-
- private static final ObjectMapper objectMapper;
-
- static {
- objectMapper = new ObjectMapper();
- objectMapper.registerModule(new JodaModule());
- LoggingUtils.defaultObjectMapper(objectMapper);
- }
-
- @Logging(logEvent = true)
- public String handleRequest(final ScheduledEvent input, final Context context) {
- String queueUrl = System.getenv("QUEUE_URL");
-
- // Push 5 messages on each invoke.
- List batchRequestEntries = IntStream.range(0, 5)
- .mapToObj(value ->
- {
- Map attributeValueHashMap = new HashMap<>();
- attributeValueHashMap.put("Key" + value, MessageAttributeValue.builder()
- .dataType("String")
- .stringValue("Value" + value)
- .build());
-
- byte[] array = new byte[7];
- random.nextBytes(array);
-
- return SendMessageBatchRequestEntry.builder()
- .messageAttributes(attributeValueHashMap)
- .id(input.getId() + value)
- .messageBody("Sample Message " + value)
- .build();
- }).collect(toList());
-
- SendMessageBatchResponse sendMessageBatchResponse = sqsClient.sendMessageBatch(SendMessageBatchRequest.builder()
- .queueUrl(queueUrl)
- .entries(batchRequestEntries)
- .build());
-
- log.info("Sent Message {}", sendMessageBatchResponse);
-
- return "Success";
- }
-}
\ No newline at end of file
diff --git a/examples/powertools-examples-sqs/src/main/java/org/demo/sqs/SqsPoller.java b/examples/powertools-examples-sqs/src/main/java/org/demo/sqs/SqsPoller.java
deleted file mode 100644
index 9ad5c7868..000000000
--- a/examples/powertools-examples-sqs/src/main/java/org/demo/sqs/SqsPoller.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.demo.sqs;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import java.security.SecureRandom;
-import java.util.Random;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
-import software.amazon.awssdk.services.sqs.SqsClient;
-import software.amazon.lambda.powertools.logging.Logging;
-import software.amazon.lambda.powertools.sqs.SqsBatch;
-import software.amazon.lambda.powertools.sqs.SqsMessageHandler;
-import software.amazon.lambda.powertools.sqs.SqsUtils;
-
-/**
- * Handler for requests to Lambda function.
- */
-public class SqsPoller implements RequestHandler {
-
- static {
- // https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/lambda-optimize-starttime.html
- SqsUtils.overrideSqsClient(SqsClient.builder()
- .httpClient(UrlConnectionHttpClient.create())
- .build());
- }
-
- Logger log = LogManager.getLogger(SqsPoller.class);
- Random random = new SecureRandom();
-
- @SqsBatch(value = BatchProcessor.class, nonRetryableExceptions = {IllegalArgumentException.class})
- @Logging(logEvent = true)
- public String handleRequest(final SQSEvent input, final Context context) {
- return "Success";
- }
-
- private class BatchProcessor implements SqsMessageHandler {
- @Override
- public String process(SQSMessage message) {
- log.info("Processing message with id {}", message.getMessageId());
-
- int nextInt = random.nextInt(100);
-
- if (nextInt <= 10) {
- log.info("Randomly picked message with id {} as business validation failure.", message.getMessageId());
- throw new IllegalArgumentException(
- "Failed business validation. No point of retrying. Move me to DLQ." + message.getMessageId());
- }
-
- if (nextInt > 90) {
- log.info("Randomly picked message with id {} as intermittent failure.", message.getMessageId());
- throw new RuntimeException(
- "Failed due to intermittent issue. Will be sent back for retry." + message.getMessageId());
- }
-
- return "Success";
- }
- }
-}
\ No newline at end of file
diff --git a/examples/powertools-examples-sqs/src/main/resources/log4j2.xml b/examples/powertools-examples-sqs/src/main/resources/log4j2.xml
deleted file mode 100644
index e1fd14cea..000000000
--- a/examples/powertools-examples-sqs/src/main/resources/log4j2.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/powertools-examples-sqs/template.yaml b/examples/powertools-examples-sqs/template.yaml
deleted file mode 100644
index 50327de18..000000000
--- a/examples/powertools-examples-sqs/template.yaml
+++ /dev/null
@@ -1,148 +0,0 @@
-AWSTemplateFormatVersion: '2010-09-09'
-Transform: AWS::Serverless-2016-10-31
-Description: >
- sqs batch processing demo
-
-Globals:
- Function:
- Timeout: 20
- Runtime: java11
- MemorySize: 512
- Tracing: Active
- Environment:
- Variables:
- # Powertools for AWS Lambda (Java) env vars: https://docs.powertools.aws.dev/lambda/java/#environment-variables
- POWERTOOLS_LOG_LEVEL: INFO
- POWERTOOLS_LOGGER_SAMPLE_RATE: 0.1
- POWERTOOLS_LOGGER_LOG_EVENT: true
-
-Resources:
- CustomerKey:
- Type: AWS::KMS::Key
- Properties:
- Description: KMS key for encrypted queues
- Enabled: true
- KeyPolicy:
- Version: '2012-10-17'
- Statement:
- - Sid: Enable IAM User Permissions
- Effect: Allow
- Principal:
- AWS: !Sub 'arn:aws:iam::${AWS::AccountId}:root'
- Action: 'kms:*'
- Resource: '*'
- - Sid: Allow use of the key
- Effect: Allow
- Principal:
- Service: lambda.amazonaws.com
- Action:
- - kms:Decrypt
- - kms:GenerateDataKey
- Resource: '*'
-
- CustomerKeyAlias:
- Type: AWS::KMS::Alias
- Properties:
- AliasName: alias/sqs-key
- TargetKeyId: !Ref CustomerKey
-
- DemoDlqSqsQueue:
- Type: AWS::SQS::Queue
- Properties:
- KmsMasterKeyId: !Ref CustomerKey
-
- DemoSqsQueue:
- Type: AWS::SQS::Queue
- Properties:
- RedrivePolicy:
- deadLetterTargetArn:
- Fn::GetAtt:
- - "DemoDlqSqsQueue"
- - "Arn"
- maxReceiveCount: 2
- KmsMasterKeyId: !Ref CustomerKey
-
- DemoSQSSenderFunction:
- Type: AWS::Serverless::Function
- Properties:
- CodeUri: .
- Handler: org.demo.sqs.SqsMessageSender::handleRequest
- Environment:
- Variables:
- POWERTOOLS_SERVICE_NAME: sqs-demo
- QUEUE_URL: !Ref DemoSqsQueue
- Policies:
- - Statement:
- - Sid: SQSSendMessageBatch
- Effect: Allow
- Action:
- - sqs:SendMessageBatch
- - sqs:SendMessage
- Resource: !GetAtt DemoSqsQueue.Arn
- - Sid: SQSKMSKey
- Effect: Allow
- Action:
- - kms:GenerateDataKey
- - kms:Decrypt
- Resource: !GetAtt CustomerKey.Arn
- Events:
- CWSchedule:
- Type: Schedule
- Properties:
- Schedule: 'rate(5 minutes)'
- Name: !Join ["-", ["message-producer-schedule", !Select [0, !Split [-, !Select [2, !Split [/, !Ref AWS::StackId ]]]]]]
- Description: Produce message to SQS via a Lambda function
- Enabled: true
-
- DemoSQSConsumerFunction:
- Type: AWS::Serverless::Function
- Properties:
- CodeUri: .
- Handler: org.demo.sqs.SqsPoller::handleRequest
- Environment:
- Variables:
- POWERTOOLS_SERVICE_NAME: sqs-demo
- Policies:
- - Statement:
- - Sid: SQSDeleteGetAttribute
- Effect: Allow
- Action:
- - sqs:DeleteMessageBatch
- - sqs:GetQueueAttributes
- Resource: !GetAtt DemoSqsQueue.Arn
- - Sid: SQSSendMessageBatch
- Effect: Allow
- Action:
- - sqs:SendMessageBatch
- - sqs:SendMessage
- Resource: !GetAtt DemoDlqSqsQueue.Arn
- - Sid: SQSKMSKey
- Effect: Allow
- Action:
- - kms:GenerateDataKey
- - kms:Decrypt
- Resource: !GetAtt CustomerKey.Arn
- Events:
- MySQSEvent:
- Type: SQS
- Properties:
- Queue: !GetAtt DemoSqsQueue.Arn
- BatchSize: 2
- MaximumBatchingWindowInSeconds: 300
-
-Outputs:
- DemoSqsQueue:
- Description: "ARN for main SQS queue"
- Value: !GetAtt DemoSqsQueue.Arn
- DemoDlqSqsQueue:
- Description: "ARN for DLQ"
- Value: !GetAtt DemoDlqSqsQueue.Arn
- DemoSQSSenderFunction:
- Description: "Sender SQS Lambda Function ARN"
- Value: !GetAtt DemoSQSSenderFunction.Arn
- DemoSQSConsumerFunction:
- Description: "Consumer SQS Lambda Function ARN"
- Value: !GetAtt DemoSQSConsumerFunction.Arn
- DemoSQSConsumerFunctionRole:
- Description: "Implicit IAM Role created for SQS Lambda Function ARN"
- Value: !GetAtt DemoSQSConsumerFunctionRole.Arn
diff --git a/mkdocs.yml b/mkdocs.yml
index d54ece508..62d8d75ce 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -18,9 +18,6 @@ nav:
- utilities/validation.md
- utilities/custom_resources.md
- utilities/serialization.md
- - Deprecated:
- - utilities/sqs_large_message_handling.md
- - utilities/sqs_batch.md
- Processes:
- processes/maintainers.md
diff --git a/pom.xml b/pom.xml
index 8c9e540f5..bebb2493f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,11 +45,9 @@
powertools-serialization
powertools-logging
powertools-tracing
- powertools-sqs
powertools-metrics
powertools-parameters
powertools-validation
- powertools-test-suite
powertools-cloudformation
powertools-idempotency
powertools-large-messages
diff --git a/powertools-sqs/pom.xml b/powertools-sqs/pom.xml
deleted file mode 100644
index c21943fba..000000000
--- a/powertools-sqs/pom.xml
+++ /dev/null
@@ -1,144 +0,0 @@
-
-
-
-
- 4.0.0
-
- powertools-sqs
- jar
-
-
- powertools-parent
- software.amazon.lambda
- 1.17.0-SNAPSHOT
-
-
- Powertools for AWS Lambda (Java) library SQS
-
- Deprecated: Batch processing is now handled in powertools-batch and large messages in powertools-large-messages modules.
- A suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray, structured logging and creating custom metrics asynchronously easier.
-
- https://aws.amazon.com/lambda/
-
- GitHub Issues
- https://github.com/aws-powertools/powertools-lambda-java/issues
-
-
- https://github.com/aws-powertools/powertools-lambda-java.git
-
-
-
- Powertools for AWS Lambda team
- Amazon Web Services
- https://aws.amazon.com/
-
-
-
-
-
- ossrh
- https://aws.oss.sonatype.org/content/repositories/snapshots
-
-
-
-
-
- software.amazon.lambda
- powertools-core
-
-
- com.amazonaws
- aws-lambda-java-tests
-
-
- com.amazonaws
- aws-lambda-java-core
-
-
- software.amazon.payloadoffloading
- payloadoffloading-common
-
-
- com.amazonaws
- aws-lambda-java-events
-
-
- software.amazon.awssdk
- sqs
-
-
- software.amazon.awssdk
- s3
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
-
- org.aspectj
- aspectjrt
-
-
-
-
- org.junit.jupiter
- junit-jupiter-api
- test
-
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
-
- org.junit.jupiter
- junit-jupiter-params
- test
-
-
- org.apache.commons
- commons-lang3
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.aspectj
- aspectjweaver
- test
-
-
- org.assertj
- assertj-core
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
-
-
-
-
\ No newline at end of file
diff --git a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SQSBatchProcessingException.java b/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SQSBatchProcessingException.java
deleted file mode 100644
index 7adc2afe5..000000000
--- a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SQSBatchProcessingException.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static java.util.Collections.unmodifiableList;
-import static java.util.stream.Collectors.joining;
-
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * When one or more {@link SQSMessage} fails and if any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)}
- * during processing of a messages, this exception is with all the details of successful and failed messages.
- *
- *
- *
- * This exception can be thrown form:
- *
- * {@link SqsBatch}
- * {@link SqsUtils#batchProcessor(SQSEvent, Class)}
- * {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
- * {@link SqsUtils#batchProcessor(SQSEvent, SqsMessageHandler)}
- * {@link SqsUtils#batchProcessor(SQSEvent, boolean, SqsMessageHandler)}
- *
- *
- */
-public class SQSBatchProcessingException extends RuntimeException {
-
- private final List exceptions;
- private final List failures;
- private final List returnValues;
-
- public SQSBatchProcessingException(final List exceptions,
- final List failures,
- final List successReturns) {
- super(exceptions.stream()
- .map(Throwable::toString)
- .collect(joining("\n")));
-
- this.exceptions = new ArrayList<>(exceptions);
- this.failures = new ArrayList<>(failures);
- this.returnValues = new ArrayList<>(successReturns);
- }
-
- /**
- * Details for exceptions that occurred while processing messages in {@link SqsMessageHandler#process(SQSMessage)}
- *
- * @return List of exceptions that occurred while processing messages
- */
- public List getExceptions() {
- return unmodifiableList(exceptions);
- }
-
- /**
- * List of returns from {@link SqsMessageHandler#process(SQSMessage)} that were successfully processed.
- *
- * @return List of returns from successfully processed messages
- */
- public List successMessageReturnValues() {
- return unmodifiableList(returnValues);
- }
-
- /**
- * Details of {@link SQSMessage} that failed in {@link SqsMessageHandler#process(SQSMessage)}
- *
- * @return List of failed messages
- */
- public List getFailures() {
- return unmodifiableList(failures);
- }
-
- @Override
- public void printStackTrace() {
- for (Exception exception : exceptions) {
- exception.printStackTrace();
- }
- }
-}
diff --git a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsBatch.java b/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsBatch.java
deleted file mode 100644
index 4378fa707..000000000
--- a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsBatch.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @deprecated
- * @see software.amazon.lambda.powertools.batch in powertools-batch module.
- * Will be removed in V2.
- *
- * {@link SqsBatch} is used to process batch messages in {@link SQSEvent}
- *
- *
- * When using the annotation, implementation of {@link SqsMessageHandler} is required. Annotation will take care of
- * calling {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage} in the received {@link SQSEvent}
- *
- *
- *
- * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages, Utility
- * will take care of deleting all the successful messages from SQS. When one or more single message fails processing due
- * to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}, Lambda execution will fail
- * with {@link SQSBatchProcessingException}.
- *
- * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
- * Lambda execution context for deletion.
- *
- *
- *
- * If you want to suppress the exception even if any message in batch fails, set
- * {@link SqsBatch#suppressException()} to true. By default its value is false
- *
- *
- *
- * If you want certain exceptions to be treated as permanent failures, i.e. exceptions where the result of retrying will
- * always be a failure and want these can be immediately moved to the dead letter queue associated to the source SQS queue,
- *
- * you can use {@link SqsBatch#nonRetryableExceptions()} to configure such exceptions.
- * Make sure function execution role has sqs:GetQueueAttributes permission on source SQS queue and sqs:SendMessage,
- * sqs:SendMessageBatch permission for configured DLQ.
- *
- * If you want such messages to be deleted instead, set {@link SqsBatch#deleteNonRetryableMessageFromQueue()} to true.
- * By default its value is false.
- *
- * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
- * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
- * exceptions and the message will be moved back to source SQS queue for reprocessing. The same behaviour will occur if
- * for some reason the utility is unable to move the message to the DLQ. An example of this could be because the function
- * is missing the correct permissions.
- *
- *
- *
- * public class SqsMessageHandler implements RequestHandler {
- *
- * {@literal @}Override
- * {@literal @}{@link SqsBatch (SqsMessageHandler)}
- * public String handleRequest(SQSEvent sqsEvent, Context context) {
- *
- * return "ok";
- * }
- *
- * public class DummySqsMessageHandler implements SqsMessageHandler{
- * @Override
- * public Object process(SQSEvent.SQSMessage message) {
- * throw new UnsupportedOperationException();
- * }
- * }
- *
- * ...
- *
- *
- * @see Amazon SQS dead-letter queues
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-@Deprecated
-public @interface SqsBatch {
-
- Class extends SqsMessageHandler> value();
-
- boolean suppressException() default false;
-
- Class extends Exception>[] nonRetryableExceptions() default {};
-
- boolean deleteNonRetryableMessageFromQueue() default false;
-}
diff --git a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsLargeMessage.java b/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsLargeMessage.java
deleted file mode 100644
index a3a92cea1..000000000
--- a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsLargeMessage.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @deprecated See software.amazon.lambda.powertools.largemessages.LargeMessage in powertools-large-messages module.
- * Will be removed in version 2.
- *
- * {@code SqsLargeMessage} is used to signal that the annotated method
- * should be extended to handle large SQS messages which have been offloaded
- * to S3
- *
- * {@code SqsLargeMessage} automatically retrieves and deletes messages
- * which have been offloaded to S3 using the {@code amazon-sqs-java-extended-client-lib}
- * client library.
- *
- * This version of the {@code SqsLargeMessage} is compatible with version
- * 1.1.0+ of {@code amazon-sqs-java-extended-client-lib}.
- *
- *
- * <dependency>
- * <groupId>com.amazonaws</groupId>
- * <artifactId>amazon-sqs-java-extended-client-lib</artifactId>
- * <version>1.1.0</version>
- * </dependency>
- *
- *
- * {@code SqsLargeMessage} should be used with the handleRequest method of a class
- * which implements {@code com.amazonaws.services.lambda.runtime.RequestHandler} with
- * {@code com.amazonaws.services.lambda.runtime.events.SQSEvent} as the first parameter.
- *
- *
- * public class SqsMessageHandler implements RequestHandler {
- *
- * {@literal @}Override
- * {@literal @}SqsLargeMessage
- * public String handleRequest(SQSEvent sqsEvent, Context context) {
- *
- * // process messages
- *
- * return "ok";
- * }
- *
- * ...
- *
- *
- * Using the default S3 Client {@code AmazonS3 amazonS3 = AmazonS3ClientBuilder.defaultClient();}
- * each record received in the SQSEvent {@code SqsLargeMessage} will checked
- * to see if it's body contains a payload which has been offloaded to S3. If it
- * does then {@code getObject(bucket, key)} will be called and the payload
- * retrieved.
- *
- * Note : Retreiving payloads from S3 will increase the duration of the
- * Lambda function.
- *
- * If the request handler method returns then each payload will be deleted
- * from S3 using {@code deleteObject(bucket, key)}
- *
- * To disable deletion of payloads setting the following annotation parameter
- * {@code @SqsLargeMessage(deletePayloads=false)}
- */
-@Deprecated
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface SqsLargeMessage {
-
- boolean deletePayloads() default true;
-}
diff --git a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsMessageHandler.java b/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsMessageHandler.java
deleted file mode 100644
index 0c8f03ee9..000000000
--- a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsMessageHandler.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-
-/**
- *
- * This interface should be implemented for processing {@link SQSMessage} inside {@link SQSEvent} received by lambda
- * function.
- *
- *
- *
- * It is required by utilities:
- *
- * {@link SqsBatch}
- * {@link SqsUtils#batchProcessor(SQSEvent, Class)}
- * {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
- * {@link SqsUtils#batchProcessor(SQSEvent, SqsMessageHandler)}
- * {@link SqsUtils#batchProcessor(SQSEvent, boolean, SqsMessageHandler)}
- *
- *
- *
- * @param Return value type from {@link SqsMessageHandler#process(SQSMessage)}
- */
-@FunctionalInterface
-public interface SqsMessageHandler {
-
- R process(SQSMessage message);
-}
diff --git a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsUtils.java b/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsUtils.java
deleted file mode 100644
index d89642780..000000000
--- a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsUtils.java
+++ /dev/null
@@ -1,653 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static software.amazon.lambda.powertools.sqs.internal.SqsLargeMessageAspect.processMessages;
-
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
-import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption;
-import software.amazon.awssdk.services.s3.S3Client;
-import software.amazon.awssdk.services.sqs.SqsClient;
-import software.amazon.lambda.powertools.core.internal.UserAgentConfigurator;
-import software.amazon.lambda.powertools.sqs.exception.SkippedMessageDueToFailedBatchException;
-import software.amazon.lambda.powertools.sqs.internal.BatchContext;
-import software.amazon.lambda.powertools.sqs.internal.SqsLargeMessageAspect;
-import software.amazon.payloadoffloading.PayloadS3Pointer;
-
-/**
- * A class of helper functions to add additional functionality to {@link SQSEvent} processing.
- *
- * @deprecated Batch processing is now handled in powertools-batch and large messages in powertools-large-messages .
- * This class will no longer be available in version 2.
- */
-@Deprecated
-public final class SqsUtils {
-
- public static final String SQS = "sqs";
- private static final Logger LOG = LoggerFactory.getLogger(SqsUtils.class);
- private static final ObjectMapper objectMapper = new ObjectMapper();
- private static final String MESSAGE_GROUP_ID = "MessageGroupId";
- private static SqsClient client;
- private static S3Client s3Client;
-
- private SqsUtils() {
- }
-
- /**
- * This is a utility method when you want to avoid using {@code SqsLargeMessage} annotation.
- * Gives you access to enriched messages from S3 in the SQS event produced via extended client lib.
- * If all the large S3 payload are successfully retrieved, it will delete them from S3 post success.
- *
- * @param sqsEvent Event received from SQS Extended client library
- * @param messageFunction Function to execute you business logic which provides access to enriched messages from S3 when needed.
- * @return Return value from the function.
- */
- public static R enrichedMessageFromS3(final SQSEvent sqsEvent,
- final Function, R> messageFunction) {
- return enrichedMessageFromS3(sqsEvent, true, messageFunction);
- }
-
- /**
- * This is a utility method when you want to avoid using {@code SqsLargeMessage} annotation.
- * Gives you access to enriched messages from S3 in the SQS event produced via extended client lib.
- * if all the large S3 payload are successfully retrieved, Control if it will delete payload from S3 post success.
- *
- * @param sqsEvent Event received from SQS Extended client library
- * @param messageFunction Function to execute you business logic which provides access to enriched messages from S3 when needed.
- * @return Return value from the function.
- */
- public static R enrichedMessageFromS3(final SQSEvent sqsEvent,
- final boolean deleteS3Payload,
- final Function, R> messageFunction) {
-
- List sqsMessages = sqsEvent.getRecords().stream()
- .map(SqsUtils::clonedMessage)
- .collect(Collectors.toList());
-
- List s3Pointers = processMessages(sqsMessages);
-
- R returnValue = messageFunction.apply(sqsMessages);
-
- if (deleteS3Payload) {
- s3Pointers.forEach(SqsLargeMessageAspect::deleteMessage);
- }
-
- return returnValue;
- }
-
- /**
- * Provides ability to set default {@link SqsClient} to be used by utility.
- * If no default configuration is provided, client is instantiated via {@link SqsClient#create()}
- *
- * @param client {@link SqsClient} to be used by utility
- */
- public static void overrideSqsClient(SqsClient client) {
- SqsUtils.client = client;
- }
-
- /**
- * By default, the S3Client is instantiated via {@link S3Client#create()}.
- * This method provides the ability to override the S3Client with your own custom version.
- *
- * @param s3Client {@link S3Client} to be used by utility
- */
- public static void overrideS3Client(S3Client s3Client) {
- SqsUtils.s3Client = s3Client;
- }
-
- /**
- *
- * @deprecated
- * @see software.amazon.lambda.powertools.batch in powertools-batch module.
- * Will be removed in V2.
- *
- * This utility method is used to process each {@link SQSMessage} inside the received {@link SQSEvent}
- *
- *
- * The Utility will call {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
- * in the received {@link SQSEvent}
- *
- *
- *
- * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a message,
- * the utility will take care of deleting all the successful messages from SQS. When one or more single message fails
- * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
- * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
- *
- * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
- * Lambda execution context for deletion.
- *
- *
- *
- * If you dont want the utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
- * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
- *
- *
- * @param event {@link SQSEvent} received by lambda function.
- * @param handler Class implementing {@link SqsMessageHandler} which will be called for each message in event.
- * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
- * @throws SQSBatchProcessingException if some messages fail during processing.
- */
- @Deprecated
- public static List batchProcessor(final SQSEvent event,
- final Class extends SqsMessageHandler> handler) {
- return batchProcessor(event, false, handler);
- }
-
- /**
- * @deprecated
- * @see software.amazon.lambda.powertools.batch in powertools-batch module.
- * Will be removed in V2.
- *
- * This utility method is used to process each {@link SQSMessage} inside the received {@link SQSEvent}
- *
- *
- * The Utility will call {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
- * in the received {@link SQSEvent}
- *
- *
- * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a message,
- * the utility will take care of deleting all the successful messages from SQS. When one or more single message fails
- * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
- * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
- *
- *
- *
- *
- * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
- * Lambda execution context for deletion.
- *
- *
- *
- * If you dont want the utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
- * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
- *
- *
- *
- * If you want certain exceptions to be treated as permanent failures, i.e. exceptions where the result of retrying will
- * always be a failure and want these can be immediately moved to the dead letter queue associated to the source SQS queue,
- * you can use nonRetryableExceptions parameter to configure such exceptions.
- *
- * Make sure function execution role has sqs:GetQueueAttributes permission on source SQS queue and sqs:SendMessage,
- * sqs:SendMessageBatch permission for configured DLQ.
- *
- * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
- * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
- * exceptions and the message will be moved back to source SQS queue for reprocessing. The same behaviour will occur if
- * for some reason the utility is unable to move the message to the DLQ. An example of this could be because the function
- * is missing the correct permissions.
- *
- *
- * @param event {@link SQSEvent} received by lambda function.
- * @param handler Class implementing {@link SqsMessageHandler} which will be called for each message in event.
- * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
- * to DLQ.
- * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
- * @throws SQSBatchProcessingException if some messages fail during processing.
- * @see Amazon SQS dead-letter queues
- */
- @SafeVarargs
- @Deprecated
- public static List batchProcessor(final SQSEvent event,
- final Class extends SqsMessageHandler> handler,
- final Class extends Exception>... nonRetryableExceptions) {
- return batchProcessor(event, false, handler, nonRetryableExceptions);
- }
-
- /**
- * @deprecated
- * @see software.amazon.lambda.powertools.batch in powertools-batch module.
- * Will be removed in V2.
- *
- * This utility method is used to process each {@link SQSMessage} inside the received {@link SQSEvent}
- *
- *
- * The Utility will call {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
- * in the received {@link SQSEvent}
- *
- *
- * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a message,
- * the utility will take care of deleting all the successful messages from SQS. When one or more single message fails
- * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
- * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
- *
- * Exception can also be suppressed if desired.
- *
- * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
- * Lambda execution context for deletion.
- *
- *
- * @param event {@link SQSEvent} received by lambda function.
- * @param suppressException if this is set to true, No {@link SQSBatchProcessingException} is thrown even on failed
- * messages.
- * @param handler Class implementing {@link SqsMessageHandler} which will be called for each message in event.
- * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
- * @throws SQSBatchProcessingException if some messages fail during processing and no suppression enabled.
- */
- @Deprecated
- public static List batchProcessor(final SQSEvent event,
- final boolean suppressException,
- final Class extends SqsMessageHandler> handler) {
-
- SqsMessageHandler handlerInstance = instantiatedHandler(handler);
- return batchProcessor(event, suppressException, handlerInstance);
- }
-
- /**
- * @deprecated
- * @see software.amazon.lambda.powertools.batch in powertools-batch module.
- * Will be removed in V2.
- *
- * This utility method is used to process each {@link SQSMessage} inside the received {@link SQSEvent}
- *
- *
- * The Utility will call {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
- * in the received {@link SQSEvent}
- *
- *
- * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a message,
- * the utility will take care of deleting all the successful messages from SQS. When one or more single message fails
- * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
- * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
- *
- *
- *
- *
- * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
- * Lambda execution context for deletion.
- *
- *
- *
- * If you dont want the utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
- * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
- *
- *
- *
- * If you want certain exceptions to be treated as permanent failures, i.e. exceptions where the result of retrying will
- * always be a failure and want these can be immediately moved to the dead letter queue associated to the source SQS queue,
- * you can use nonRetryableExceptions parameter to configure such exceptions.
- *
- * Make sure function execution role has sqs:GetQueueAttributes permission on source SQS queue and sqs:SendMessage,
- * sqs:SendMessageBatch permission for configured DLQ.
- *
- * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
- * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
- * exceptions and the message will be moved back to source SQS queue for reprocessing. The same behaviour will occur if
- * for some reason the utility is unable to move the message to the DLQ. An example of this could be because the function
- * is missing the correct permissions.
- *
- *
- * @param event {@link SQSEvent} received by lambda function.
- * @param suppressException if this is set to true, No {@link SQSBatchProcessingException} is thrown even on failed
- * messages.
- * @param handler Class implementing {@link SqsMessageHandler} which will be called for each message in event.
- * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
- * to DLQ.
- * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
- * @throws SQSBatchProcessingException if some messages fail during processing.
- * @see Amazon SQS dead-letter queues
- */
- @SafeVarargs
- @Deprecated
- public static List batchProcessor(final SQSEvent event,
- final boolean suppressException,
- final Class extends SqsMessageHandler> handler,
- final Class extends Exception>... nonRetryableExceptions) {
-
- SqsMessageHandler handlerInstance = instantiatedHandler(handler);
- return batchProcessor(event, suppressException, handlerInstance, false, nonRetryableExceptions);
- }
-
- /**
- * @deprecated
- * @see software.amazon.lambda.powertools.batch in powertools-batch module.
- * Will be removed in V2.
- *
- * This utility method is used to process each {@link SQSMessage} inside the received {@link SQSEvent}
- *
- *
- * The Utility will call {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
- * in the received {@link SQSEvent}
- *
- *
- *
- * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a message,
- * the utility will take care of deleting all the successful messages from SQS. When one or more single message fails
- * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
- * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
- *
- *
- *
- *
- * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
- * Lambda execution context for deletion.
- *
- *
- *
- * If you dont want the utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
- * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
- *
- *
- *
- * If you want certain exceptions to be treated as permanent failures, i.e. exceptions where the result of retrying will
- * always be a failure and want these can be immediately moved to the dead letter queue associated to the source SQS queue,
- * you can use nonRetryableExceptions parameter to configure such exceptions.
- *
- * Make sure function execution role has sqs:GetQueueAttributes permission on source SQS queue and sqs:SendMessage,
- * sqs:SendMessageBatch permission for configured DLQ.
- *
- * If you want such messages to be deleted instead, set deleteNonRetryableMessageFromQueue to true.
- *
- * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
- * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
- * exceptions and the message will be moved back to source SQS queue for reprocessing. The same behaviour will occur if
- * for some reason the utility is unable to move the message to the DLQ. An example of this could be because the function
- * is missing the correct permissions.
- *
- *
- * @param event {@link SQSEvent} received by lambda function.
- * @param suppressException if this is set to true, No {@link SQSBatchProcessingException} is thrown even on failed
- * messages.
- * @param handler Class implementing {@link SqsMessageHandler} which will be called for each message in event.
- * @param deleteNonRetryableMessageFromQueue If messages with nonRetryableExceptions are to be deleted from SQS queue.
- * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
- * to DLQ.
- * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
- * @throws SQSBatchProcessingException if some messages fail during processing.
- * @see Amazon SQS dead-letter queues
- */
- @SafeVarargs
- @Deprecated
- public static List batchProcessor(final SQSEvent event,
- final boolean suppressException,
- final Class extends SqsMessageHandler> handler,
- final boolean deleteNonRetryableMessageFromQueue,
- final Class extends Exception>... nonRetryableExceptions) {
-
- SqsMessageHandler handlerInstance = instantiatedHandler(handler);
- return batchProcessor(event, suppressException, handlerInstance, deleteNonRetryableMessageFromQueue,
- nonRetryableExceptions);
- }
-
- /**
- * @deprecated
- * @see software.amazon.lambda.powertools.batch in powertools-batch module.
- * Will be removed in V2.
- *
- * This utility method is used to process each {@link SQSMessage} inside the received {@link SQSEvent}
- *
- *
- * The Utility will call {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
- * in the received {@link SQSEvent}
- *
- *
- *
- * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages,
- * Utility will take care of deleting all the successful messages from SQS. When one or more single message fails
- * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
- * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
- *
- * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
- * Lambda execution context for deletion.
- *
- *
- *
- * If you dont want the utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
- * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, SqsMessageHandler)}
- *
- *
- * @param event {@link SQSEvent} received by lambda function.
- * @param handler Instance of class implementing {@link SqsMessageHandler} which will be called for each message in event.
- * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message-
- * @throws SQSBatchProcessingException if some messages fail during processing.
- */
- @Deprecated
- public static List batchProcessor(final SQSEvent event,
- final SqsMessageHandler handler) {
- return batchProcessor(event, false, handler);
- }
-
-
- /**
- * @deprecated
- * @see software.amazon.lambda.powertools.batch in powertools-batch module.
- * Will be removed in V2.
- *
- * This utility method is used to process each {@link SQSMessage} inside the received {@link SQSEvent}
- *
- *
- * The Utility will call {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
- * in the received {@link SQSEvent}
- *
- *
- *
- * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a message,
- * the utility will take care of deleting all the successful messages from SQS. When one or more single message fails
- * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
- * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
- *
- *
- *
- *
- * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
- * Lambda execution context for deletion.
- *
- *
- *
- * If you dont want the utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
- * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
- *
- *
- *
- * If you want certain exceptions to be treated as permanent failures, i.e. exceptions where the result of retrying will
- * always be a failure and want these can be immediately moved to the dead letter queue associated to the source SQS queue,
- * you can use nonRetryableExceptions parameter to configure such exceptions.
- *
- * Make sure function execution role has sqs:GetQueueAttributes permission on source SQS queue and sqs:SendMessage,
- * sqs:SendMessageBatch permission for configured DLQ.
- *
- * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
- * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
- * exceptions and the message will be moved back to source SQS queue for reprocessing.The same behaviour will occur if
- * for some reason the utility is unable to moved the message to the DLQ. An example of this could be because the function
- * is missing the correct permissions.
- *
- *
- * @param event {@link SQSEvent} received by lambda function.
- * @param handler Instance of class implementing {@link SqsMessageHandler} which will be called for each message in event.
- * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
- * to DLQ.
- * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
- * @throws SQSBatchProcessingException if some messages fail during processing.
- * @see Amazon SQS dead-letter queues
- */
- @SafeVarargs
- @Deprecated
- public static List batchProcessor(final SQSEvent event,
- final SqsMessageHandler handler,
- final Class extends Exception>... nonRetryableExceptions) {
- return batchProcessor(event, false, handler, false, nonRetryableExceptions);
- }
-
-
- /**
- * @deprecated
- * @see software.amazon.lambda.powertools.batch in powertools-batch module.
- * Will be removed in V2.
- *
- * This utility method is used to process each {@link SQSMessage} inside the received {@link SQSEvent}
- *
- *
- * The Utility will call {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
- * in the received {@link SQSEvent}
- *
- *
- *
- * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages,
- * the utility will take care of deleting all the successful messages from SQS. When one or more single message fails
- * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
- * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
- *
- * Exception can also be suppressed if desired.
- *
- * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
- * Lambda execution context for deletion.
- *
- *
- * @param event {@link SQSEvent} received by lambda function.
- * @param suppressException if this is set to true, No {@link SQSBatchProcessingException} is thrown even on failed
- * messages.
- * @param handler Instance of class implementing {@link SqsMessageHandler} which will be called for each message in event.
- * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
- * @throws SQSBatchProcessingException if some messages fail during processing and no suppression enabled.
- */
- @Deprecated
- public static List batchProcessor(final SQSEvent event,
- final boolean suppressException,
- final SqsMessageHandler handler) {
- return batchProcessor(event, suppressException, handler, false);
-
- }
-
- /**
- * @deprecated
- * @see software.amazon.lambda.powertools.batch in powertools-batch module.
- * Will be removed in V2.
- */
- @SafeVarargs
- @Deprecated
- public static List batchProcessor(final SQSEvent event,
- final boolean suppressException,
- final SqsMessageHandler handler,
- final boolean deleteNonRetryableMessageFromQueue,
- final Class extends Exception>... nonRetryableExceptions) {
- final List handlerReturn = new ArrayList<>();
-
- if (client == null) {
- client = (SqsClient) SqsClient.builder()
- .overrideConfiguration(ClientOverrideConfiguration.builder()
- .putAdvancedOption(SdkAdvancedClientOption.USER_AGENT_SUFFIX,
- UserAgentConfigurator.getUserAgent(SQS))
- .build());
- }
-
- BatchContext batchContext = new BatchContext(client);
- int offset = 0;
- boolean failedBatch = false;
- while (offset < event.getRecords().size() && !failedBatch) {
- // Get the current message and advance to the next. Doing this here
- // makes it easier for us to know where we are up to if we have to
- // break out of here early.
- SQSMessage message = event.getRecords().get(offset);
- offset++;
-
- // If the batch hasn't failed, try process the message
- try {
- handlerReturn.add(handler.process(message));
- batchContext.addSuccess(message);
- } catch (Exception e) {
-
- // Record the failure
- batchContext.addFailure(message, e);
-
- // If we are trying to process a message that has a messageGroupId, we are on a FIFO queue. A failure
- // now stops us from processing the rest of the batch; we break out of the loop leaving unprocessed
- // messages in the queue
- // https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting
- String messageGroupId = message.getAttributes() != null ?
- message.getAttributes().get(MESSAGE_GROUP_ID) : null;
- if (messageGroupId != null) {
- LOG.info(
- "A message in a message batch with messageGroupId {} and messageId {} failed; failing the rest of the batch too"
- , messageGroupId, message.getMessageId());
- failedBatch = true;
- }
- LOG.error("Encountered issue processing message: {}", message.getMessageId(), e);
- }
- }
-
- // If we have a FIFO batch failure, unprocessed messages will remain on the queue
- // past the failed message. We have to add these to the errors
- if (offset < event.getRecords().size()) {
- event.getRecords()
- .subList(offset, event.getRecords().size())
- .forEach(message ->
- {
- LOG.info("Skipping message {} as another message with a message group failed in this batch",
- message.getMessageId());
- batchContext.addFailure(message, new SkippedMessageDueToFailedBatchException());
- });
- }
-
- batchContext.processSuccessAndHandleFailed(handlerReturn, suppressException, deleteNonRetryableMessageFromQueue,
- nonRetryableExceptions);
- return handlerReturn;
- }
-
- private static SqsMessageHandler instantiatedHandler(final Class extends SqsMessageHandler> handler) {
-
- try {
- if (null == handler.getDeclaringClass()) {
- return handler.getDeclaredConstructor().newInstance();
- }
-
- final Constructor extends SqsMessageHandler> constructor =
- handler.getDeclaredConstructor(handler.getDeclaringClass());
- constructor.setAccessible(true);
- return constructor.newInstance(handler.getDeclaringClass().getDeclaredConstructor().newInstance());
- } catch (Exception e) {
- LOG.error("Failed creating handler instance", e);
- throw new RuntimeException("Unexpected error occurred. Please raise issue at " +
- "https://github.com/aws-powertools/powertools-lambda-java/issues", e);
- }
- }
-
- private static SQSMessage clonedMessage(final SQSMessage sqsMessage) {
- try {
- return objectMapper
- .readValue(objectMapper.writeValueAsString(sqsMessage), SQSMessage.class);
- } catch (JsonProcessingException e) {
- throw new RuntimeException(e);
- }
- }
-
- public static ObjectMapper objectMapper() {
- return objectMapper;
- }
-
- public static S3Client s3Client() {
- if (null == s3Client) {
- s3Client = (S3Client) S3Client.builder()
- .overrideConfiguration(ClientOverrideConfiguration.builder()
- .putAdvancedOption(SdkAdvancedClientOption.USER_AGENT_SUFFIX,
- UserAgentConfigurator.getUserAgent(SQS))
- .build());
- SqsUtils.s3Client = S3Client.create();
- }
-
- return s3Client;
- }
-}
diff --git a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/exception/SkippedMessageDueToFailedBatchException.java b/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/exception/SkippedMessageDueToFailedBatchException.java
deleted file mode 100644
index fbb4289d8..000000000
--- a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/exception/SkippedMessageDueToFailedBatchException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.exception;
-
-/**
- * Indicates that a message has been skipped due to the batch it is
- * within failing.
- */
-public class SkippedMessageDueToFailedBatchException extends Exception {
-
- public SkippedMessageDueToFailedBatchException() {
- }
-
-}
diff --git a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/BatchContext.java b/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/BatchContext.java
deleted file mode 100644
index 70cf04fb8..000000000
--- a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/BatchContext.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.internal;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static java.lang.String.format;
-import static java.util.Optional.ofNullable;
-import static java.util.stream.Collectors.toList;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.core.SdkBytes;
-import software.amazon.awssdk.services.sqs.SqsClient;
-import software.amazon.awssdk.services.sqs.model.DeleteMessageBatchRequest;
-import software.amazon.awssdk.services.sqs.model.DeleteMessageBatchRequestEntry;
-import software.amazon.awssdk.services.sqs.model.DeleteMessageBatchResponse;
-import software.amazon.awssdk.services.sqs.model.GetQueueAttributesRequest;
-import software.amazon.awssdk.services.sqs.model.GetQueueAttributesResponse;
-import software.amazon.awssdk.services.sqs.model.MessageAttributeValue;
-import software.amazon.awssdk.services.sqs.model.QueueAttributeName;
-import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequest;
-import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequestEntry;
-import software.amazon.awssdk.services.sqs.model.SendMessageBatchResponse;
-import software.amazon.lambda.powertools.sqs.SQSBatchProcessingException;
-import software.amazon.lambda.powertools.sqs.SqsUtils;
-
-public final class BatchContext {
- private static final Logger LOG = LoggerFactory.getLogger(BatchContext.class);
- private static final Map QUEUE_ARN_TO_DLQ_URL_MAPPING = new HashMap<>();
-
- private final Map messageToException = new HashMap<>();
- private final List success = new ArrayList<>();
-
- private final SqsClient client;
-
- public BatchContext(SqsClient client) {
- this.client = client;
- }
-
- public void addSuccess(SQSMessage event) {
- success.add(event);
- }
-
- public void addFailure(SQSMessage event, Exception e) {
- messageToException.put(event, e);
- }
-
- @SafeVarargs
- public final void processSuccessAndHandleFailed(final List successReturns,
- final boolean suppressException,
- final boolean deleteNonRetryableMessageFromQueue,
- final Class extends Exception>... nonRetryableExceptions) {
- if (hasFailures()) {
-
- List exceptions = new ArrayList<>();
- List failedMessages = new ArrayList<>();
- Map nonRetryableMessageToException = new HashMap<>();
-
- if (nonRetryableExceptions.length == 0) {
- exceptions.addAll(messageToException.values());
- failedMessages.addAll(messageToException.keySet());
- } else {
- messageToException.forEach((sqsMessage, exception) ->
- {
- boolean nonRetryableException = isNonRetryableException(exception, nonRetryableExceptions);
-
- if (nonRetryableException) {
- nonRetryableMessageToException.put(sqsMessage, exception);
- } else {
- exceptions.add(exception);
- failedMessages.add(sqsMessage);
- }
- });
- }
-
- List messagesToBeDeleted = new ArrayList<>(success);
-
- if (!nonRetryableMessageToException.isEmpty() && deleteNonRetryableMessageFromQueue) {
- messagesToBeDeleted.addAll(nonRetryableMessageToException.keySet());
- } else if (!nonRetryableMessageToException.isEmpty()) {
-
- boolean isMovedToDlq = moveNonRetryableMessagesToDlqIfConfigured(nonRetryableMessageToException);
-
- if (!isMovedToDlq) {
- exceptions.addAll(nonRetryableMessageToException.values());
- failedMessages.addAll(nonRetryableMessageToException.keySet());
- }
- }
-
- deleteMessagesFromQueue(messagesToBeDeleted);
-
- processFailedMessages(successReturns, suppressException, exceptions, failedMessages);
- }
- }
-
- private void processFailedMessages(List successReturns,
- boolean suppressException,
- List exceptions,
- List failedMessages) {
- if (failedMessages.isEmpty()) {
- return;
- }
-
- if (suppressException) {
- List messageIds = failedMessages.stream().
- map(SQSMessage::getMessageId)
- .collect(toList());
-
- LOG.debug(format("[%d] records failed processing, but exceptions are suppressed. " +
- "Failed messages %s", failedMessages.size(), messageIds));
- } else {
- throw new SQSBatchProcessingException(exceptions, failedMessages, successReturns);
- }
- }
-
- private boolean isNonRetryableException(Exception exception, Class extends Exception>[] nonRetryableExceptions) {
- return Arrays.stream(nonRetryableExceptions)
- .anyMatch(aClass -> aClass.isInstance(exception));
- }
-
- private boolean moveNonRetryableMessagesToDlqIfConfigured(
- Map nonRetryableMessageToException) {
- Optional dlqUrl = fetchDlqUrl(nonRetryableMessageToException);
-
- if (!dlqUrl.isPresent()) {
- return false;
- }
-
- List dlqMessages = nonRetryableMessageToException.keySet().stream()
- .map(sqsMessage ->
- {
- Map messageAttributesMap = new HashMap<>();
-
- sqsMessage.getMessageAttributes().forEach((s, messageAttribute) ->
- {
- MessageAttributeValue.Builder builder = MessageAttributeValue.builder();
-
- builder
- .dataType(messageAttribute.getDataType())
- .stringValue(messageAttribute.getStringValue());
-
- if (null != messageAttribute.getBinaryValue()) {
- builder.binaryValue(SdkBytes.fromByteBuffer(messageAttribute.getBinaryValue()));
- }
-
- messageAttributesMap.put(s, builder.build());
- });
-
- return SendMessageBatchRequestEntry.builder()
- .messageBody(sqsMessage.getBody())
- .id(sqsMessage.getMessageId())
- .messageAttributes(messageAttributesMap)
- .build();
- })
- .collect(toList());
-
- List sendMessageBatchResponses = batchRequest(dlqMessages, 10, entriesToSend ->
- {
-
- SendMessageBatchResponse sendMessageBatchResponse =
- client.sendMessageBatch(SendMessageBatchRequest.builder()
- .entries(entriesToSend)
- .queueUrl(dlqUrl.get())
- .build());
-
-
- LOG.debug("Response from send batch message to DLQ request {}", sendMessageBatchResponse);
-
- return sendMessageBatchResponse;
- });
-
- return sendMessageBatchResponses.stream()
- .filter(response -> null != response && response.hasFailed())
- .peek(sendMessageBatchResponse -> LOG.error(
- "Failed sending message to the DLQ. Entire batch will be re processed. Check if needed permissions are configured for the function. Response: {}",
- sendMessageBatchResponse))
- .count() == 0;
- }
-
-
- private Optional fetchDlqUrl(Map nonRetryableMessageToException) {
- return nonRetryableMessageToException.keySet().stream()
- .findFirst()
- .map(sqsMessage -> QUEUE_ARN_TO_DLQ_URL_MAPPING.computeIfAbsent(sqsMessage.getEventSourceArn(),
- sourceArn ->
- {
- String queueUrl = url(sourceArn);
-
- GetQueueAttributesResponse queueAttributes =
- client.getQueueAttributes(GetQueueAttributesRequest.builder()
- .attributeNames(QueueAttributeName.REDRIVE_POLICY)
- .queueUrl(queueUrl)
- .build());
-
- return ofNullable(queueAttributes.attributes().get(QueueAttributeName.REDRIVE_POLICY))
- .map(policy ->
- {
- try {
- return SqsUtils.objectMapper().readTree(policy);
- } catch (JsonProcessingException e) {
- LOG.debug(
- "Unable to parse Re drive policy for queue {}. Even if DLQ exists, failed messages will be send back to main queue.",
- queueUrl, e);
- return null;
- }
- })
- .map(node -> node.get("deadLetterTargetArn"))
- .map(JsonNode::asText)
- .map(this::url)
- .orElse(null);
- }));
- }
-
- private boolean hasFailures() {
- return !messageToException.isEmpty();
- }
-
- private void deleteMessagesFromQueue(final List messages) {
- if (!messages.isEmpty()) {
-
- List entries =
- messages.stream().map(m -> DeleteMessageBatchRequestEntry.builder()
- .id(m.getMessageId())
- .receiptHandle(m.getReceiptHandle())
- .build()).collect(toList());
-
- batchRequest(entries, 10, entriesToDelete ->
- {
- DeleteMessageBatchRequest request = DeleteMessageBatchRequest.builder()
- .queueUrl(url(messages.get(0).getEventSourceArn()))
- .entries(entriesToDelete)
- .build();
-
- DeleteMessageBatchResponse deleteMessageBatchResponse = client.deleteMessageBatch(request);
-
- LOG.debug("Response from delete request {}", deleteMessageBatchResponse);
-
- return deleteMessageBatchResponse;
- });
- }
- }
-
- private List batchRequest(final List listOFEntries,
- final int size,
- final Function, R> batchLogic) {
-
- return IntStream.range(0, listOFEntries.size())
- .filter(index -> index % size == 0)
- .mapToObj(index -> listOFEntries.subList(index, Math.min(index + size, listOFEntries.size())))
- .map(batchLogic)
- .collect(Collectors.toList());
- }
-
- private String url(String queueArn) {
- String[] arnArray = queueArn.split(":");
- return String.format("https://sqs.%s.amazonaws.com/%s/%s", arnArray[3], arnArray[4], arnArray[5]);
- }
-}
diff --git a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/SqsLargeMessageAspect.java b/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/SqsLargeMessageAspect.java
deleted file mode 100644
index e5176e13a..000000000
--- a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/SqsLargeMessageAspect.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.internal;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static java.lang.String.format;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.isHandlerMethod;
-import static software.amazon.lambda.powertools.sqs.SqsUtils.s3Client;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.function.Function;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.core.ResponseInputStream;
-import software.amazon.awssdk.core.exception.SdkClientException;
-import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
-import software.amazon.awssdk.services.s3.model.GetObjectRequest;
-import software.amazon.awssdk.services.s3.model.GetObjectResponse;
-import software.amazon.awssdk.services.s3.model.S3Exception;
-import software.amazon.awssdk.utils.IoUtils;
-import software.amazon.lambda.powertools.sqs.SqsLargeMessage;
-import software.amazon.payloadoffloading.PayloadS3Pointer;
-
-@Aspect
-public class SqsLargeMessageAspect {
-
- private static final Logger LOG = LoggerFactory.getLogger(SqsLargeMessageAspect.class);
-
- public static List processMessages(final List records) {
- List s3Pointers = new ArrayList<>();
- for (SQSMessage sqsMessage : records) {
- if (isBodyLargeMessagePointer(sqsMessage.getBody())) {
-
- PayloadS3Pointer s3Pointer = Optional.ofNullable(PayloadS3Pointer.fromJson(sqsMessage.getBody()))
- .orElseThrow(() -> new FailedProcessingLargePayloadException(
- format("Failed processing SQS body to extract S3 details. [ %s ].",
- sqsMessage.getBody())));
-
- ResponseInputStream s3Object = callS3Gracefully(s3Pointer, pointer ->
- {
- ResponseInputStream response =
- s3Client().getObject(GetObjectRequest.builder()
- .bucket(pointer.getS3BucketName())
- .key(pointer.getS3Key())
- .build());
-
- LOG.debug("Object downloaded with key: " + s3Pointer.getS3Key());
- return response;
- });
-
- sqsMessage.setBody(readStringFromS3Object(s3Object, s3Pointer));
- s3Pointers.add(s3Pointer);
- }
- }
-
- return s3Pointers;
- }
-
- private static boolean isBodyLargeMessagePointer(String record) {
- return record.startsWith("[\"software.amazon.payloadoffloading.PayloadS3Pointer\"");
- }
-
- private static String readStringFromS3Object(ResponseInputStream response,
- PayloadS3Pointer s3Pointer) {
- try (ResponseInputStream content = response) {
- return IoUtils.toUtf8String(content);
- } catch (IOException e) {
- LOG.error("Error converting S3 object to String", e);
- throw new FailedProcessingLargePayloadException(
- format("Failed processing S3 record with [Bucket Name: %s Bucket Key: %s]",
- s3Pointer.getS3BucketName(), s3Pointer.getS3Key()), e);
- }
- }
-
- public static void deleteMessage(PayloadS3Pointer s3Pointer) {
- callS3Gracefully(s3Pointer, pointer ->
- {
- s3Client().deleteObject(DeleteObjectRequest.builder()
- .bucket(pointer.getS3BucketName())
- .key(pointer.getS3Key())
- .build());
- LOG.info("Message deleted from S3: " + s3Pointer.toJson());
- return null;
- });
- }
-
- private static R callS3Gracefully(final PayloadS3Pointer pointer,
- final Function function) {
- try {
- return function.apply(pointer);
- } catch (S3Exception e) {
- LOG.error("A service exception", e);
- throw new FailedProcessingLargePayloadException(
- format("Failed processing S3 record with [Bucket Name: %s Bucket Key: %s]",
- pointer.getS3BucketName(), pointer.getS3Key()), e);
- } catch (SdkClientException e) {
- LOG.error("Some sort of client exception", e);
- throw new FailedProcessingLargePayloadException(
- format("Failed processing S3 record with [Bucket Name: %s Bucket Key: %s]",
- pointer.getS3BucketName(), pointer.getS3Key()), e);
- }
- }
-
- public static boolean placedOnSqsEventRequestHandler(ProceedingJoinPoint pjp) {
- return pjp.getArgs().length == 2
- && pjp.getArgs()[0] instanceof SQSEvent
- && pjp.getArgs()[1] instanceof Context;
- }
-
- @SuppressWarnings({"EmptyMethod"})
- @Pointcut("@annotation(sqsLargeMessage)")
- public void callAt(SqsLargeMessage sqsLargeMessage) {
- }
-
- @Around(value = "callAt(sqsLargeMessage) && execution(@SqsLargeMessage * *.*(..))", argNames = "pjp,sqsLargeMessage")
- public Object around(ProceedingJoinPoint pjp,
- SqsLargeMessage sqsLargeMessage) throws Throwable {
- Object[] proceedArgs = pjp.getArgs();
-
- if (isHandlerMethod(pjp)
- && placedOnSqsEventRequestHandler(pjp)) {
- List pointersToDelete = rewriteMessages((SQSEvent) proceedArgs[0]);
-
- Object proceed = pjp.proceed(proceedArgs);
-
- if (sqsLargeMessage.deletePayloads()) {
- pointersToDelete.forEach(SqsLargeMessageAspect::deleteMessage);
- }
- return proceed;
- }
-
- return pjp.proceed(proceedArgs);
- }
-
- private List rewriteMessages(SQSEvent sqsEvent) {
- List records = sqsEvent.getRecords();
- return processMessages(records);
- }
-
- public static class FailedProcessingLargePayloadException extends RuntimeException {
- public FailedProcessingLargePayloadException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public FailedProcessingLargePayloadException(String message) {
- super(message);
- }
- }
-}
diff --git a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/SqsMessageBatchProcessorAspect.java b/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/SqsMessageBatchProcessorAspect.java
deleted file mode 100644
index ff0b5b014..000000000
--- a/powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/internal/SqsMessageBatchProcessorAspect.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.internal;
-
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.isHandlerMethod;
-import static software.amazon.lambda.powertools.sqs.SqsUtils.batchProcessor;
-import static software.amazon.lambda.powertools.sqs.internal.SqsLargeMessageAspect.placedOnSqsEventRequestHandler;
-
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-import software.amazon.lambda.powertools.sqs.SqsBatch;
-
-@Aspect
-public class SqsMessageBatchProcessorAspect {
-
- @SuppressWarnings({"EmptyMethod"})
- @Pointcut("@annotation(sqsBatch)")
- public void callAt(SqsBatch sqsBatch) {
- }
-
- @Around(value = "callAt(sqsBatch) && execution(@SqsBatch * *.*(..))", argNames = "pjp,sqsBatch")
- public Object around(ProceedingJoinPoint pjp,
- SqsBatch sqsBatch) throws Throwable {
- Object[] proceedArgs = pjp.getArgs();
-
- if (isHandlerMethod(pjp)
- && placedOnSqsEventRequestHandler(pjp)) {
-
- SQSEvent sqsEvent = (SQSEvent) proceedArgs[0];
-
- batchProcessor(sqsEvent,
- sqsBatch.suppressException(),
- sqsBatch.value(),
- sqsBatch.deleteNonRetryableMessageFromQueue(),
- sqsBatch.nonRetryableExceptions());
- }
-
- return pjp.proceed(proceedArgs);
- }
-}
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SampleSqsHandler.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SampleSqsHandler.java
deleted file mode 100644
index 557aa214d..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SampleSqsHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs;
-
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-
-public class SampleSqsHandler implements SqsMessageHandler {
- private int counter;
-
- @Override
- public String process(SQSEvent.SQSMessage message) {
- return String.valueOf(counter++);
- }
-}
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsBatchProcessorTest.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsBatchProcessorTest.java
deleted file mode 100644
index c0c334e78..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsBatchProcessorTest.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoInteractions;
-import static org.mockito.Mockito.when;
-import static software.amazon.lambda.powertools.sqs.SqsUtils.batchProcessor;
-import static software.amazon.lambda.powertools.sqs.SqsUtils.overrideSqsClient;
-
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-import org.mockito.ArgumentCaptor;
-import software.amazon.awssdk.services.sqs.SqsClient;
-import software.amazon.awssdk.services.sqs.model.DeleteMessageBatchRequest;
-import software.amazon.awssdk.services.sqs.model.GetQueueAttributesRequest;
-import software.amazon.awssdk.services.sqs.model.GetQueueAttributesResponse;
-import software.amazon.awssdk.services.sqs.model.QueueAttributeName;
-import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequest;
-
-class SqsUtilsBatchProcessorTest {
-
- private static final SqsClient sqsClient = mock(SqsClient.class);
- private static final SqsClient interactionClient = mock(SqsClient.class);
- private static final ObjectMapper MAPPER = new ObjectMapper();
- private SQSEvent event;
-
- @BeforeEach
- void setUp() throws IOException {
- reset(sqsClient, interactionClient);
- event = MAPPER.readValue(this.getClass().getResource("/sampleSqsBatchEvent.json"), SQSEvent.class);
- overrideSqsClient(sqsClient);
- }
-
- @Test
- void shouldBatchProcessAndNotDeleteMessagesWhenAllSuccess() {
- List returnValues = batchProcessor(event, false, (message) ->
- {
- interactionClient.listQueues();
- return "Success";
- });
-
- assertThat(returnValues)
- .hasSize(2)
- .containsExactly("Success", "Success");
-
- verify(interactionClient, times(2)).listQueues();
- verifyNoInteractions(sqsClient);
- }
-
- @ParameterizedTest
- @ValueSource(classes = {SampleInnerSqsHandler.class, SampleSqsHandler.class})
- void shouldBatchProcessViaClassAndNotDeleteMessagesWhenAllSuccess(
- Class extends SqsMessageHandler> handler) {
- List returnValues = batchProcessor(event, handler);
-
- assertThat(returnValues)
- .hasSize(2)
- .containsExactly("0", "1");
-
- verifyNoInteractions(sqsClient);
- }
-
- @Test
- void shouldBatchProcessAndDeleteSuccessMessageOnPartialFailures() {
- String failedId = "2e1424d4-f796-459a-8184-9c92662be6da";
-
- SqsMessageHandler failedHandler = (message) ->
- {
- if (failedId.equals(message.getMessageId())) {
- throw new RuntimeException("Failed processing");
- }
-
- interactionClient.listQueues();
- return "Success";
- };
-
- assertThatExceptionOfType(SQSBatchProcessingException.class)
- .isThrownBy(() -> batchProcessor(event, failedHandler))
- .satisfies(e ->
- {
-
- assertThat(e.successMessageReturnValues())
- .hasSize(1)
- .contains("Success");
-
- assertThat(e.getFailures())
- .hasSize(1)
- .extracting("messageId")
- .contains(failedId);
-
- assertThat(e.getExceptions())
- .hasSize(1)
- .extracting("detailMessage")
- .contains("Failed processing");
- });
-
- verify(interactionClient).listQueues();
-
- ArgumentCaptor captor = ArgumentCaptor.forClass(DeleteMessageBatchRequest.class);
- verify(sqsClient).deleteMessageBatch(captor.capture());
-
- assertThat(captor.getValue())
- .hasFieldOrPropertyWithValue("queueUrl", "https://sqs.us-east-2.amazonaws.com/123456789012/my-queue");
- }
-
- @Test
- void shouldBatchProcessAndFullFailuresInBatch() {
- SqsMessageHandler failedHandler = (message) ->
- {
- throw new RuntimeException(message.getMessageId());
- };
-
- assertThatExceptionOfType(SQSBatchProcessingException.class)
- .isThrownBy(() -> batchProcessor(event, failedHandler))
- .satisfies(e ->
- {
-
- assertThat(e.successMessageReturnValues())
- .isEmpty();
-
- assertThat(e.getFailures())
- .hasSize(2)
- .extracting("messageId")
- .containsExactly("059f36b4-87a3-44ab-83d2-661975830a7d",
- "2e1424d4-f796-459a-8184-9c92662be6da");
-
- assertThat(e.getExceptions())
- .hasSize(2)
- .extracting("detailMessage")
- .containsExactly("059f36b4-87a3-44ab-83d2-661975830a7d",
- "2e1424d4-f796-459a-8184-9c92662be6da");
- });
-
- verifyNoInteractions(sqsClient);
- }
-
- @Test
- void shouldBatchProcessViaClassAndDeleteSuccessMessageOnPartialFailures() {
- assertThatExceptionOfType(SQSBatchProcessingException.class)
- .isThrownBy(() -> batchProcessor(event, FailureSampleInnerSqsHandler.class))
- .satisfies(e ->
- {
-
- assertThat(e.successMessageReturnValues())
- .hasSize(1)
- .contains("Success");
-
- assertThat(e.getFailures())
- .hasSize(1)
- .extracting("messageId")
- .contains("2e1424d4-f796-459a-8184-9c92662be6da");
-
- assertThat(e.getExceptions())
- .hasSize(1)
- .extracting("detailMessage")
- .contains("Failed processing");
- });
-
- verify(sqsClient).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- }
-
-
- @Test
- void shouldBatchProcessAndSuppressExceptions() {
- String failedId = "2e1424d4-f796-459a-8184-9c92662be6da";
-
- SqsMessageHandler failedHandler = (message) ->
- {
- if (failedId.equals(message.getMessageId())) {
- throw new RuntimeException("Failed processing");
- }
-
- interactionClient.listQueues();
- return "Success";
- };
-
- List returnValues = batchProcessor(event, true, failedHandler);
-
- assertThat(returnValues)
- .hasSize(1)
- .contains("Success");
-
- verify(interactionClient).listQueues();
- verify(sqsClient).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- }
-
- @Test
- void shouldBatchProcessViaClassAndSuppressExceptions() {
- List returnValues = batchProcessor(event, true, FailureSampleInnerSqsHandler.class);
-
- assertThat(returnValues)
- .hasSize(1)
- .contains("Success");
-
- verify(interactionClient).listQueues();
- verify(sqsClient).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- }
-
- @Test
- void shouldBatchProcessAndMoveNonRetryableExceptionToDlq() {
- String failedId = "2e1424d4-f796-459a-8184-9c92662be6da";
- HashMap attributes = new HashMap<>();
-
- attributes.put(QueueAttributeName.REDRIVE_POLICY, "{\n" +
- " \"deadLetterTargetArn\": \"arn:aws:sqs:us-east-2:123456789012:retry-queue\",\n" +
- " \"maxReceiveCount\": 2\n" +
- "}");
-
- when(sqsClient.getQueueAttributes(any(GetQueueAttributesRequest.class))).thenReturn(
- GetQueueAttributesResponse.builder()
- .attributes(attributes)
- .build());
-
- List batchProcessor = batchProcessor(event, (message) ->
- {
- if (failedId.equals(message.getMessageId())) {
- throw new IllegalStateException("Failed processing");
- }
-
- interactionClient.listQueues();
- return "Success";
- }, IllegalStateException.class, IllegalArgumentException.class);
-
- assertThat(batchProcessor)
- .hasSize(1);
-
- verify(sqsClient).sendMessageBatch(any(SendMessageBatchRequest.class));
- }
-
- @Test
- void shouldBatchProcessAndDeleteNonRetryableException() {
- String failedId = "2e1424d4-f796-459a-8184-9c92662be6da";
- HashMap attributes = new HashMap<>();
-
- attributes.put(QueueAttributeName.REDRIVE_POLICY, "{\n" +
- " \"deadLetterTargetArn\": \"arn:aws:sqs:us-east-2:123456789012:retry-queue\",\n" +
- " \"maxReceiveCount\": 2\n" +
- "}");
-
- when(sqsClient.getQueueAttributes(any(GetQueueAttributesRequest.class))).thenReturn(
- GetQueueAttributesResponse.builder()
- .attributes(attributes)
- .build());
-
- List batchProcessor = batchProcessor(event, false, (message) ->
- {
- if (failedId.equals(message.getMessageId())) {
- throw new IllegalStateException("Failed processing");
- }
-
- interactionClient.listQueues();
- return "Success";
- }, true, IllegalStateException.class, IllegalArgumentException.class);
-
- assertThat(batchProcessor)
- .hasSize(1);
-
- verify(sqsClient, times(0)).sendMessageBatch(any(SendMessageBatchRequest.class));
- verify(sqsClient).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- }
-
- @Test
- void shouldDeleteSuccessfulMessageInBatchesOfT10orLess() throws IOException {
- SQSEvent batch25Message =
- MAPPER.readValue(this.getClass().getResource("/sampleSqsBatchEventBatchSize25.json"), SQSEvent.class);
-
- assertThatExceptionOfType(SQSBatchProcessingException.class)
- .isThrownBy(() -> batchProcessor(batch25Message, FailureSampleInnerSqsHandler.class))
- .satisfies(e ->
- {
-
- assertThat(e.successMessageReturnValues())
- .hasSize(24)
- .contains("Success");
-
- assertThat(e.getFailures())
- .hasSize(1)
- .extracting("messageId")
- .contains("2e1424d4-f796-459a-8184-9c92662be6da");
-
- assertThat(e.getExceptions())
- .hasSize(1)
- .extracting("detailMessage")
- .contains("Failed processing");
- });
-
- ArgumentCaptor captor = ArgumentCaptor.forClass(DeleteMessageBatchRequest.class);
-
- verify(sqsClient, times(3)).deleteMessageBatch(captor.capture());
-
- assertThat(captor.getAllValues())
- .hasSize(3)
- .flatMap(DeleteMessageBatchRequest::entries)
- .hasSize(24);
- }
-
- @Test
- void shouldBatchProcessAndMoveNonRetryableExceptionToDlqInBatchesOfT10orLess() throws IOException {
- SQSEvent batch25Message =
- MAPPER.readValue(this.getClass().getResource("/sampleSqsBatchEventBatchSize25.json"), SQSEvent.class);
-
- HashMap attributes = new HashMap<>();
-
- attributes.put(QueueAttributeName.REDRIVE_POLICY, "{\n" +
- " \"deadLetterTargetArn\": \"arn:aws:sqs:us-east-2:123456789012:retry-queue\",\n" +
- " \"maxReceiveCount\": 2\n" +
- "}");
-
- when(sqsClient.getQueueAttributes(any(GetQueueAttributesRequest.class))).thenReturn(
- GetQueueAttributesResponse.builder()
- .attributes(attributes)
- .build());
-
- List batchProcessor = batchProcessor(batch25Message, (message) ->
- {
- if ("2e1424d4-f796-459a-8184-9c92662be6da".equals(message.getMessageId())) {
- interactionClient.listQueues();
- return "Success";
- }
-
- throw new IllegalStateException("Failed processing");
- }, IllegalStateException.class, IllegalArgumentException.class);
-
- assertThat(batchProcessor)
- .hasSize(1);
-
- ArgumentCaptor captor = ArgumentCaptor.forClass(SendMessageBatchRequest.class);
-
-
- verify(sqsClient, times(3)).sendMessageBatch(captor.capture());
-
- assertThat(captor.getAllValues())
- .hasSize(3)
- .flatMap(SendMessageBatchRequest::entries)
- .hasSize(24);
- }
-
- public class SampleInnerSqsHandler implements SqsMessageHandler {
- private int counter;
-
- @Override
- public String process(SQSMessage message) {
- interactionClient.listQueues();
- return String.valueOf(counter++);
- }
- }
-
- public class FailureSampleInnerSqsHandler implements SqsMessageHandler {
- @Override
- public String process(SQSEvent.SQSMessage message) {
- if ("2e1424d4-f796-459a-8184-9c92662be6da".equals(message.getMessageId())) {
- throw new RuntimeException("Failed processing");
- }
-
- interactionClient.listQueues();
- return "Success";
- }
- }
-}
\ No newline at end of file
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsFifoBatchProcessorTest.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsFifoBatchProcessorTest.java
deleted file mode 100644
index bfc555405..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsFifoBatchProcessorTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static software.amazon.lambda.powertools.sqs.SqsUtils.batchProcessor;
-import static software.amazon.lambda.powertools.sqs.SqsUtils.overrideSqsClient;
-
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import com.amazonaws.services.lambda.runtime.tests.EventLoader;
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoSession;
-import org.mockito.quality.Strictness;
-import software.amazon.awssdk.services.sqs.SqsClient;
-import software.amazon.awssdk.services.sqs.model.DeleteMessageBatchRequest;
-import software.amazon.awssdk.services.sqs.model.DeleteMessageBatchRequestEntry;
-import software.amazon.awssdk.services.sqs.model.DeleteMessageBatchResponse;
-
-public class SqsUtilsFifoBatchProcessorTest {
-
- private static SQSEvent sqsBatchEvent;
- private MockitoSession session;
-
- @Mock
- private SqsClient sqsClient;
-
- @Captor
- private ArgumentCaptor deleteMessageBatchCaptor;
-
- public SqsUtilsFifoBatchProcessorTest() throws IOException {
- sqsBatchEvent = EventLoader.loadSQSEvent("SqsFifoBatchEvent.json");
- }
-
- @BeforeEach
- public void setup() {
- // Establish a strict mocking session. This means that any
- // calls to a mock that have not been stubbed will throw
- this.session = Mockito.mockitoSession()
- .strictness(Strictness.STRICT_STUBS)
- .initMocks(this)
- .startMocking();
-
- overrideSqsClient(sqsClient);
- }
-
- @AfterEach
- public void tearDown() {
- session.finishMocking();
- }
-
- @Test
- public void processWholeBatch() {
- // Act
- AtomicInteger processedCount = new AtomicInteger();
- List results = batchProcessor(sqsBatchEvent, false, (message) ->
- {
- processedCount.getAndIncrement();
- return true;
- });
-
- // Assert
- assertThat(processedCount.get()).isEqualTo(3);
- assertThat(results.size()).isEqualTo(3);
- }
-
- /**
- * Check that a failure in the middle of the batch:
- * - deletes the successful message explicitly from SQS
- * - marks the failed and subsequent message as failed
- * - does not delete the failed or subsequent message
- */
- @Test
- public void singleFailureInMiddleOfBatch() {
- // Arrange
- Mockito.when(sqsClient.deleteMessageBatch(deleteMessageBatchCaptor.capture()))
- .thenReturn(DeleteMessageBatchResponse
- .builder().build());
-
- // Act
- AtomicInteger processedCount = new AtomicInteger();
- assertThatExceptionOfType(SQSBatchProcessingException.class)
- .isThrownBy(() -> batchProcessor(sqsBatchEvent, false, (message) ->
- {
- int value = processedCount.getAndIncrement();
- if (value == 1) {
- throw new RuntimeException("Whoops");
- }
- return true;
- }))
-
- // Assert
- .isInstanceOf(SQSBatchProcessingException.class)
- .satisfies(e ->
- {
- List failures = ((SQSBatchProcessingException) e).getFailures();
- assertThat(failures.size()).isEqualTo(2);
- List failureIds = failures.stream()
- .map(SQSEvent.SQSMessage::getMessageId)
- .collect(Collectors.toList());
- assertThat(failureIds).contains(sqsBatchEvent.getRecords().get(1).getMessageId());
- assertThat(failureIds).contains(sqsBatchEvent.getRecords().get(2).getMessageId());
- });
-
- DeleteMessageBatchRequest deleteRequest = deleteMessageBatchCaptor.getValue();
- List messageIds = deleteRequest.entries().stream()
- .map(DeleteMessageBatchRequestEntry::id)
- .collect(Collectors.toList());
- assertThat(deleteRequest.entries().size()).isEqualTo(1);
- assertThat(messageIds.contains(sqsBatchEvent.getRecords().get(0).getMessageId())).isTrue();
-
- }
-
- @Test
- public void singleFailureAtEndOfBatch() {
-
- // Arrange
- Mockito.when(sqsClient.deleteMessageBatch(deleteMessageBatchCaptor.capture()))
- .thenReturn(DeleteMessageBatchResponse
- .builder().build());
-
-
- // Act
- AtomicInteger processedCount = new AtomicInteger();
- assertThatExceptionOfType(SQSBatchProcessingException.class)
- .isThrownBy(() -> batchProcessor(sqsBatchEvent, false, (message) ->
- {
- int value = processedCount.getAndIncrement();
- if (value == 2) {
- throw new RuntimeException("Whoops");
- }
- return true;
- }));
-
- // Assert
- DeleteMessageBatchRequest deleteRequest = deleteMessageBatchCaptor.getValue();
- List messageIds = deleteRequest.entries().stream()
- .map(DeleteMessageBatchRequestEntry::id)
- .collect(Collectors.toList());
- assertThat(deleteRequest.entries().size()).isEqualTo(2);
- assertThat(messageIds.contains(sqsBatchEvent.getRecords().get(0).getMessageId())).isTrue();
- assertThat(messageIds.contains(sqsBatchEvent.getRecords().get(1).getMessageId())).isTrue();
- assertThat(messageIds.contains(sqsBatchEvent.getRecords().get(2).getMessageId())).isFalse();
- }
-
- @Test
- public void messageFailureStopsGroupProcessing() {
- String groupToFail = sqsBatchEvent.getRecords().get(0).getAttributes().get("MessageGroupId");
-
- assertThatExceptionOfType(SQSBatchProcessingException.class)
- .isThrownBy(() -> batchProcessor(sqsBatchEvent, (message) ->
- {
- String groupId = message.getAttributes().get("MessageGroupId");
- if (groupId.equals(groupToFail)) {
- throw new RuntimeException("Failed processing");
- }
- return groupId;
- }))
- .satisfies(e ->
- {
- assertThat(e.successMessageReturnValues().size()).isEqualTo(0);
- assertThat(e.successMessageReturnValues().contains(groupToFail)).isFalse();
- });
- }
-
-}
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsLargeMessageTest.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsLargeMessageTest.java
deleted file mode 100644
index afc426976..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/SqsUtilsLargeMessageTest.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static java.util.Collections.singletonList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoInteractions;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.openMocks;
-
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
-import org.junit.jupiter.params.provider.ValueSource;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import software.amazon.awssdk.core.ResponseInputStream;
-import software.amazon.awssdk.core.exception.SdkClientException;
-import software.amazon.awssdk.http.AbortableInputStream;
-import software.amazon.awssdk.services.s3.S3Client;
-import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
-import software.amazon.awssdk.services.s3.model.GetObjectRequest;
-import software.amazon.awssdk.services.s3.model.GetObjectResponse;
-import software.amazon.awssdk.services.s3.model.S3Exception;
-import software.amazon.awssdk.utils.StringInputStream;
-import software.amazon.lambda.powertools.sqs.internal.SqsLargeMessageAspect;
-
-class SqsUtilsLargeMessageTest {
-
- private static final String BUCKET_NAME = "ms-extended-sqs-client";
- private static final String BUCKET_KEY = "c71eb2ae-37e0-4265-8909-32f4153faddf";
- @Mock
- private S3Client s3Client;
-
- private static Stream exception() {
- return Stream.of(Arguments.of(S3Exception.builder()
- .message("Service Exception")
- .build()),
- Arguments.of(SdkClientException.builder()
- .message("Client Exception")
- .build()));
- }
-
- @BeforeEach
- void setUp() {
- openMocks(this);
- SqsUtils.overrideS3Client(s3Client);
- }
-
- @Test
- public void testLargeMessage() {
- ResponseInputStream s3Response =
- new ResponseInputStream<>(GetObjectResponse.builder().build(),
- AbortableInputStream.create(new ByteArrayInputStream("A big message".getBytes())));
- when(s3Client.getObject(any(GetObjectRequest.class))).thenReturn(s3Response);
-
- SQSEvent sqsEvent = messageWithBody(
- "[\"software.amazon.payloadoffloading.PayloadS3Pointer\",{\"s3BucketName\":\"" + BUCKET_NAME +
- "\",\"s3Key\":\"" + BUCKET_KEY + "\"}]");
-
- Map sqsMessage = SqsUtils.enrichedMessageFromS3(sqsEvent, sqsMessages ->
- {
- Map someBusinessLogic = new HashMap<>();
- someBusinessLogic.put("Message", sqsMessages.get(0).getBody());
- return someBusinessLogic;
- });
-
- assertThat(sqsMessage)
- .hasSize(1)
- .containsEntry("Message", "A big message");
-
- ArgumentCaptor delete = ArgumentCaptor.forClass(DeleteObjectRequest.class);
-
- verify(s3Client).deleteObject(delete.capture());
-
- Assertions.assertThat(delete.getValue())
- .satisfies((Consumer) deleteObjectRequest ->
- {
- assertThat(deleteObjectRequest.bucket())
- .isEqualTo(BUCKET_NAME);
-
- assertThat(deleteObjectRequest.key())
- .isEqualTo(BUCKET_KEY);
- });
- }
-
- @ParameterizedTest
- @ValueSource(booleans = {true, false})
- public void testLargeMessageDeleteFromS3Toggle(boolean deleteS3Payload) {
- ResponseInputStream s3Response =
- new ResponseInputStream<>(GetObjectResponse.builder().build(),
- AbortableInputStream.create(new ByteArrayInputStream("A big message".getBytes())));
-
- when(s3Client.getObject(any(GetObjectRequest.class))).thenReturn(s3Response);
-
- SQSEvent sqsEvent = messageWithBody(
- "[\"software.amazon.payloadoffloading.PayloadS3Pointer\",{\"s3BucketName\":\"" + BUCKET_NAME +
- "\",\"s3Key\":\"" + BUCKET_KEY + "\"}]");
-
- Map sqsMessage = SqsUtils.enrichedMessageFromS3(sqsEvent, deleteS3Payload, sqsMessages ->
- {
- Map someBusinessLogic = new HashMap<>();
- someBusinessLogic.put("Message", sqsMessages.get(0).getBody());
- return someBusinessLogic;
- });
-
- assertThat(sqsMessage)
- .hasSize(1)
- .containsEntry("Message", "A big message");
- if (deleteS3Payload) {
- ArgumentCaptor delete = ArgumentCaptor.forClass(DeleteObjectRequest.class);
-
- verify(s3Client).deleteObject(delete.capture());
-
- Assertions.assertThat(delete.getValue())
- .satisfies((Consumer) deleteObjectRequest ->
- {
- assertThat(deleteObjectRequest.bucket())
- .isEqualTo(BUCKET_NAME);
-
- assertThat(deleteObjectRequest.key())
- .isEqualTo(BUCKET_KEY);
- });
- } else {
- verify(s3Client, never()).deleteObject(any(DeleteObjectRequest.class));
- }
- }
-
- @Test
- public void shouldNotProcessSmallMessageBody() {
- ResponseInputStream s3Response =
- new ResponseInputStream<>(GetObjectResponse.builder().build(),
- AbortableInputStream.create(new ByteArrayInputStream("A big message".getBytes())));
-
- when(s3Client.getObject(any(GetObjectRequest.class))).thenReturn(s3Response);
-
- SQSEvent sqsEvent = messageWithBody("This is small message");
-
- Map sqsMessage = SqsUtils.enrichedMessageFromS3(sqsEvent, sqsMessages ->
- {
- Map someBusinessLogic = new HashMap<>();
- someBusinessLogic.put("Message", sqsMessages.get(0).getBody());
- return someBusinessLogic;
- });
-
- assertThat(sqsMessage)
- .containsEntry("Message", "This is small message");
-
- verifyNoInteractions(s3Client);
- }
-
- @ParameterizedTest
- @MethodSource("exception")
- public void shouldFailEntireBatchIfFailedDownloadingFromS3(RuntimeException exception) {
- when(s3Client.getObject(any(GetObjectRequest.class))).thenThrow(exception);
-
- String messageBody =
- "[\"software.amazon.payloadoffloading.PayloadS3Pointer\",{\"s3BucketName\":\"" + BUCKET_NAME +
- "\",\"s3Key\":\"" + BUCKET_KEY + "\"}]";
- SQSEvent sqsEvent = messageWithBody(messageBody);
-
- assertThatExceptionOfType(SqsLargeMessageAspect.FailedProcessingLargePayloadException.class)
- .isThrownBy(() -> SqsUtils.enrichedMessageFromS3(sqsEvent, sqsMessages -> sqsMessages.get(0).getBody()))
- .withCause(exception);
-
- verify(s3Client, never()).deleteObject(any(DeleteObjectRequest.class));
- }
-
- @Test
- public void shouldFailEntireBatchIfFailedProcessingDownloadMessageFromS3() {
- ResponseInputStream s3Response =
- new ResponseInputStream<>(GetObjectResponse.builder().build(),
- AbortableInputStream.create(new StringInputStream("test") {
- @Override
- public void close() throws IOException {
- throw new IOException("Failed");
- }
- }));
-
- when(s3Client.getObject(any(GetObjectRequest.class))).thenReturn(s3Response);
-
- String messageBody =
- "[\"software.amazon.payloadoffloading.PayloadS3Pointer\",{\"s3BucketName\":\"" + BUCKET_NAME +
- "\",\"s3Key\":\"" + BUCKET_KEY + "\"}]";
- SQSEvent sqsEvent = messageWithBody(messageBody);
-
- assertThatExceptionOfType(SqsLargeMessageAspect.FailedProcessingLargePayloadException.class)
- .isThrownBy(() -> SqsUtils.enrichedMessageFromS3(sqsEvent, sqsMessages -> sqsMessages.get(0).getBody()))
- .withCauseInstanceOf(IOException.class);
-
- verify(s3Client, never()).deleteObject(any(DeleteObjectRequest.class));
- }
-
- private SQSEvent messageWithBody(String messageBody) {
- SQSMessage sqsMessage = new SQSMessage();
- sqsMessage.setBody(messageBody);
- SQSEvent sqsEvent = new SQSEvent();
- sqsEvent.setRecords(singletonList(sqsMessage));
- return sqsEvent;
- }
-}
\ No newline at end of file
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/LambdaHandlerApiGateway.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/LambdaHandlerApiGateway.java
deleted file mode 100644
index 3bad9644f..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/LambdaHandlerApiGateway.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.handlers;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
-import software.amazon.lambda.powertools.sqs.SampleSqsHandler;
-import software.amazon.lambda.powertools.sqs.SqsBatch;
-import software.amazon.lambda.powertools.sqs.SqsLargeMessage;
-
-public class LambdaHandlerApiGateway implements RequestHandler {
-
- @Override
- @SqsLargeMessage
- @SqsBatch(value = SampleSqsHandler.class)
- public String handleRequest(APIGatewayProxyRequestEvent sqsEvent, Context context) {
- return sqsEvent.getBody();
- }
-}
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchFailureSuppressedHandler.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchFailureSuppressedHandler.java
deleted file mode 100644
index 172179057..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchFailureSuppressedHandler.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.handlers;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static software.amazon.lambda.powertools.sqs.internal.SqsMessageBatchProcessorAspectTest.interactionClient;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import software.amazon.lambda.powertools.sqs.SqsBatch;
-import software.amazon.lambda.powertools.sqs.SqsMessageHandler;
-
-public class PartialBatchFailureSuppressedHandler implements RequestHandler {
- @Override
- @SqsBatch(value = InnerMessageHandler.class, suppressException = true)
- public String handleRequest(final SQSEvent sqsEvent,
- final Context context) {
- return "Success";
- }
-
- private class InnerMessageHandler implements SqsMessageHandler {
-
- @Override
- public String process(SQSMessage message) {
- if ("2e1424d4-f796-459a-8184-9c92662be6da".equals(message.getMessageId())) {
- throw new RuntimeException("2e1424d4-f796-459a-8184-9c92662be6da");
- }
-
- interactionClient.listQueues();
- return "Success";
- }
- }
-}
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchPartialFailureHandler.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchPartialFailureHandler.java
deleted file mode 100644
index 6e3971269..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchPartialFailureHandler.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.handlers;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static software.amazon.lambda.powertools.sqs.internal.SqsMessageBatchProcessorAspectTest.interactionClient;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import software.amazon.lambda.powertools.sqs.SqsBatch;
-import software.amazon.lambda.powertools.sqs.SqsMessageHandler;
-
-public class PartialBatchPartialFailureHandler implements RequestHandler {
- @Override
- @SqsBatch(InnerMessageHandler.class)
- public String handleRequest(final SQSEvent sqsEvent,
- final Context context) {
- return "Success";
- }
-
- private class InnerMessageHandler implements SqsMessageHandler {
-
- @Override
- public String process(SQSMessage message) {
- if ("2e1424d4-f796-459a-8184-9c92662be6da".equals(message.getMessageId())) {
- throw new RuntimeException("2e1424d4-f796-459a-8184-9c92662be6da");
- }
-
- interactionClient.listQueues();
- return "Success";
- }
- }
-}
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchSuccessHandler.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchSuccessHandler.java
deleted file mode 100644
index acfcd7109..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/PartialBatchSuccessHandler.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.handlers;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static software.amazon.lambda.powertools.sqs.internal.SqsMessageBatchProcessorAspectTest.interactionClient;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import software.amazon.lambda.powertools.sqs.SqsBatch;
-import software.amazon.lambda.powertools.sqs.SqsMessageHandler;
-
-public class PartialBatchSuccessHandler implements RequestHandler {
- @Override
- @SqsBatch(InnerMessageHandler.class)
- public String handleRequest(final SQSEvent sqsEvent,
- final Context context) {
- return "Success";
- }
-
- private class InnerMessageHandler implements SqsMessageHandler {
-
- @Override
- public String process(SQSMessage message) {
- interactionClient.listQueues();
- return "Success";
- }
- }
-}
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandler.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandler.java
deleted file mode 100644
index de096679f..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandler.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.handlers;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import software.amazon.lambda.powertools.sqs.SqsLargeMessage;
-
-public class SqsMessageHandler implements RequestHandler {
-
- @Override
- @SqsLargeMessage
- public String handleRequest(SQSEvent sqsEvent, Context context) {
- return sqsEvent.getRecords().get(0).getBody();
- }
-}
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandlerWithNonRetryableHandler.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandlerWithNonRetryableHandler.java
deleted file mode 100644
index 74ff02e2c..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandlerWithNonRetryableHandler.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.handlers;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static software.amazon.lambda.powertools.sqs.internal.SqsMessageBatchProcessorAspectTest.interactionClient;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import software.amazon.lambda.powertools.sqs.SqsBatch;
-import software.amazon.lambda.powertools.sqs.SqsMessageHandler;
-
-public class SqsMessageHandlerWithNonRetryableHandler implements RequestHandler {
-
- @Override
- @SqsBatch(value = InnerMessageHandler.class, nonRetryableExceptions = {IllegalStateException.class,
- IllegalArgumentException.class})
- public String handleRequest(final SQSEvent sqsEvent,
- final Context context) {
- return "Success";
- }
-
- private class InnerMessageHandler implements SqsMessageHandler {
-
- @Override
- public String process(SQSMessage message) {
- if (message.getMessageId().isEmpty()) {
- throw new IllegalArgumentException("Invalid message and was moved to DLQ");
- }
-
- if ("2e1424d4-f796-459a-9696-9c92662ba5da".equals(message.getMessageId())) {
- throw new RuntimeException("Invalid message and should be reprocessed");
- }
-
- interactionClient.listQueues();
- return "Success";
- }
- }
-}
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandlerWithNonRetryableHandlerWithDelete.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandlerWithNonRetryableHandlerWithDelete.java
deleted file mode 100644
index 5b341880e..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsMessageHandlerWithNonRetryableHandlerWithDelete.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.handlers;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static software.amazon.lambda.powertools.sqs.internal.SqsMessageBatchProcessorAspectTest.interactionClient;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import software.amazon.lambda.powertools.sqs.SqsBatch;
-import software.amazon.lambda.powertools.sqs.SqsMessageHandler;
-
-public class SqsMessageHandlerWithNonRetryableHandlerWithDelete implements RequestHandler {
-
- @Override
- @SqsBatch(value = InnerMessageHandler.class,
- nonRetryableExceptions = {IllegalStateException.class, IllegalArgumentException.class},
- deleteNonRetryableMessageFromQueue = true)
- public String handleRequest(final SQSEvent sqsEvent,
- final Context context) {
- return "Success";
- }
-
- private class InnerMessageHandler implements SqsMessageHandler {
-
- @Override
- public String process(SQSMessage message) {
- if (message.getMessageId().isEmpty()) {
- throw new IllegalArgumentException("Invalid message and was moved to DLQ");
- }
-
- if ("2e1424d4-f796-459a-9696-9c92662ba5da".equals(message.getMessageId())) {
- throw new RuntimeException("Invalid message and should be reprocessed");
- }
-
- interactionClient.listQueues();
- return "Success";
- }
- }
-}
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsNoDeleteMessageHandler.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsNoDeleteMessageHandler.java
deleted file mode 100644
index e96dc5581..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/handlers/SqsNoDeleteMessageHandler.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.handlers;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import software.amazon.lambda.powertools.sqs.SqsLargeMessage;
-
-public class SqsNoDeleteMessageHandler implements RequestHandler {
-
- @Override
- @SqsLargeMessage(deletePayloads = false)
- public String handleRequest(SQSEvent sqsEvent, Context context) {
- return sqsEvent.getRecords().get(0).getBody();
- }
-}
\ No newline at end of file
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/internal/SqsLargeMessageAspectTest.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/internal/SqsLargeMessageAspectTest.java
deleted file mode 100644
index 535da11c7..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/internal/SqsLargeMessageAspectTest.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.internal;
-
-import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
-import static java.util.Collections.singletonList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoInteractions;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.openMocks;
-import static software.amazon.lambda.powertools.sqs.internal.SqsLargeMessageAspect.FailedProcessingLargePayloadException;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import software.amazon.awssdk.core.ResponseInputStream;
-import software.amazon.awssdk.core.exception.SdkClientException;
-import software.amazon.awssdk.http.AbortableInputStream;
-import software.amazon.awssdk.services.s3.S3Client;
-import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
-import software.amazon.awssdk.services.s3.model.GetObjectRequest;
-import software.amazon.awssdk.services.s3.model.GetObjectResponse;
-import software.amazon.awssdk.services.s3.model.S3Exception;
-import software.amazon.awssdk.utils.StringInputStream;
-import software.amazon.lambda.powertools.sqs.SqsUtils;
-import software.amazon.lambda.powertools.sqs.handlers.LambdaHandlerApiGateway;
-import software.amazon.lambda.powertools.sqs.handlers.SqsMessageHandler;
-import software.amazon.lambda.powertools.sqs.handlers.SqsNoDeleteMessageHandler;
-
-public class SqsLargeMessageAspectTest {
-
- private static final String BUCKET_NAME = "bucketname";
- private static final String BUCKET_KEY = "c71eb2ae-37e0-4265-8909-32f4153faddf";
- private RequestHandler requestHandler;
- @Mock
- private Context context;
- @Mock
- private S3Client s3Client;
-
- private static Stream exception() {
- return Stream.of(Arguments.of(S3Exception.builder()
- .message("Service Exception")
- .build()),
- Arguments.of(SdkClientException.builder()
- .message("Client Exception")
- .build()));
- }
-
- @BeforeEach
- void setUp() {
- openMocks(this);
- setupContext();
- SqsUtils.overrideS3Client(s3Client);
- requestHandler = new SqsMessageHandler();
- }
-
- @Test
- public void testLargeMessage() {
- when(s3Client.getObject(any(GetObjectRequest.class))).thenReturn(s3ObjectWithLargeMessage());
- SQSEvent sqsEvent = messageWithBody(
- "[\"software.amazon.payloadoffloading.PayloadS3Pointer\",{\"s3BucketName\":\"" + BUCKET_NAME +
- "\",\"s3Key\":\"" + BUCKET_KEY + "\"}]");
-
- String response = requestHandler.handleRequest(sqsEvent, context);
-
- assertThat(response)
- .isEqualTo("A big message");
-
- ArgumentCaptor delete = ArgumentCaptor.forClass(DeleteObjectRequest.class);
-
- verify(s3Client).deleteObject(delete.capture());
-
- Assertions.assertThat(delete.getValue())
- .satisfies((Consumer) deleteObjectRequest ->
- {
- assertThat(deleteObjectRequest.bucket())
- .isEqualTo(BUCKET_NAME);
-
- assertThat(deleteObjectRequest.key())
- .isEqualTo(BUCKET_KEY);
- });
- }
-
- @Test
- public void shouldNotProcessSmallMessageBody() {
- when(s3Client.getObject(any(GetObjectRequest.class))).thenReturn(s3ObjectWithLargeMessage());
-
- SQSEvent sqsEvent = messageWithBody("This is small message");
-
- String response = requestHandler.handleRequest(sqsEvent, context);
-
- assertThat(response)
- .isEqualTo("This is small message");
-
- verifyNoInteractions(s3Client);
- }
-
- @ParameterizedTest
- @MethodSource("exception")
- public void shouldFailEntireBatchIfFailedDownloadingFromS3(RuntimeException exception) {
- when(s3Client.getObject(any(GetObjectRequest.class))).thenThrow(exception);
-
- String messageBody =
- "[\"software.amazon.payloadoffloading.PayloadS3Pointer\",{\"s3BucketName\":\"" + BUCKET_NAME +
- "\",\"s3Key\":\"" + BUCKET_KEY + "\"}]";
- SQSEvent sqsEvent = messageWithBody(messageBody);
-
- assertThatExceptionOfType(FailedProcessingLargePayloadException.class)
- .isThrownBy(() -> requestHandler.handleRequest(sqsEvent, context))
- .withCause(exception);
-
- verify(s3Client, never()).deleteObject(any(DeleteObjectRequest.class));
- }
-
- @Test
- public void testLargeMessageWithDeletionOff() {
- requestHandler = new SqsNoDeleteMessageHandler();
-
- when(s3Client.getObject(any(GetObjectRequest.class))).thenReturn(s3ObjectWithLargeMessage());
- SQSEvent sqsEvent = messageWithBody(
- "[\"software.amazon.payloadoffloading.PayloadS3Pointer\",{\"s3BucketName\":\"" + BUCKET_NAME +
- "\",\"s3Key\":\"" + BUCKET_KEY + "\"}]");
-
- String response = requestHandler.handleRequest(sqsEvent, context);
-
- assertThat(response).isEqualTo("A big message");
-
- verify(s3Client, never()).deleteObject(any(DeleteObjectRequest.class));
- }
-
- @Test
- public void shouldFailEntireBatchIfFailedProcessingDownloadMessageFromS3() {
- ResponseInputStream s3Response =
- new ResponseInputStream<>(GetObjectResponse.builder().build(),
- AbortableInputStream.create(new StringInputStream("test") {
- @Override
- public void close() throws IOException {
- throw new IOException("Failed");
- }
- }));
-
- when(s3Client.getObject(any(GetObjectRequest.class))).thenReturn(s3Response);
-
- String messageBody =
- "[\"software.amazon.payloadoffloading.PayloadS3Pointer\",{\"s3BucketName\":\"" + BUCKET_NAME +
- "\",\"s3Key\":\"" + BUCKET_KEY + "\"}]";
- SQSEvent sqsEvent = messageWithBody(messageBody);
-
- assertThatExceptionOfType(FailedProcessingLargePayloadException.class)
- .isThrownBy(() -> requestHandler.handleRequest(sqsEvent, context))
- .withCauseInstanceOf(IOException.class);
-
- verify(s3Client, never()).deleteObject(any(DeleteObjectRequest.class));
- }
-
- @Test
- public void shouldNotDoAnyProcessingWhenNotSqsEvent() {
- LambdaHandlerApiGateway handler = new LambdaHandlerApiGateway();
-
- String messageBody =
- "[\"software.amazon.payloadoffloading.PayloadS3Pointer\",{\"s3BucketName\":\"" + BUCKET_NAME +
- "\",\"s3Key\":\"" + BUCKET_KEY + "\"}]";
-
- APIGatewayProxyRequestEvent event = new APIGatewayProxyRequestEvent();
- event.setBody(messageBody);
- String response = handler.handleRequest(event, context);
-
- assertThat(response)
- .isEqualTo(messageBody);
-
- verifyNoInteractions(s3Client);
- }
-
- private ResponseInputStream s3ObjectWithLargeMessage() {
- return new ResponseInputStream<>(GetObjectResponse.builder().build(),
- AbortableInputStream.create(new ByteArrayInputStream("A big message".getBytes())));
- }
-
- private SQSEvent messageWithBody(String messageBody) {
- SQSMessage sqsMessage = new SQSMessage();
- sqsMessage.setBody(messageBody);
- SQSEvent sqsEvent = new SQSEvent();
- sqsEvent.setRecords(singletonList(sqsMessage));
- return sqsEvent;
- }
-
- private void setupContext() {
- when(context.getFunctionName()).thenReturn("testFunction");
- when(context.getInvokedFunctionArn()).thenReturn("testArn");
- when(context.getFunctionVersion()).thenReturn("1");
- when(context.getMemoryLimitInMB()).thenReturn(10);
- }
-}
\ No newline at end of file
diff --git a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/internal/SqsMessageBatchProcessorAspectTest.java b/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/internal/SqsMessageBatchProcessorAspectTest.java
deleted file mode 100644
index c0211cb83..000000000
--- a/powertools-sqs/src/test/java/software/amazon/lambda/powertools/sqs/internal/SqsMessageBatchProcessorAspectTest.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.sqs.internal;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoInteractions;
-import static org.mockito.Mockito.when;
-import static software.amazon.lambda.powertools.sqs.SqsUtils.overrideSqsClient;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import java.util.HashMap;
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentCaptor;
-import software.amazon.awssdk.services.sqs.SqsClient;
-import software.amazon.awssdk.services.sqs.model.BatchResultErrorEntry;
-import software.amazon.awssdk.services.sqs.model.DeleteMessageBatchRequest;
-import software.amazon.awssdk.services.sqs.model.GetQueueAttributesRequest;
-import software.amazon.awssdk.services.sqs.model.GetQueueAttributesResponse;
-import software.amazon.awssdk.services.sqs.model.QueueAttributeName;
-import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequest;
-import software.amazon.awssdk.services.sqs.model.SendMessageBatchResponse;
-import software.amazon.lambda.powertools.sqs.SQSBatchProcessingException;
-import software.amazon.lambda.powertools.sqs.handlers.LambdaHandlerApiGateway;
-import software.amazon.lambda.powertools.sqs.handlers.PartialBatchFailureSuppressedHandler;
-import software.amazon.lambda.powertools.sqs.handlers.PartialBatchPartialFailureHandler;
-import software.amazon.lambda.powertools.sqs.handlers.PartialBatchSuccessHandler;
-import software.amazon.lambda.powertools.sqs.handlers.SqsMessageHandlerWithNonRetryableHandler;
-import software.amazon.lambda.powertools.sqs.handlers.SqsMessageHandlerWithNonRetryableHandlerWithDelete;
-
-public class SqsMessageBatchProcessorAspectTest {
- public static final SqsClient interactionClient = mock(SqsClient.class);
- private static final SqsClient sqsClient = mock(SqsClient.class);
- private static final ObjectMapper MAPPER = new ObjectMapper();
- private final Context context = mock(Context.class);
- private SQSEvent event;
- private RequestHandler requestHandler;
-
- @BeforeEach
- void setUp() throws IOException {
- overrideSqsClient(sqsClient);
- reset(interactionClient);
- reset(sqsClient);
- setupContext();
- event = MAPPER.readValue(this.getClass().getResource("/sampleSqsBatchEvent.json"), SQSEvent.class);
- requestHandler = new PartialBatchSuccessHandler();
- }
-
- @Test
- void shouldBatchProcessAllMessageSuccessfullyAndNotDeleteFromSQS() {
- requestHandler.handleRequest(event, context);
-
- verify(interactionClient, times(2)).listQueues();
- verify(sqsClient, times(0)).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- }
-
- @Test
- void shouldBatchProcessMessageWithSuccessDeletedOnFailureInBatchFromSQS() {
- requestHandler = new PartialBatchPartialFailureHandler();
-
- assertThatExceptionOfType(SQSBatchProcessingException.class)
- .isThrownBy(() -> requestHandler.handleRequest(event, context))
- .satisfies(e ->
- {
- assertThat(e.getExceptions())
- .hasSize(1)
- .extracting("message")
- .containsExactly("2e1424d4-f796-459a-8184-9c92662be6da");
-
- assertThat(e.getFailures())
- .hasSize(1)
- .extracting("messageId")
- .containsExactly("2e1424d4-f796-459a-8184-9c92662be6da");
-
- assertThat(e.successMessageReturnValues())
- .hasSize(1)
- .contains("Success");
- });
-
- verify(interactionClient).listQueues();
- verify(sqsClient).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- }
-
- @Test
- void shouldBatchProcessMessageWithSuccessDeletedOnFailureWithSuppressionInBatchFromSQS() {
- requestHandler = new PartialBatchFailureSuppressedHandler();
-
- requestHandler.handleRequest(event, context);
-
- verify(interactionClient).listQueues();
- verify(sqsClient).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- }
-
- @Test
- void shouldNotTakeEffectOnNonSqsEventHandler() {
- LambdaHandlerApiGateway handlerApiGateway = new LambdaHandlerApiGateway();
-
- handlerApiGateway.handleRequest(mock(APIGatewayProxyRequestEvent.class), context);
-
- verifyNoInteractions(sqsClient);
- }
-
- @Test
- void shouldBatchProcessAndMoveNonRetryableExceptionToDlq() {
- requestHandler = new SqsMessageHandlerWithNonRetryableHandler();
- event.getRecords().get(0).setMessageId("");
-
- HashMap attributes = new HashMap<>();
-
- attributes.put(QueueAttributeName.REDRIVE_POLICY, "{\n" +
- " \"deadLetterTargetArn\": \"arn:aws:sqs:us-east-2:123456789012:retry-queue\",\n" +
- " \"maxReceiveCount\": 2\n" +
- "}");
-
- when(sqsClient.getQueueAttributes(any(GetQueueAttributesRequest.class))).thenReturn(
- GetQueueAttributesResponse.builder()
- .attributes(attributes)
- .build());
-
- requestHandler.handleRequest(event, context);
-
- verify(interactionClient).listQueues();
- verify(sqsClient).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- verify(sqsClient).sendMessageBatch(any(SendMessageBatchRequest.class));
- }
-
- @Test
- void shouldBatchProcessAndThrowExceptionForNonRetryableExceptionWhenMoveToDlqReturnFailedResponse() {
- requestHandler = new SqsMessageHandlerWithNonRetryableHandler();
- event.getRecords().get(0).setMessageId("");
-
- when(sqsClient.sendMessageBatch(any(SendMessageBatchRequest.class))).thenReturn(
- SendMessageBatchResponse.builder()
- .failed(BatchResultErrorEntry.builder()
- .message("Permission Error")
- .code("KMS.AccessDeniedException")
- .senderFault(true)
- .build())
- .build());
-
- HashMap attributes = new HashMap<>();
-
- attributes.put(QueueAttributeName.REDRIVE_POLICY, "{\n" +
- " \"deadLetterTargetArn\": \"arn:aws:sqs:us-east-2:123456789012:retry-queue\",\n" +
- " \"maxReceiveCount\": 2\n" +
- "}");
-
- when(sqsClient.getQueueAttributes(any(GetQueueAttributesRequest.class))).thenReturn(
- GetQueueAttributesResponse.builder()
- .attributes(attributes)
- .build());
-
- Assertions.assertThatExceptionOfType(SQSBatchProcessingException.class).
- isThrownBy(() -> requestHandler.handleRequest(event, context));
-
- verify(interactionClient).listQueues();
- verify(sqsClient).sendMessageBatch(any(SendMessageBatchRequest.class));
- verify(sqsClient).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- }
-
- @Test
- void shouldBatchProcessAndDeleteNonRetryableExceptionMessage() {
- requestHandler = new SqsMessageHandlerWithNonRetryableHandlerWithDelete();
- event.getRecords().get(0).setMessageId("");
-
- requestHandler.handleRequest(event, context);
-
- verify(interactionClient).listQueues();
- ArgumentCaptor captor = ArgumentCaptor.forClass(DeleteMessageBatchRequest.class);
- verify(sqsClient).deleteMessageBatch(captor.capture());
- verify(sqsClient, never()).sendMessageBatch(any(SendMessageBatchRequest.class));
- verify(sqsClient, never()).getQueueAttributes(any(GetQueueAttributesRequest.class));
-
- assertThat(captor.getValue())
- .satisfies(deleteMessageBatchRequest -> assertThat(deleteMessageBatchRequest.entries())
- .hasSize(2)
- .extracting("id")
- .contains("", "2e1424d4-f796-459a-8184-9c92662be6da"));
- }
-
- @Test
- void shouldBatchProcessAndFailWithExceptionForNonRetryableExceptionAndNoDlq() {
- requestHandler = new SqsMessageHandlerWithNonRetryableHandler();
-
- event.getRecords().get(0).setMessageId("");
- event.getRecords()
- .forEach(sqsMessage -> sqsMessage.setEventSourceArn(sqsMessage.getEventSourceArn() + "-temp"));
-
- when(sqsClient.getQueueAttributes(any(GetQueueAttributesRequest.class))).thenReturn(
- GetQueueAttributesResponse.builder()
- .build());
-
- assertThatExceptionOfType(SQSBatchProcessingException.class)
- .isThrownBy(() -> requestHandler.handleRequest(event, context))
- .satisfies(e ->
- {
- assertThat(e.getExceptions())
- .hasSize(1)
- .extracting("message")
- .containsExactly("Invalid message and was moved to DLQ");
-
- assertThat(e.getFailures())
- .hasSize(1)
- .extracting("messageId")
- .containsExactly("");
-
- assertThat(e.successMessageReturnValues())
- .hasSize(1)
- .contains("Success");
- });
-
- verify(interactionClient).listQueues();
- verify(sqsClient).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- verify(sqsClient, never()).sendMessageBatch(any(SendMessageBatchRequest.class));
- }
-
- @Test
- void shouldBatchProcessAndFailWithExceptionForNonRetryableExceptionWhenFailedParsingPolicy() {
- requestHandler = new SqsMessageHandlerWithNonRetryableHandler();
- event.getRecords().get(0).setMessageId("");
- event.getRecords()
- .forEach(sqsMessage -> sqsMessage.setEventSourceArn(sqsMessage.getEventSourceArn() + "-temp-queue"));
-
- HashMap attributes = new HashMap<>();
-
- attributes.put(QueueAttributeName.REDRIVE_POLICY, "MalFormedRedrivePolicy");
-
- when(sqsClient.getQueueAttributes(any(GetQueueAttributesRequest.class))).thenReturn(
- GetQueueAttributesResponse.builder()
- .attributes(attributes)
- .build());
-
- assertThatExceptionOfType(SQSBatchProcessingException.class)
- .isThrownBy(() -> requestHandler.handleRequest(event, context))
- .satisfies(e ->
- {
- assertThat(e.getExceptions())
- .hasSize(1)
- .extracting("message")
- .containsExactly("Invalid message and was moved to DLQ");
-
- assertThat(e.getFailures())
- .hasSize(1)
- .extracting("messageId")
- .containsExactly("");
-
- assertThat(e.successMessageReturnValues())
- .hasSize(1)
- .contains("Success");
- });
-
- verify(interactionClient).listQueues();
- verify(sqsClient).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- verify(sqsClient, never()).sendMessageBatch(any(SendMessageBatchRequest.class));
- }
-
- @Test
- void shouldBatchProcessAndMoveNonRetryableExceptionToDlqAndThrowException() throws IOException {
- requestHandler = new SqsMessageHandlerWithNonRetryableHandler();
- event = MAPPER.readValue(this.getClass().getResource("/threeMessageSqsBatchEvent.json"), SQSEvent.class);
-
- event.getRecords().get(1).setMessageId("");
-
- HashMap attributes = new HashMap<>();
-
- attributes.put(QueueAttributeName.REDRIVE_POLICY, "{\n" +
- " \"deadLetterTargetArn\": \"arn:aws:sqs:us-east-2:123456789012:retry-queue\",\n" +
- " \"maxReceiveCount\": 2\n" +
- "}");
-
- when(sqsClient.getQueueAttributes(any(GetQueueAttributesRequest.class))).thenReturn(
- GetQueueAttributesResponse.builder()
- .attributes(attributes)
- .build());
-
- assertThatExceptionOfType(SQSBatchProcessingException.class)
- .isThrownBy(() -> requestHandler.handleRequest(event, context))
- .satisfies(e ->
- {
- assertThat(e.getExceptions())
- .hasSize(1)
- .extracting("message")
- .containsExactly("Invalid message and should be reprocessed");
-
- assertThat(e.getFailures())
- .hasSize(1)
- .extracting("messageId")
- .containsExactly("2e1424d4-f796-459a-9696-9c92662ba5da");
-
- assertThat(e.successMessageReturnValues())
- .hasSize(1)
- .contains("Success");
- });
-
- verify(interactionClient).listQueues();
- verify(sqsClient).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- verify(sqsClient).sendMessageBatch(any(SendMessageBatchRequest.class));
- }
-
- private void setupContext() {
- when(context.getFunctionName()).thenReturn("testFunction");
- when(context.getInvokedFunctionArn()).thenReturn("testArn");
- when(context.getFunctionVersion()).thenReturn("1");
- when(context.getMemoryLimitInMB()).thenReturn(10);
- }
-}
\ No newline at end of file
diff --git a/powertools-sqs/src/test/resources/SqsFifoBatchEvent.json b/powertools-sqs/src/test/resources/SqsFifoBatchEvent.json
deleted file mode 100644
index 726e45ea1..000000000
--- a/powertools-sqs/src/test/resources/SqsFifoBatchEvent.json
+++ /dev/null
@@ -1,73 +0,0 @@
-{
- "Records": [
- {
- "messageId": "059f36b4-87a3-44ab-83d2-661975830a7d",
- "receiptHandle": "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082649183",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082649185",
- "MessageGroupId": "Group1"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceARN": "arn:aws:sqs:us-east-1:906126917321:sqs-lambda-MySqsQueue-4DYWWJIE97N5",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6da",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649",
- "MessageGroupId": "Group2"
- },
- "messageAttributes": {
- "Attribute3" : {
- "binaryValue" : "MTEwMA==",
- "dataType" : "Binary"
- },
- "Attribute2" : {
- "stringValue" : "123",
- "dataType" : "Number"
- },
- "Attribute1" : {
- "stringValue" : "AttributeValue1",
- "dataType" : "String"
- }
- },
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceARN": "arn:aws:sqs:us-east-1:906126917321:sqs-lambda-MySqsQueue-4DYWWJIE97N5",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-9696-9c92662ba5da",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649",
- "MessageGroupId": "Group1"
- },
- "messageAttributes": {
- "Attribute2" : {
- "stringValue" : "123",
- "dataType" : "Number"
- }
- },
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceARN": "arn:aws:sqs:us-east-1:906126917321:sqs-lambda-MySqsQueue-4DYWWJIE97N5",
- "awsRegion": "us-east-2"
- }
- ]
-}
\ No newline at end of file
diff --git a/powertools-sqs/src/test/resources/sampleSqsBatchEvent.json b/powertools-sqs/src/test/resources/sampleSqsBatchEvent.json
deleted file mode 100644
index 8a5fbf309..000000000
--- a/powertools-sqs/src/test/resources/sampleSqsBatchEvent.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "records": [
- {
- "messageId": "059f36b4-87a3-44ab-83d2-661975830a7d",
- "receiptHandle": "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082649183",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082649185"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6da",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- }
- ]
-}
\ No newline at end of file
diff --git a/powertools-sqs/src/test/resources/sampleSqsBatchEventBatchSize25.json b/powertools-sqs/src/test/resources/sampleSqsBatchEventBatchSize25.json
deleted file mode 100644
index 31b8862ad..000000000
--- a/powertools-sqs/src/test/resources/sampleSqsBatchEventBatchSize25.json
+++ /dev/null
@@ -1,404 +0,0 @@
-{
- "records": [
- {
- "messageId": "059f36b4-87a3-44ab-83d2-661975830a7d",
- "receiptHandle": "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082649183",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082649185"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6da",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d3",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d4",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b5",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d6",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b7",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d8",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d9",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d10",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d11",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d12",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d13",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d14",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d15",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d16",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d17",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d18",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d19",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d20",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d21",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d22",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d23",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d24",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d25",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d26",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6d27",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-2:123456789012:my-queue",
- "awsRegion": "us-east-2"
- }
- ]
-}
\ No newline at end of file
diff --git a/powertools-sqs/src/test/resources/threeMessageSqsBatchEvent.json b/powertools-sqs/src/test/resources/threeMessageSqsBatchEvent.json
deleted file mode 100644
index b3b61da3b..000000000
--- a/powertools-sqs/src/test/resources/threeMessageSqsBatchEvent.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
- "records": [
- {
- "messageId": "059f36b4-87a3-44ab-83d2-661975830a7d",
- "receiptHandle": "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082649183",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082649185"
- },
- "messageAttributes": {},
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-1:906126917321:sqs-lambda-MySqsQueue-4DYWWJIE97N5",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-8184-9c92662be6da",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {
- "Attribute3" : {
- "binaryValue" : "MTEwMA==",
- "dataType" : "Binary"
- },
- "Attribute2" : {
- "stringValue" : "123",
- "dataType" : "Number"
- },
- "Attribute1" : {
- "stringValue" : "AttributeValue1",
- "dataType" : "String"
- }
- },
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-1:906126917321:sqs-lambda-MySqsQueue-4DYWWJIE97N5",
- "awsRegion": "us-east-2"
- },
- {
- "messageId": "2e1424d4-f796-459a-9696-9c92662ba5da",
- "receiptHandle": "AQEBzWwaftRI0KuVm4tP+/7q1rGgNqicHq...",
- "body": "Test message.",
- "attributes": {
- "ApproximateReceiveCount": "1",
- "SentTimestamp": "1545082650636",
- "SenderId": "AIDAIENQZJOLO23YVJ4VO",
- "ApproximateFirstReceiveTimestamp": "1545082650649"
- },
- "messageAttributes": {
- "Attribute2" : {
- "stringValue" : "123",
- "dataType" : "Number"
- }
- },
- "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
- "eventSource": "aws:sqs",
- "eventSourceArn": "arn:aws:sqs:us-east-1:906126917321:sqs-lambda-MySqsQueue-4DYWWJIE97N5",
- "awsRegion": "us-east-2"
- }
- ]
-}
\ No newline at end of file
diff --git a/powertools-test-suite/pom.xml b/powertools-test-suite/pom.xml
deleted file mode 100644
index 4a79d2987..000000000
--- a/powertools-test-suite/pom.xml
+++ /dev/null
@@ -1,164 +0,0 @@
-
-
-
-
- 4.0.0
-
- powertools-test-suite
- jar
-
-
- powertools-parent
- software.amazon.lambda
- 1.17.0-SNAPSHOT
-
-
- Powertools for AWS Lambda (Java) library Test Suite
-
- A suite of tests for interactions between the various Powertools for AWS Lambda (Java) modules.
-
- https://aws.amazon.com/lambda/
-
- GitHub Issues
- https://github.com/aws-powertools/powertools-lambda-java/issues
-
-
- https://github.com/aws-powertools/powertools-lambda-java.git
-
-
-
- Powertools for AWS Lambda team
- Amazon Web Services
- https://aws.amazon.com/
-
-
-
-
- true
-
-
-
-
- ossrh
- https://aws.oss.sonatype.org/content/repositories/snapshots
-
-
-
-
-
- software.amazon.lambda
- powertools-core
-
-
- org.apache.logging.log4j
- log4j-jcl
-
-
- com.amazonaws
- aws-lambda-java-core
-
-
- com.amazonaws
- aws-lambda-java-events
-
-
- software.amazon.lambda
- powertools-logging
-
-
- software.amazon.lambda
- powertools-tracing
-
-
- software.amazon.lambda
- powertools-sqs
-
-
-
-
- org.junit.jupiter
- junit-jupiter-api
- test
-
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
-
- org.apache.commons
- commons-lang3
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.aspectj
- aspectjweaver
- test
-
-
- org.assertj
- assertj-core
- test
-
-
- org.skyscreamer
- jsonassert
- test
-
-
-
-
-
-
- dev.aspectj
- aspectj-maven-plugin
- 1.13.1
-
- ${maven.compiler.source}
- ${maven.compiler.target}
- ${maven.compiler.target}
-
-
- software.amazon.lambda
- powertools-logging
-
-
- software.amazon.lambda
- powertools-tracing
-
-
- software.amazon.lambda
- powertools-sqs
-
-
-
-
-
-
- compile
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/LoggingOrderTest.java b/powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/LoggingOrderTest.java
deleted file mode 100644
index 9e9c464a6..000000000
--- a/powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/LoggingOrderTest.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.testsuite;
-
-
-import static java.util.Collections.emptyMap;
-import static java.util.Collections.singletonList;
-import static org.apache.commons.lang3.reflect.FieldUtils.writeStaticField;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.openMocks;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification;
-import com.amazonaws.xray.AWSXRay;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.channels.FileChannel;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
-import java.util.Map;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.ThreadContext;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
-import software.amazon.awssdk.core.ResponseInputStream;
-import software.amazon.awssdk.http.AbortableInputStream;
-import software.amazon.awssdk.services.s3.S3Client;
-import software.amazon.awssdk.services.s3.model.GetObjectRequest;
-import software.amazon.awssdk.services.s3.model.GetObjectResponse;
-import software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor;
-import software.amazon.lambda.powertools.logging.internal.LambdaLoggingAspect;
-import software.amazon.lambda.powertools.sqs.SqsUtils;
-import software.amazon.lambda.powertools.testsuite.handler.LoggingOrderMessageHandler;
-import software.amazon.lambda.powertools.testsuite.handler.TracingLoggingStreamMessageHandler;
-
-public class LoggingOrderTest {
-
- private static final String BUCKET_NAME = "ms-extended-sqs-client";
- private static final String BUCKET_KEY = "c71eb2ae-37e0-4265-8909-32f4153faddf";
-
- @Mock
- private Context context;
-
- @Mock
- private S3Client s3Client;
-
- @BeforeEach
- void setUp() throws IllegalAccessException, IOException, NoSuchMethodException, InvocationTargetException {
- openMocks(this);
- SqsUtils.overrideS3Client(s3Client);
- ThreadContext.clearAll();
- writeStaticField(LambdaHandlerProcessor.class, "IS_COLD_START", null, true);
- setupContext();
- //Make sure file is cleaned up before running full stack logging regression
- FileChannel.open(Paths.get("target/logfile.json"), StandardOpenOption.WRITE).truncate(0).close();
- resetLogLevel(Level.INFO);
- AWSXRay.beginSegment(LoggingOrderTest.class.getName());
- }
-
- @AfterEach
- void tearDown() {
- AWSXRay.endSegment();
- }
-
- /**
- * The SQSEvent payload will be altered by the @SqsLargeMessage annotation. Logging of the event should happen
- * after the event has been altered
- */
- @Test
- public void testThatLoggingAnnotationActsLast() throws IOException {
- ResponseInputStream s3Response =
- new ResponseInputStream<>(GetObjectResponse.builder().build(),
- AbortableInputStream.create(new ByteArrayInputStream("A big message".getBytes())));
-
- when(s3Client.getObject(any(GetObjectRequest.class))).thenReturn(s3Response);
- SQSEvent sqsEvent = messageWithBody(
- "[\"software.amazon.payloadoffloading.PayloadS3Pointer\",{\"s3BucketName\":\"" + BUCKET_NAME +
- "\",\"s3Key\":\"" + BUCKET_KEY + "\"}]");
-
- LoggingOrderMessageHandler requestHandler = new LoggingOrderMessageHandler();
- requestHandler.handleRequest(sqsEvent, context);
-
- assertThat(Files.lines(Paths.get("target/logfile.json")))
- .hasSize(2)
- .satisfies(line ->
- {
- Map actual = parseToMap(line.get(0));
-
- String message = actual.get("message").toString();
-
- assertThat(message)
- .contains("A big message");
- });
- }
-
- @Test
- public void testLoggingAnnotationActsAfterTracingForStreamingHandler() throws IOException {
-
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- S3EventNotification s3EventNotification = s3EventNotification();
-
- TracingLoggingStreamMessageHandler handler = new TracingLoggingStreamMessageHandler();
- handler.handleRequest(new ByteArrayInputStream(new ObjectMapper().writeValueAsBytes(s3EventNotification)),
- output, context);
-
- assertThat(new String(output.toByteArray(), StandardCharsets.UTF_8))
- .isNotEmpty();
- }
-
- private void setupContext() {
- when(context.getFunctionName()).thenReturn("testFunction");
- when(context.getInvokedFunctionArn()).thenReturn("testArn");
- when(context.getFunctionVersion()).thenReturn("1");
- when(context.getMemoryLimitInMB()).thenReturn(10);
- when(context.getAwsRequestId()).thenReturn("RequestId");
- }
-
- private void resetLogLevel(Level level)
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
- Method resetLogLevels = LambdaLoggingAspect.class.getDeclaredMethod("resetLogLevels", Level.class);
- resetLogLevels.setAccessible(true);
- resetLogLevels.invoke(null, level);
- writeStaticField(LambdaLoggingAspect.class, "LEVEL_AT_INITIALISATION", level, true);
- }
-
- private Map parseToMap(String stringAsJson) {
- try {
- return new ObjectMapper().readValue(stringAsJson, Map.class);
- } catch (JsonProcessingException e) {
- fail("Failed parsing logger line " + stringAsJson);
- return emptyMap();
- }
- }
-
- private S3EventNotification s3EventNotification() {
- S3EventNotification.S3EventNotificationRecord record =
- new S3EventNotification.S3EventNotificationRecord("us-west-2",
- "ObjectCreated:Put",
- "aws:s3",
- null,
- "2.1",
- new S3EventNotification.RequestParametersEntity("127.0.0.1"),
- new S3EventNotification.ResponseElementsEntity("C3D13FE58DE4C810",
- "FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD"),
- new S3EventNotification.S3Entity("testConfigRule",
- new S3EventNotification.S3BucketEntity("mybucket",
- new S3EventNotification.UserIdentityEntity("A3NL1KOZZKExample"),
- "arn:aws:s3:::mybucket"),
- new S3EventNotification.S3ObjectEntity("HappyFace.jpg",
- 1024L,
- "d41d8cd98f00b204e9800998ecf8427e",
- "096fKKXTRTtl3on89fVO.nfljtsv6qko",
- "0055AED6DCD90281E5"),
- "1.0"),
- new S3EventNotification.UserIdentityEntity("AIDAJDPLRKLG7UEXAMPLE")
- );
-
- return new S3EventNotification(singletonList(record));
- }
-
- private SQSEvent messageWithBody(String messageBody) {
- SQSEvent.SQSMessage sqsMessage = new SQSEvent.SQSMessage();
- sqsMessage.setBody(messageBody);
- SQSEvent sqsEvent = new SQSEvent();
- sqsEvent.setRecords(singletonList(sqsMessage));
- return sqsEvent;
- }
-}
\ No newline at end of file
diff --git a/powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/handler/LoggingOrderMessageHandler.java b/powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/handler/LoggingOrderMessageHandler.java
deleted file mode 100644
index 5592b1fd3..000000000
--- a/powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/handler/LoggingOrderMessageHandler.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.testsuite.handler;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
-import software.amazon.lambda.powertools.logging.Logging;
-import software.amazon.lambda.powertools.sqs.SqsLargeMessage;
-
-public class LoggingOrderMessageHandler implements RequestHandler {
-
- @Override
- @SqsLargeMessage
- @Logging(logEvent = true)
- public String handleRequest(SQSEvent sqsEvent, Context context) {
- return sqsEvent.getRecords().get(0).getBody();
- }
-}
diff --git a/powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/handler/TracingLoggingStreamMessageHandler.java b/powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/handler/TracingLoggingStreamMessageHandler.java
deleted file mode 100644
index 4a60d0949..000000000
--- a/powertools-test-suite/src/test/java/software/amazon/lambda/powertools/testsuite/handler/TracingLoggingStreamMessageHandler.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2023 Amazon.com, Inc. or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package software.amazon.lambda.powertools.testsuite.handler;
-
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Map;
-import software.amazon.lambda.powertools.logging.Logging;
-import software.amazon.lambda.powertools.tracing.Tracing;
-
-public class TracingLoggingStreamMessageHandler implements RequestStreamHandler {
-
- @Logging(logEvent = true)
- @Tracing
- @Override
- public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException {
- ObjectMapper mapper = new ObjectMapper();
- mapper.writeValue(output, mapper.readValue(input, Map.class));
- }
-}
diff --git a/powertools-test-suite/src/test/resources/log4j2.xml b/powertools-test-suite/src/test/resources/log4j2.xml
deleted file mode 100644
index 8ac9b34ce..000000000
--- a/powertools-test-suite/src/test/resources/log4j2.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
From 23261c7cf82c57778317b57142e89ef4cb08c737 Mon Sep 17 00:00:00 2001
From: Scott Gerring
Date: Mon, 7 Aug 2023 18:39:26 +0100
Subject: [PATCH 02/16] v2: fix version (#1348)
---
examples/pom.xml | 2 +-
examples/powertools-examples-batch/pom.xml | 2 +-
examples/powertools-examples-cloudformation/pom.xml | 2 +-
examples/powertools-examples-core/pom.xml | 2 +-
examples/powertools-examples-idempotency/pom.xml | 2 +-
examples/powertools-examples-parameters/pom.xml | 2 +-
examples/powertools-examples-serialization/pom.xml | 2 +-
examples/powertools-examples-validation/pom.xml | 2 +-
pom.xml | 2 +-
powertools-batch/pom.xml | 2 +-
powertools-cloudformation/pom.xml | 2 +-
powertools-core/pom.xml | 2 +-
powertools-e2e-tests/handlers/pom.xml | 2 +-
powertools-e2e-tests/pom.xml | 2 +-
powertools-idempotency/pom.xml | 2 +-
powertools-large-messages/pom.xml | 2 +-
powertools-logging/pom.xml | 2 +-
powertools-metrics/pom.xml | 2 +-
powertools-parameters/pom.xml | 2 +-
powertools-serialization/pom.xml | 2 +-
powertools-tracing/pom.xml | 2 +-
powertools-validation/pom.xml | 2 +-
22 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/examples/pom.xml b/examples/pom.xml
index 0cd62e326..aca250dae 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -20,7 +20,7 @@
software.amazon.lambda
powertools-examples
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
pom
Powertools for AWS Lambda (Java) library Examples
diff --git a/examples/powertools-examples-batch/pom.xml b/examples/powertools-examples-batch/pom.xml
index d3c4bc49b..10e15d532 100644
--- a/examples/powertools-examples-batch/pom.xml
+++ b/examples/powertools-examples-batch/pom.xml
@@ -5,7 +5,7 @@
4.0.0
software.amazon.lambda.examples
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-examples-batch
jar
Powertools for AWS Lambda (Java) library Examples - Batch
diff --git a/examples/powertools-examples-cloudformation/pom.xml b/examples/powertools-examples-cloudformation/pom.xml
index 35d5e340c..c9fe249b3 100644
--- a/examples/powertools-examples-cloudformation/pom.xml
+++ b/examples/powertools-examples-cloudformation/pom.xml
@@ -3,7 +3,7 @@
4.0.0
software.amazon.lambda.examples
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-examples-cloudformation
jar
diff --git a/examples/powertools-examples-core/pom.xml b/examples/powertools-examples-core/pom.xml
index a5d854d6b..d402ce09c 100644
--- a/examples/powertools-examples-core/pom.xml
+++ b/examples/powertools-examples-core/pom.xml
@@ -3,7 +3,7 @@
4.0.0
software.amazon.lambda.examples
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-examples-core
jar
diff --git a/examples/powertools-examples-idempotency/pom.xml b/examples/powertools-examples-idempotency/pom.xml
index f24b2ffc4..38682e164 100644
--- a/examples/powertools-examples-idempotency/pom.xml
+++ b/examples/powertools-examples-idempotency/pom.xml
@@ -17,7 +17,7 @@
4.0.0
software.amazon.lambda.examples
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-examples-idempotency
jar
Powertools for AWS Lambda (Java) library Examples - Idempotency
diff --git a/examples/powertools-examples-parameters/pom.xml b/examples/powertools-examples-parameters/pom.xml
index c4631fd05..1c7d177f4 100644
--- a/examples/powertools-examples-parameters/pom.xml
+++ b/examples/powertools-examples-parameters/pom.xml
@@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
software.amazon.lambda.examples
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-examples-parameters
jar
Powertools for AWS Lambda (Java) library Examples - Parameters
diff --git a/examples/powertools-examples-serialization/pom.xml b/examples/powertools-examples-serialization/pom.xml
index 4974842dd..0ec05cd82 100644
--- a/examples/powertools-examples-serialization/pom.xml
+++ b/examples/powertools-examples-serialization/pom.xml
@@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
software.amazon.lambda.examples
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-examples-serialization
jar
Powertools for AWS Lambda (Java) library Examples - Serialization
diff --git a/examples/powertools-examples-validation/pom.xml b/examples/powertools-examples-validation/pom.xml
index 1c7e33de0..b3947513f 100644
--- a/examples/powertools-examples-validation/pom.xml
+++ b/examples/powertools-examples-validation/pom.xml
@@ -16,7 +16,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
software.amazon.lambda.examples
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-examples-validation
jar
Powertools for AWS Lambda (Java) library Examples - Validation
diff --git a/pom.xml b/pom.xml
index bebb2493f..7cdf8a71f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,7 @@
software.amazon.lambda
powertools-parent
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
pom
Powertools for AWS Lambda (Java) library Parent
diff --git a/powertools-batch/pom.xml b/powertools-batch/pom.xml
index 9e25dabd8..593b22444 100644
--- a/powertools-batch/pom.xml
+++ b/powertools-batch/pom.xml
@@ -6,7 +6,7 @@
software.amazon.lambda
powertools-parent
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
diff --git a/powertools-cloudformation/pom.xml b/powertools-cloudformation/pom.xml
index a122e7ac8..336a3f94c 100644
--- a/powertools-cloudformation/pom.xml
+++ b/powertools-cloudformation/pom.xml
@@ -24,7 +24,7 @@
powertools-parent
software.amazon.lambda
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Powertools for AWS Lambda (Java)library Cloudformation
diff --git a/powertools-core/pom.xml b/powertools-core/pom.xml
index 78cd735b9..c244f70fc 100644
--- a/powertools-core/pom.xml
+++ b/powertools-core/pom.xml
@@ -24,7 +24,7 @@
powertools-parent
software.amazon.lambda
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Powertools for AWS Lambda (Java) library Core
diff --git a/powertools-e2e-tests/handlers/pom.xml b/powertools-e2e-tests/handlers/pom.xml
index 6e82c7aec..49b4b5a20 100644
--- a/powertools-e2e-tests/handlers/pom.xml
+++ b/powertools-e2e-tests/handlers/pom.xml
@@ -10,7 +10,7 @@
Fake handlers that use Powertools for AWS Lambda (Java).
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
UTF-8
1.8
1.8
diff --git a/powertools-e2e-tests/pom.xml b/powertools-e2e-tests/pom.xml
index f3194c163..e8a3273b1 100644
--- a/powertools-e2e-tests/pom.xml
+++ b/powertools-e2e-tests/pom.xml
@@ -20,7 +20,7 @@
powertools-parent
software.amazon.lambda
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-e2e-tests
diff --git a/powertools-idempotency/pom.xml b/powertools-idempotency/pom.xml
index 2e68ea563..6b9e46a4a 100644
--- a/powertools-idempotency/pom.xml
+++ b/powertools-idempotency/pom.xml
@@ -21,7 +21,7 @@
software.amazon.lambda
powertools-parent
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-idempotency
diff --git a/powertools-large-messages/pom.xml b/powertools-large-messages/pom.xml
index a9ded60c5..19793d616 100644
--- a/powertools-large-messages/pom.xml
+++ b/powertools-large-messages/pom.xml
@@ -23,7 +23,7 @@
software.amazon.lambda
powertools-parent
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-large-messages
diff --git a/powertools-logging/pom.xml b/powertools-logging/pom.xml
index 83650fcde..e13a88e57 100644
--- a/powertools-logging/pom.xml
+++ b/powertools-logging/pom.xml
@@ -24,7 +24,7 @@
powertools-parent
software.amazon.lambda
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Powertools for AWS Lambda (Java) library Logging
diff --git a/powertools-metrics/pom.xml b/powertools-metrics/pom.xml
index 7b2e99045..0681ed000 100644
--- a/powertools-metrics/pom.xml
+++ b/powertools-metrics/pom.xml
@@ -24,7 +24,7 @@
powertools-parent
software.amazon.lambda
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Powertools for AWS Lambda (Java) library Metrics
diff --git a/powertools-parameters/pom.xml b/powertools-parameters/pom.xml
index fab72a9b7..367996e9c 100644
--- a/powertools-parameters/pom.xml
+++ b/powertools-parameters/pom.xml
@@ -21,7 +21,7 @@
powertools-parent
software.amazon.lambda
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-parameters
diff --git a/powertools-serialization/pom.xml b/powertools-serialization/pom.xml
index 2a57f21e3..c34cddef1 100644
--- a/powertools-serialization/pom.xml
+++ b/powertools-serialization/pom.xml
@@ -21,7 +21,7 @@
powertools-parent
software.amazon.lambda
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
powertools-serialization
diff --git a/powertools-tracing/pom.xml b/powertools-tracing/pom.xml
index b5de90f7b..5f397aa9f 100644
--- a/powertools-tracing/pom.xml
+++ b/powertools-tracing/pom.xml
@@ -24,7 +24,7 @@
powertools-parent
software.amazon.lambda
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Powertools for AWS Lambda (Java) library Tracing
diff --git a/powertools-validation/pom.xml b/powertools-validation/pom.xml
index daec3aa99..1b939f46f 100644
--- a/powertools-validation/pom.xml
+++ b/powertools-validation/pom.xml
@@ -24,7 +24,7 @@
powertools-parent
software.amazon.lambda
- 1.17.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Powertools for AWS Lambda (Java) validation library
From 69eafe6279135d96091281eea6a605246b151037 Mon Sep 17 00:00:00 2001
From: Scott Gerring
Date: Tue, 22 Aug 2023 13:19:22 +0100
Subject: [PATCH 03/16] chore: V2 update from main (#1365)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* build(deps): bump aws.sdk.version from 2.20.119 to 2.20.120 (#1349)
Bumps `aws.sdk.version` from 2.20.119 to 2.20.120.
Updates `software.amazon.awssdk:bom` from 2.20.119 to 2.20.120
Updates `software.amazon.awssdk:http-client-spi` from 2.20.119 to 2.20.120
Updates `software.amazon.awssdk:url-connection-client` from 2.20.109 to 2.20.120
Updates `software.amazon.awssdk:sqs` from 2.20.109 to 2.20.120
Updates `software.amazon.awssdk:s3` from 2.20.119 to 2.20.120
Updates `software.amazon.awssdk:dynamodb` from 2.20.119 to 2.20.120
Updates `software.amazon.awssdk:lambda` from 2.20.119 to 2.20.120
Updates `software.amazon.awssdk:kinesis` from 2.20.109 to 2.20.120
Updates `software.amazon.awssdk:cloudwatch` from 2.20.119 to 2.20.120
Updates `software.amazon.awssdk:xray` from 2.20.119 to 2.20.120
Updates `software.amazon.awssdk:cloudformation` from 2.20.119 to 2.20.120
Updates `software.amazon.awssdk:sts` from 2.20.119 to 2.20.120
---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:url-connection-client
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sqs
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:s3
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:dynamodb
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:lambda
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:kinesis
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudwatch
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:xray
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudformation
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sts
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps-dev): bump software.amazon.awscdk:aws-cdk-lib (#1350)
Bumps [software.amazon.awscdk:aws-cdk-lib](https://github.com/aws/aws-cdk) from 2.89.0 to 2.90.0.
- [Release notes](https://github.com/aws/aws-cdk/releases)
- [Changelog](https://github.com/aws/aws-cdk/blob/main/CHANGELOG.v2.md)
- [Commits](https://github.com/aws/aws-cdk/compare/v2.89.0...v2.90.0)
---
updated-dependencies:
- dependency-name: software.amazon.awscdk:aws-cdk-lib
dependency-type: direct:development
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump aws.sdk.version from 2.20.120 to 2.20.121 (#1351)
Bumps `aws.sdk.version` from 2.20.120 to 2.20.121.
Updates `software.amazon.awssdk:bom` from 2.20.120 to 2.20.121
Updates `software.amazon.awssdk:http-client-spi` from 2.20.120 to 2.20.121
Updates `software.amazon.awssdk:url-connection-client` from 2.20.109 to 2.20.121
Updates `software.amazon.awssdk:sqs` from 2.20.109 to 2.20.121
Updates `software.amazon.awssdk:s3` from 2.20.120 to 2.20.121
Updates `software.amazon.awssdk:dynamodb` from 2.20.120 to 2.20.121
Updates `software.amazon.awssdk:lambda` from 2.20.120 to 2.20.121
Updates `software.amazon.awssdk:kinesis` from 2.20.109 to 2.20.121
Updates `software.amazon.awssdk:cloudwatch` from 2.20.120 to 2.20.121
Updates `software.amazon.awssdk:xray` from 2.20.120 to 2.20.121
Updates `software.amazon.awssdk:cloudformation` from 2.20.120 to 2.20.121
Updates `software.amazon.awssdk:sts` from 2.20.120 to 2.20.121
---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:url-connection-client
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sqs
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:s3
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:dynamodb
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:lambda
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:kinesis
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudwatch
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:xray
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudformation
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sts
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump aws.sdk.version from 2.20.121 to 2.20.122 (#1354)
Bumps `aws.sdk.version` from 2.20.121 to 2.20.122.
Updates `software.amazon.awssdk:bom` from 2.20.121 to 2.20.122
Updates `software.amazon.awssdk:http-client-spi` from 2.20.121 to 2.20.122
Updates `software.amazon.awssdk:url-connection-client` from 2.20.109 to 2.20.122
Updates `software.amazon.awssdk:sqs` from 2.20.109 to 2.20.122
Updates `software.amazon.awssdk:s3` from 2.20.121 to 2.20.122
Updates `software.amazon.awssdk:dynamodb` from 2.20.121 to 2.20.122
Updates `software.amazon.awssdk:lambda` from 2.20.121 to 2.20.122
Updates `software.amazon.awssdk:kinesis` from 2.20.109 to 2.20.122
Updates `software.amazon.awssdk:cloudwatch` from 2.20.121 to 2.20.122
Updates `software.amazon.awssdk:xray` from 2.20.121 to 2.20.122
Updates `software.amazon.awssdk:cloudformation` from 2.20.121 to 2.20.122
Updates `software.amazon.awssdk:sts` from 2.20.121 to 2.20.122
---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:url-connection-client
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sqs
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:s3
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:dynamodb
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:lambda
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:kinesis
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudwatch
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:xray
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudformation
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sts
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump aws.sdk.version from 2.20.122 to 2.20.123 (#1355)
Bumps `aws.sdk.version` from 2.20.122 to 2.20.123.
Updates `software.amazon.awssdk:bom` from 2.20.122 to 2.20.123
Updates `software.amazon.awssdk:http-client-spi` from 2.20.122 to 2.20.123
Updates `software.amazon.awssdk:url-connection-client` from 2.20.109 to 2.20.123
Updates `software.amazon.awssdk:sqs` from 2.20.109 to 2.20.123
Updates `software.amazon.awssdk:s3` from 2.20.122 to 2.20.123
Updates `software.amazon.awssdk:dynamodb` from 2.20.122 to 2.20.123
Updates `software.amazon.awssdk:lambda` from 2.20.122 to 2.20.123
Updates `software.amazon.awssdk:kinesis` from 2.20.109 to 2.20.123
Updates `software.amazon.awssdk:cloudwatch` from 2.20.122 to 2.20.123
Updates `software.amazon.awssdk:xray` from 2.20.122 to 2.20.123
Updates `software.amazon.awssdk:cloudformation` from 2.20.122 to 2.20.123
Updates `software.amazon.awssdk:sts` from 2.20.122 to 2.20.123
---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:url-connection-client
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sqs
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:s3
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:dynamodb
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:lambda
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:kinesis
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudwatch
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:xray
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudformation
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sts
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump aws.sdk.version from 2.20.123 to 2.20.124 (#1356)
Bumps `aws.sdk.version` from 2.20.123 to 2.20.124.
Updates `software.amazon.awssdk:bom` from 2.20.123 to 2.20.124
Updates `software.amazon.awssdk:http-client-spi` from 2.20.123 to 2.20.124
Updates `software.amazon.awssdk:url-connection-client` from 2.20.109 to 2.20.124
Updates `software.amazon.awssdk:sqs` from 2.20.109 to 2.20.124
Updates `software.amazon.awssdk:s3` from 2.20.123 to 2.20.124
Updates `software.amazon.awssdk:dynamodb` from 2.20.123 to 2.20.124
Updates `software.amazon.awssdk:lambda` from 2.20.123 to 2.20.124
Updates `software.amazon.awssdk:kinesis` from 2.20.109 to 2.20.124
Updates `software.amazon.awssdk:cloudwatch` from 2.20.123 to 2.20.124
Updates `software.amazon.awssdk:xray` from 2.20.123 to 2.20.124
Updates `software.amazon.awssdk:cloudformation` from 2.20.123 to 2.20.124
Updates `software.amazon.awssdk:sts` from 2.20.123 to 2.20.124
---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:url-connection-client
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sqs
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:s3
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:dynamodb
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:lambda
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:kinesis
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudwatch
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:xray
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudformation
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sts
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps-dev): bump software.amazon.awscdk:aws-cdk-lib (#1357)
Bumps [software.amazon.awscdk:aws-cdk-lib](https://github.com/aws/aws-cdk) from 2.90.0 to 2.91.0.
- [Release notes](https://github.com/aws/aws-cdk/releases)
- [Changelog](https://github.com/aws/aws-cdk/blob/main/CHANGELOG.v2.md)
- [Commits](https://github.com/aws/aws-cdk/compare/v2.90.0...v2.91.0)
---
updated-dependencies:
- dependency-name: software.amazon.awscdk:aws-cdk-lib
dependency-type: direct:development
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Scott Gerring
* docs: Adding CDK example (#1321)
* Move the current example, which is for SAM, under /sam directory
* Create a new directory for CDK
* Add CDK Example as a Maven module
* CDK Stack stub
* Restructure CDK application info Infra and App projects
* Define the build of the project inside the CDK stack
* Use default account and region
* Add example of setting environment variables in CDK
* Remove threads from the examples, as this should be covered by documentation
* Add general README for the project
* Add specific README for SAM
* Add specific README for CDK
* Use Java11 syntax for CDK
* Refactor the code for clarity
* Fix imports
* Add outputs example
* Add test for the stack
* Update examples/powertools-examples-core/README.md
Co-authored-by: Jérôme Van Der Linden <117538+jeromevdl@users.noreply.github.com>
* Update examples/powertools-examples-core/cdk/README.md
Co-authored-by: Jérôme Van Der Linden <117538+jeromevdl@users.noreply.github.com>
* Remove unnecessary .gitignore
* Mixed log level and sample rate
* Combine .gitignore files
* Remove `cdk ls`, since there's just a single stack
* Remove SAM mentions from the CDK readme
* Replace "architecture" with "tool" while talking about SAM/CDK
* Update examples/powertools-examples-core/README.md
Co-authored-by: Jérôme Van Der Linden <117538+jeromevdl@users.noreply.github.com>
* Update examples/powertools-examples-core/README.md
Co-authored-by: Jérôme Van Der Linden <117538+jeromevdl@users.noreply.github.com>
* Reformat imports
* Don't include version number in the HelloWorld jar
* Update examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkStack.java
Co-authored-by: Jérôme Van Der Linden <117538+jeromevdl@users.noreply.github.com>
* Add Streaming example as well
* Update examples/powertools-examples-core/README.md
Co-authored-by: Scott Gerring
* Update examples/.gitignore
Co-authored-by: Scott Gerring
* Update examples/.gitignore
Co-authored-by: Scott Gerring
* Update examples/powertools-examples-core/README.md
Co-authored-by: Scott Gerring
* Update examples/powertools-examples-core/cdk/README.md
Co-authored-by: Scott Gerring
* Update examples/powertools-examples-core/sam/README.md
Co-authored-by: Scott Gerring
* Exclude examples from duplicate code scan
https://github.com/aws-powertools/powertools-lambda-java/pull/1317/files
* Fix broken link to the events file
* Trim cdk.json
* Trim cdk.json
* Downgrade code to Java 8
* Correct README to point to powertools-core-idempotency for a quick start
* Add the missing license to the new Java files
* Reformat code
---------
Co-authored-by: Scott Gerring
Co-authored-by: Jérôme Van Der Linden <117538+jeromevdl@users.noreply.github.com>
* build(deps-dev): bump org.yaml:snakeyaml from 2.0 to 2.1 (#1344)
Bumps [org.yaml:snakeyaml](https://bitbucket.org/snakeyaml/snakeyaml) from 2.0 to 2.1.
- [Commits](https://bitbucket.org/snakeyaml/snakeyaml/branches/compare/snakeyaml-2.1..snakeyaml-2.0)
---
updated-dependencies:
- dependency-name: org.yaml:snakeyaml
dependency-type: direct:development
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Scott Gerring
* build(deps): bump org.apache.maven.plugins:maven-compiler-plugin (#1360)
Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.8.1 to 3.11.0.
- [Release notes](https://github.com/apache/maven-compiler-plugin/releases)
- [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.8.1...maven-compiler-plugin-3.11.0)
---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-compiler-plugin
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps-dev): bump org.junit.jupiter:junit-jupiter (#1362)
Bumps [org.junit.jupiter:junit-jupiter](https://github.com/junit-team/junit5) from 5.7.1 to 5.10.0.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.7.1...r5.10.0)
---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter
dependency-type: direct:development
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump aws.sdk.version from 2.20.124 to 2.20.125 (#1361)
Bumps `aws.sdk.version` from 2.20.124 to 2.20.125.
Updates `software.amazon.awssdk:bom` from 2.20.124 to 2.20.125
Updates `software.amazon.awssdk:http-client-spi` from 2.20.124 to 2.20.125
Updates `software.amazon.awssdk:url-connection-client` from 2.20.109 to 2.20.125
Updates `software.amazon.awssdk:sqs` from 2.20.109 to 2.20.125
Updates `software.amazon.awssdk:s3` from 2.20.124 to 2.20.125
Updates `software.amazon.awssdk:dynamodb` from 2.20.124 to 2.20.125
Updates `software.amazon.awssdk:lambda` from 2.20.124 to 2.20.125
Updates `software.amazon.awssdk:kinesis` from 2.20.109 to 2.20.125
Updates `software.amazon.awssdk:cloudwatch` from 2.20.124 to 2.20.125
Updates `software.amazon.awssdk:xray` from 2.20.124 to 2.20.125
Updates `software.amazon.awssdk:cloudformation` from 2.20.124 to 2.20.125
Updates `software.amazon.awssdk:sts` from 2.20.124 to 2.20.125
---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:url-connection-client
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sqs
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:s3
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:dynamodb
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:lambda
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:kinesis
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudwatch
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:xray
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudformation
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sts
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump org.codehaus.mojo:exec-maven-plugin (#1366)
Bumps [org.codehaus.mojo:exec-maven-plugin](https://github.com/mojohaus/exec-maven-plugin) from 3.0.0 to 3.1.0.
- [Release notes](https://github.com/mojohaus/exec-maven-plugin/releases)
- [Commits](https://github.com/mojohaus/exec-maven-plugin/compare/exec-maven-plugin-3.0.0...exec-maven-plugin-3.1.0)
---
updated-dependencies:
- dependency-name: org.codehaus.mojo:exec-maven-plugin
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps-dev): bump software.amazon.awscdk:aws-cdk-lib (#1368)
Bumps [software.amazon.awscdk:aws-cdk-lib](https://github.com/aws/aws-cdk) from 2.88.0 to 2.91.0.
- [Release notes](https://github.com/aws/aws-cdk/releases)
- [Changelog](https://github.com/aws/aws-cdk/blob/main/CHANGELOG.v2.md)
- [Commits](https://github.com/aws/aws-cdk/compare/v2.88.0...v2.91.0)
---
updated-dependencies:
- dependency-name: software.amazon.awscdk:aws-cdk-lib
dependency-type: direct:development
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump aws.sdk.version from 2.20.125 to 2.20.126 (#1367)
Bumps `aws.sdk.version` from 2.20.125 to 2.20.126.
Updates `software.amazon.awssdk:bom` from 2.20.125 to 2.20.126
Updates `software.amazon.awssdk:http-client-spi` from 2.20.125 to 2.20.126
Updates `software.amazon.awssdk:url-connection-client` from 2.20.109 to 2.20.126
Updates `software.amazon.awssdk:sqs` from 2.20.109 to 2.20.126
Updates `software.amazon.awssdk:s3` from 2.20.125 to 2.20.126
Updates `software.amazon.awssdk:dynamodb` from 2.20.125 to 2.20.126
Updates `software.amazon.awssdk:lambda` from 2.20.125 to 2.20.126
Updates `software.amazon.awssdk:kinesis` from 2.20.109 to 2.20.126
Updates `software.amazon.awssdk:cloudwatch` from 2.20.125 to 2.20.126
Updates `software.amazon.awssdk:xray` from 2.20.125 to 2.20.126
Updates `software.amazon.awssdk:cloudformation` from 2.20.125 to 2.20.126
Updates `software.amazon.awssdk:sts` from 2.20.125 to 2.20.126
---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:url-connection-client
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sqs
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:s3
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:dynamodb
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:lambda
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:kinesis
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudwatch
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:xray
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudformation
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sts
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump aws.sdk.version from 2.20.126 to 2.20.127 (#1372)
Bumps `aws.sdk.version` from 2.20.126 to 2.20.127.
Updates `software.amazon.awssdk:bom` from 2.20.126 to 2.20.127
Updates `software.amazon.awssdk:http-client-spi` from 2.20.126 to 2.20.127
Updates `software.amazon.awssdk:url-connection-client` from 2.20.109 to 2.20.127
Updates `software.amazon.awssdk:sqs` from 2.20.109 to 2.20.127
Updates `software.amazon.awssdk:s3` from 2.20.126 to 2.20.127
Updates `software.amazon.awssdk:dynamodb` from 2.20.126 to 2.20.127
Updates `software.amazon.awssdk:lambda` from 2.20.126 to 2.20.127
Updates `software.amazon.awssdk:kinesis` from 2.20.109 to 2.20.127
Updates `software.amazon.awssdk:cloudwatch` from 2.20.126 to 2.20.127
Updates `software.amazon.awssdk:xray` from 2.20.126 to 2.20.127
Updates `software.amazon.awssdk:cloudformation` from 2.20.126 to 2.20.127
Updates `software.amazon.awssdk:sts` from 2.20.126 to 2.20.127
---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:url-connection-client
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sqs
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:s3
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:dynamodb
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:lambda
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:kinesis
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudwatch
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:xray
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudformation
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sts
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump aws.sdk.version from 2.20.109 to 2.20.128 (#1377)
Bumps `aws.sdk.version` from 2.20.109 to 2.20.128.
Updates `software.amazon.awssdk:url-connection-client` from 2.20.109 to 2.20.128
Updates `software.amazon.awssdk:sqs` from 2.20.109 to 2.20.128
Updates `software.amazon.awssdk:sdk-core` from 2.20.109 to 2.20.128
Updates `software.amazon.awssdk:kinesis` from 2.20.109 to 2.20.128
Updates `software.amazon.awssdk:dynamodb-enhanced` from 2.20.109 to 2.20.128
---
updated-dependencies:
- dependency-name: software.amazon.awssdk:url-connection-client
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sqs
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sdk-core
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:kinesis
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:dynamodb-enhanced
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* fix: Roll log4j shade transformer forwards (#1376)
* Roll log4j shade transformer forwards
* missed one
* build(deps): bump com.amazonaws:aws-lambda-java-core from 1.2.2 to 1.2.3 (#1379)
Bumps [com.amazonaws:aws-lambda-java-core](https://github.com/aws/aws-lambda-java-libs) from 1.2.2 to 1.2.3.
- [Commits](https://github.com/aws/aws-lambda-java-libs/commits)
---
updated-dependencies:
- dependency-name: com.amazonaws:aws-lambda-java-core
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump aws.sdk.version from 2.20.127 to 2.20.129 (#1380)
Bumps `aws.sdk.version` from 2.20.127 to 2.20.129.
Updates `software.amazon.awssdk:bom` from 2.20.127 to 2.20.129
Updates `software.amazon.awssdk:http-client-spi` from 2.20.127 to 2.20.129
Updates `software.amazon.awssdk:url-connection-client` from 2.20.127 to 2.20.129
Updates `software.amazon.awssdk:sqs` from 2.20.127 to 2.20.129
Updates `software.amazon.awssdk:s3` from 2.20.127 to 2.20.129
Updates `software.amazon.awssdk:dynamodb` from 2.20.127 to 2.20.129
Updates `software.amazon.awssdk:lambda` from 2.20.127 to 2.20.129
Updates `software.amazon.awssdk:kinesis` from 2.20.127 to 2.20.129
Updates `software.amazon.awssdk:cloudwatch` from 2.20.127 to 2.20.129
Updates `software.amazon.awssdk:xray` from 2.20.127 to 2.20.129
Updates `software.amazon.awssdk:cloudformation` from 2.20.127 to 2.20.129
Updates `software.amazon.awssdk:sts` from 2.20.127 to 2.20.129
---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:url-connection-client
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sqs
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:s3
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:dynamodb
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:lambda
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:kinesis
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudwatch
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:xray
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudformation
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sts
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore:Prep release 1.17.0 (#1381)
* chore:prep release 1.17.0
* Update changelog
---------
Co-authored-by: scottgerring
Co-authored-by: Scott Gerring
* chore: Fix missing version change pieces (#1382)
* Add missing bits
* And fixed the fix
* We shouldn't deploy CDK (#1383)
* build(deps): bump aws.sdk.version from 2.20.129 to 2.20.130 (#1386)
Bumps `aws.sdk.version` from 2.20.129 to 2.20.130.
Updates `software.amazon.awssdk:bom` from 2.20.129 to 2.20.130
Updates `software.amazon.awssdk:http-client-spi` from 2.20.129 to 2.20.130
Updates `software.amazon.awssdk:url-connection-client` from 2.20.128 to 2.20.130
Updates `software.amazon.awssdk:sqs` from 2.20.128 to 2.20.130
Updates `software.amazon.awssdk:s3` from 2.20.129 to 2.20.130
Updates `software.amazon.awssdk:dynamodb` from 2.20.129 to 2.20.130
Updates `software.amazon.awssdk:lambda` from 2.20.129 to 2.20.130
Updates `software.amazon.awssdk:kinesis` from 2.20.128 to 2.20.130
Updates `software.amazon.awssdk:cloudwatch` from 2.20.129 to 2.20.130
Updates `software.amazon.awssdk:xray` from 2.20.129 to 2.20.130
Updates `software.amazon.awssdk:cloudformation` from 2.20.129 to 2.20.130
Updates `software.amazon.awssdk:sts` from 2.20.129 to 2.20.130
---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:url-connection-client
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sqs
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:s3
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:dynamodb
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:lambda
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:kinesis
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudwatch
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:xray
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:cloudformation
dependency-type: direct:development
update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:sts
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Fix batch pom (#1385)
* Update to snapshot (#1384)
* Fix batch logging (#1387)
---------
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alexey Soshin
Co-authored-by: Jérôme Van Der Linden <117538+jeromevdl@users.noreply.github.com>
---
CHANGELOG.md | 22 ++
README.md | 6 +-
examples/.gitignore | 2 +
examples/README.md | 10 +-
examples/pom.xml | 4 +-
examples/powertools-examples-batch/pom.xml | 14 +-
.../batch/kinesis/KinesisBatchHandler.java | 2 +-
.../pom.xml | 14 +-
examples/powertools-examples-core/.gitignore | 0
examples/powertools-examples-core/README.md | 27 +--
.../powertools-examples-core/cdk/README.md | 36 ++++
.../{ => cdk/app}/events/event.json | 0
.../powertools-examples-core/cdk/app/pom.xml | 200 ++++++++++++++++++
.../app}/src/main/java/helloworld/App.java | 26 +--
.../src/main/java/helloworld/AppStream.java | 0
.../app}/src/main/resources/log4j2.xml | 0
.../src/test/java/helloworld/AppTest.java | 0
.../cdk/infra/cdk.json | 36 ++++
.../cdk/infra/pom.xml | 56 +++++
.../cdk/infra/src/main/java/cdk/CdkApp.java | 53 +++++
.../cdk/infra/src/main/java/cdk/CdkStack.java | 144 +++++++++++++
.../infra/src/test/java/cdk/CdkStackTest.java | 48 +++++
.../powertools-examples-core/sam/README.md | 24 +++
.../sam/events/event.json | 63 ++++++
.../{ => sam}/pom.xml | 12 +-
.../sam/src/main/java/helloworld/App.java | 107 ++++++++++
.../src/main/java/helloworld/AppStream.java | 38 ++++
.../sam/src/main/resources/log4j2.xml | 16 ++
.../sam/src/test/java/helloworld/AppTest.java | 59 ++++++
.../{ => sam}/template.yaml | 0
.../powertools-examples-idempotency/pom.xml | 12 +-
.../src/main/java/helloworld/App.java | 3 +-
.../powertools-examples-parameters/pom.xml | 2 +-
.../powertools-examples-serialization/pom.xml | 2 +-
.../powertools-examples-validation/pom.xml | 2 +-
mkdocs.yml | 2 +-
pom.xml | 4 +-
powertools-batch/pom.xml | 3 +
powertools-e2e-tests/handlers/pom.xml | 14 +-
powertools-e2e-tests/pom.xml | 4 +-
40 files changed, 969 insertions(+), 98 deletions(-)
delete mode 100644 examples/powertools-examples-core/.gitignore
create mode 100644 examples/powertools-examples-core/cdk/README.md
rename examples/powertools-examples-core/{ => cdk/app}/events/event.json (100%)
create mode 100644 examples/powertools-examples-core/cdk/app/pom.xml
rename examples/powertools-examples-core/{ => cdk/app}/src/main/java/helloworld/App.java (82%)
rename examples/powertools-examples-core/{ => cdk/app}/src/main/java/helloworld/AppStream.java (100%)
rename examples/powertools-examples-core/{ => cdk/app}/src/main/resources/log4j2.xml (100%)
rename examples/powertools-examples-core/{ => cdk/app}/src/test/java/helloworld/AppTest.java (100%)
create mode 100644 examples/powertools-examples-core/cdk/infra/cdk.json
create mode 100644 examples/powertools-examples-core/cdk/infra/pom.xml
create mode 100644 examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkApp.java
create mode 100644 examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkStack.java
create mode 100644 examples/powertools-examples-core/cdk/infra/src/test/java/cdk/CdkStackTest.java
create mode 100644 examples/powertools-examples-core/sam/README.md
create mode 100644 examples/powertools-examples-core/sam/events/event.json
rename examples/powertools-examples-core/{ => sam}/pom.xml (94%)
create mode 100644 examples/powertools-examples-core/sam/src/main/java/helloworld/App.java
create mode 100644 examples/powertools-examples-core/sam/src/main/java/helloworld/AppStream.java
create mode 100644 examples/powertools-examples-core/sam/src/main/resources/log4j2.xml
create mode 100644 examples/powertools-examples-core/sam/src/test/java/helloworld/AppTest.java
rename examples/powertools-examples-core/{ => sam}/template.yaml (100%)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5619f0bbb..dbb90ce3f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,28 @@ This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) fo
## [Unreleased]
+## [1.17.0] - 2023-08-21
+
+### Added
+* Feat: Add Batch Processor module in (#1317) by @scottgerring
+* Feat: Add SNS+SQS large messages module (#1310) by @jeromevdl
+
+### Maintenance
+* fix: use default credentials provider for all provided SDK clients in (#1303) by @roamingthings
+* Chore: Make request for Logger explicitly for current class in (#1307) by @jreijn
+* Chore: checkstyle formater & linter in (#1316) by @jeromevdl
+* Chore: Add powertools specific user-agent-suffix to the AWS SDK v2 clients by @eldimi in (#1306)
+* Chore: Add 'v2' branch to build workflows to prepare for v2 work in (#1341) by @scottgerring
+* Deps: Bump third party dependencies to the latest versions.
+
+### Documentation
+* Docs: Add maintainers guide in (#1326) by @scottgerring
+* Docs: improve contributing guide in (#1334) by @jeromevdl
+* Docs: Improve example documentation in (#1291) by @scottgerring
+* Docs: Add discord + sec disclosure links to readme in (#1311) by @scottgerring
+* Docs: Add external examples from AWS SAM CLI App Templates in (#1318) by @AlexeySoshin
+* Docs: Add CDK example in (#1321) by @AlexeySoshin
+
## [1.16.1] - 2023-07-19
* Fix: idempotency timeout bug (#1285) by @scottgerring
diff --git a/README.md b/README.md
index 47fb59bd7..76f8b2e4b 100644
--- a/README.md
+++ b/README.md
@@ -22,17 +22,17 @@ Powertools for AWS Lambda (Java) is available in Maven Central. You can use your
software.amazon.lambda
powertools-tracing
- 1.16.1
+ 1.17.0
software.amazon.lambda
powertools-logging
- 1.16.1
+ 1.17.0
software.amazon.lambda
powertools-metrics
- 1.16.1
+ 1.17.0
...
diff --git a/examples/.gitignore b/examples/.gitignore
index 79e044a40..892320d3b 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -1,2 +1,4 @@
dependency-reduced-pom.xml
.aws-sam
+cdk.out
+.m2
diff --git a/examples/README.md b/examples/README.md
index 9b76faa82..0744c2bb1 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -5,7 +5,9 @@ Each example can be copied from its subdirectory and used independently of the r
## Examples
-* [powertools-examples-core](powertools-examples-core) - Demonstrates the core logging, tracing, and metrics modules
+* [powertools-examples-core](powertools-examples-core) - Demonstrates the core logging, tracing, and metrics modules with different build tools
+ * [SAM](./powertools-examples-core/sam)
+ * [CDK](./powertools-examples-core/cdk)
* [powertools-examples-idempotency](powertools-examples-idempotency) - An idempotent HTTP API
* [powertools-examples-parameters](powertools-examples-parameters) - Uses the parameters module to provide runtime parameters to a function
* [powertools-examples-serialization](powertools-examples-serialization) - Uses the serialization module to serialize and deserialize API Gateway & SQS payloads
@@ -34,8 +36,8 @@ amongst other things.
To build and deploy an example application for the first time, run the following in your shell:
```bash
-# Switch to the directory containing an example for the powertools-core module
-$ cd powertools-examples-core
+# Switch to the directory containing an example for the powertools-idempotency module
+$ cd powertools-examples-idempotency
# Build and deploy the example
$ sam build
@@ -52,6 +54,8 @@ The first command will build the source of your application. The second command
You can find your API Gateway Endpoint URL in the output values displayed after deployment.
+If you're not using SAM, you can look for examples for other tools under [powertools-examples-core](./powertools-examples-core)
+
### External examples
You can find more examples in the https://github.com/aws/aws-sam-cli-app-templates project:
diff --git a/examples/pom.xml b/examples/pom.xml
index aca250dae..f290b3951 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -29,7 +29,9 @@
- powertools-examples-core
+ powertools-examples-core/sam
+ powertools-examples-core/cdk/app
+ powertools-examples-core/cdk/infra
powertools-examples-idempotency
powertools-examples-parameters
powertools-examples-serialization
diff --git a/examples/powertools-examples-batch/pom.xml b/examples/powertools-examples-batch/pom.xml
index 10e15d532..9efa7fa63 100644
--- a/examples/powertools-examples-batch/pom.xml
+++ b/examples/powertools-examples-batch/pom.xml
@@ -15,7 +15,7 @@
1.8
1.8
true
- 2.20.109
+ 2.20.128
@@ -37,7 +37,7 @@
com.amazonaws
aws-lambda-java-core
- 1.2.2
+ 1.2.3
software.amazon.awssdk
@@ -107,18 +107,16 @@
-
-
+
- com.github.edwgiz
- maven-shade-plugin.log4j2-cachefile-transformer
- 2.15
+ org.apache.logging.log4j
+ log4j-transform-maven-shade-plugin-extensions
+ 0.1.0
diff --git a/examples/powertools-examples-batch/src/main/java/org/demo/batch/kinesis/KinesisBatchHandler.java b/examples/powertools-examples-batch/src/main/java/org/demo/batch/kinesis/KinesisBatchHandler.java
index d9339549b..b188df501 100644
--- a/examples/powertools-examples-batch/src/main/java/org/demo/batch/kinesis/KinesisBatchHandler.java
+++ b/examples/powertools-examples-batch/src/main/java/org/demo/batch/kinesis/KinesisBatchHandler.java
@@ -12,7 +12,7 @@
public class KinesisBatchHandler implements RequestHandler {
- private final static Logger LOGGER = LogManager.getLogger(org.demo.batch.sqs.SqsBatchHandler.class);
+ private final static Logger LOGGER = LogManager.getLogger(KinesisBatchHandler.class);
private final BatchMessageHandler handler;
public KinesisBatchHandler() {
diff --git a/examples/powertools-examples-cloudformation/pom.xml b/examples/powertools-examples-cloudformation/pom.xml
index c9fe249b3..50cfff85d 100644
--- a/examples/powertools-examples-cloudformation/pom.xml
+++ b/examples/powertools-examples-cloudformation/pom.xml
@@ -14,9 +14,9 @@
1.8
1.8
true
- 1.2.2
+ 1.2.3
3.11.2
- 2.20.119
+ 2.20.130
@@ -132,18 +132,16 @@
-
-
+
- com.github.edwgiz
- maven-shade-plugin.log4j2-cachefile-transformer
- 2.15
+ org.apache.logging.log4j
+ log4j-transform-maven-shade-plugin-extensions
+ 0.1.0
diff --git a/examples/powertools-examples-core/.gitignore b/examples/powertools-examples-core/.gitignore
deleted file mode 100644
index e69de29bb..000000000
diff --git a/examples/powertools-examples-core/README.md b/examples/powertools-examples-core/README.md
index a47d0d26c..f11982477 100644
--- a/examples/powertools-examples-core/README.md
+++ b/examples/powertools-examples-core/README.md
@@ -5,17 +5,17 @@ This project demonstrates the Lambda for Powertools Java module - including
[tracing](https://docs.powertools.aws.dev/lambda/java/core/tracing/), and
[metrics](https://docs.powertools.aws.dev/lambda/java/core/metrics/).
-It is made up of the following:
+We provide examples for the following infrastructure-as-code tools:
+* [AWS SAM](sam/)
+* [AWS CDK](cdk/)
-- [App.java](src/main/java/helloworld/App.java) - Code for the application's Lambda function.
-- [events](events) - Invocation events that you can use to invoke the function.
-- [AppTests.java](src/test/java/helloworld/AppTest.java) - Unit tests for the application code.
-- [template.yaml](template.yaml) - A template that defines the application's AWS resources.
+For each of the tools, the example application is the same, and consists of the following files:
-## Deploy the sample application
+- [App.java](sam/src/main/java/helloworld/App.java) - Code for the application's Lambda function.
+- [AppTests.java](sam/src/test/java/helloworld/AppTest.java) - Unit tests for the application code.
+- [events](sam/events/event.json) - Invocation events that you can use to invoke the function.
-This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting
-started with SAM in [the examples directory](../README.md)
+Configuration files and deployment process for each tool are described in corresponding README files.
## Test the application
@@ -35,13 +35,4 @@ different function calls within the example
Likewise, from the CloudWatch dashboard, under **Metrics**, **all metrics**, you will find the namespaces `Another`
and `ServerlessAirline`. The values in each of these are published by the code in
-[App.java](src/main/java/helloworld/App.java).
-
-You can also watch the trace information or log information using the SAM CLI:
-```bash
-# Tail the logs
-sam logs --tail $MY_STACK
-
-# Tail the traces
-sam traces --tail
-```
\ No newline at end of file
+[App.java](sam/src/main/java/helloworld/App.java).
diff --git a/examples/powertools-examples-core/cdk/README.md b/examples/powertools-examples-core/cdk/README.md
new file mode 100644
index 000000000..f15a24168
--- /dev/null
+++ b/examples/powertools-examples-core/cdk/README.md
@@ -0,0 +1,36 @@
+# Powertools for AWS Lambda (Java) - Core Utilities Example with CDK
+
+This project demonstrates the Lambda for Powertools Java module deployed using [Cloud Development Kit](https://aws.amazon.com/cdk/).
+
+For general information on the deployed example itself, you can refer to the parent [README](../README.md)
+
+## Configuration
+CDK uses the following project structure:
+- [app](./app) - stores the source code of your application, which is similar between all examples
+- [infra](./infra) - stores the definition of your infrastructure
+ - [cdk.json](./infra/cdk.json) - tells the CDK Toolkit how to execute your app
+ - [CdkApp](./infra/src/main/java/cdk/CdkApp.java) - bootstraps your stack, taking AWS `account` and `region` as input
+ - [CdkStack](./infra/src/main/java/cdk/CdkStack.java) - defines the Lambda function to be deployed as well as API Gateway for it.
+
+It is a [Maven](https://maven.apache.org/) based project, so you can open this project with any Maven compatible Java IDE to build and run tests.
+
+
+## Deploy the sample application
+
+The minimum to deploy the app should be
+```bash
+cdk deploy
+```
+
+If you're running CDK for the first time, you'll need to first run the bootstrap command:
+```bash
+cdk bootstrap
+```
+
+## Useful commands
+
+* `mvn package` compile and run tests
+* `cdk synth` emits the synthesized CloudFormation template
+* `cdk deploy` deploy this stack to your default AWS account/region
+* `cdk diff` compare deployed stack with current state
+* `cdk docs` open CDK documentation
\ No newline at end of file
diff --git a/examples/powertools-examples-core/events/event.json b/examples/powertools-examples-core/cdk/app/events/event.json
similarity index 100%
rename from examples/powertools-examples-core/events/event.json
rename to examples/powertools-examples-core/cdk/app/events/event.json
diff --git a/examples/powertools-examples-core/cdk/app/pom.xml b/examples/powertools-examples-core/cdk/app/pom.xml
new file mode 100644
index 000000000..a1aba1b8d
--- /dev/null
+++ b/examples/powertools-examples-core/cdk/app/pom.xml
@@ -0,0 +1,200 @@
+
+ 4.0.0
+
+ software.amazon.lambda.examples
+ 1.16.1
+ powertools-examples-core-cdk
+ jar
+
+ Powertools for AWS Lambda (Java) library Examples - Core
+
+
+ 2.20.0
+ 1.8
+ 1.8
+ true
+
+
+
+
+ software.amazon.lambda
+ powertools-tracing
+ ${project.version}
+
+
+ software.amazon.lambda
+ powertools-logging
+ ${project.version}
+
+
+ software.amazon.lambda
+ powertools-metrics
+ ${project.version}
+
+
+ com.amazonaws
+ aws-lambda-java-core
+ 1.2.3
+
+
+ com.amazonaws
+ aws-lambda-java-events
+ 3.11.2
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j.version}
+
+
+ org.apache.logging.log4j
+ log4j-api
+ ${log4j.version}
+
+
+
+ junit
+ junit
+ 4.13.2
+ test
+
+
+
+
+ helloworld-lambda
+
+
+ dev.aspectj
+ aspectj-maven-plugin
+ 1.13.1
+
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+ ${maven.compiler.target}
+
+
+ software.amazon.lambda
+ powertools-tracing
+
+
+ software.amazon.lambda
+ powertools-logging
+
+
+ software.amazon.lambda
+ powertools-metrics
+
+
+
+
+
+
+ compile
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.5.0
+
+
+ package
+
+ shade
+
+
+
+
+
+
+
+
+
+
+ org.apache.logging.log4j
+ log4j-transform-maven-shade-plugin-extensions
+ 0.1.0
+
+
+
+
+
+
+
+
+ jdk8
+
+ (,11)
+
+
+ 1.9.7
+
+
+
+
+ org.aspectj
+ aspectjtools
+ ${aspectj.version}
+
+
+
+
+
+
+
+ dev.aspectj
+ aspectj-maven-plugin
+ ${aspectj.plugin.version}
+
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+ ${maven.compiler.target}
+
+
+ software.amazon.lambda
+ powertools-tracing
+
+
+ software.amazon.lambda
+ powertools-logging
+
+
+ software.amazon.lambda
+ powertools-metrics
+
+
+
+
+
+
+ compile
+ test-compile
+
+
+
+
+
+
+ org.aspectj
+ aspectjtools
+ ${aspectj.version}
+
+
+
+
+
+
+
+
+
diff --git a/examples/powertools-examples-core/src/main/java/helloworld/App.java b/examples/powertools-examples-core/cdk/app/src/main/java/helloworld/App.java
similarity index 82%
rename from examples/powertools-examples-core/src/main/java/helloworld/App.java
rename to examples/powertools-examples-core/cdk/app/src/main/java/helloworld/App.java
index a1ea9a9e3..988da2a73 100644
--- a/examples/powertools-examples-core/src/main/java/helloworld/App.java
+++ b/examples/powertools-examples-core/cdk/app/src/main/java/helloworld/App.java
@@ -17,14 +17,11 @@
import static software.amazon.lambda.powertools.metrics.MetricsUtils.metricsLogger;
import static software.amazon.lambda.powertools.metrics.MetricsUtils.withSingleMetric;
import static software.amazon.lambda.powertools.tracing.TracingUtils.putMetadata;
-import static software.amazon.lambda.powertools.tracing.TracingUtils.withEntitySubsegment;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
-import com.amazonaws.xray.AWSXRay;
-import com.amazonaws.xray.entities.Entity;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -83,38 +80,17 @@ public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEv
log.info(output);
});
- threadOption1();
-
- threadOption2();
-
log.info("After output");
return response
.withStatusCode(200)
.withBody(output);
- } catch (IOException | InterruptedException e) {
+ } catch (IOException e) {
return response
.withBody("{}")
.withStatusCode(500);
}
}
- private void threadOption1() throws InterruptedException {
- final Entity traceEntity = AWSXRay.getTraceEntity();
- assert traceEntity != null;
- traceEntity.run(new Thread(this::log));
- }
-
- private void threadOption2() throws InterruptedException {
- Entity traceEntity = AWSXRay.getTraceEntity();
- Thread anotherThread = new Thread(() -> withEntitySubsegment("inlineLog", traceEntity, subsegment ->
- {
- String var = "somethingToProcess";
- log.info("inside threaded logging inline {}", var);
- }));
- anotherThread.start();
- anotherThread.join();
- }
-
@Tracing
private void log() {
log.info("inside threaded logging for function");
diff --git a/examples/powertools-examples-core/src/main/java/helloworld/AppStream.java b/examples/powertools-examples-core/cdk/app/src/main/java/helloworld/AppStream.java
similarity index 100%
rename from examples/powertools-examples-core/src/main/java/helloworld/AppStream.java
rename to examples/powertools-examples-core/cdk/app/src/main/java/helloworld/AppStream.java
diff --git a/examples/powertools-examples-core/src/main/resources/log4j2.xml b/examples/powertools-examples-core/cdk/app/src/main/resources/log4j2.xml
similarity index 100%
rename from examples/powertools-examples-core/src/main/resources/log4j2.xml
rename to examples/powertools-examples-core/cdk/app/src/main/resources/log4j2.xml
diff --git a/examples/powertools-examples-core/src/test/java/helloworld/AppTest.java b/examples/powertools-examples-core/cdk/app/src/test/java/helloworld/AppTest.java
similarity index 100%
rename from examples/powertools-examples-core/src/test/java/helloworld/AppTest.java
rename to examples/powertools-examples-core/cdk/app/src/test/java/helloworld/AppTest.java
diff --git a/examples/powertools-examples-core/cdk/infra/cdk.json b/examples/powertools-examples-core/cdk/infra/cdk.json
new file mode 100644
index 000000000..e24ee7b04
--- /dev/null
+++ b/examples/powertools-examples-core/cdk/infra/cdk.json
@@ -0,0 +1,36 @@
+{
+ "app": "mvn -e -q compile exec:java",
+ "watch": {
+ "include": [
+ "**"
+ ],
+ "exclude": [
+ "README.md",
+ "cdk*.json",
+ "target",
+ "pom.xml",
+ "src/test"
+ ]
+ },
+ "context": {
+ "@aws-cdk/aws-lambda:recognizeLayerVersion": true,
+ "@aws-cdk/core:checkSecretUsage": true,
+ "@aws-cdk/core:target-partitions": [
+ "aws",
+ "aws-cn"
+ ],
+ "@aws-cdk/aws-iam:minimizePolicies": true,
+ "@aws-cdk/core:validateSnapshotRemovalPolicy": true,
+ "@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
+ "@aws-cdk/core:enablePartitionLiterals": true,
+ "@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
+ "@aws-cdk/aws-iam:standardizedServicePrincipals": true,
+ "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
+ "@aws-cdk/customresources:installLatestAwsSdkDefault": false,
+ "@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
+ "@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
+ "@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
+ "@aws-cdk/aws-kms:aliasNameRef": true,
+ "@aws-cdk/core:includePrefixInUniqueNameGeneration": true
+ }
+}
diff --git a/examples/powertools-examples-core/cdk/infra/pom.xml b/examples/powertools-examples-core/cdk/infra/pom.xml
new file mode 100644
index 000000000..d81118cde
--- /dev/null
+++ b/examples/powertools-examples-core/cdk/infra/pom.xml
@@ -0,0 +1,56 @@
+
+
+ 4.0.0
+ software.amazon.lambda.examples
+ cdk
+ 1.18.0-SNAPSHOT
+
+ UTF-8
+ 2.91.0
+ [10.0.0,11.0.0)
+ 5.10.0
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.11.0
+
+ 1.8
+ 1.8
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.1.0
+
+ cdk.CdkApp
+
+
+
+
+
+
+
+ software.amazon.awscdk
+ aws-cdk-lib
+ ${cdk.version}
+
+
+ software.constructs
+ constructs
+ ${constructs.version}
+
+
+
+ org.junit.jupiter
+ junit-jupiter
+ ${junit.version}
+ test
+
+
+
diff --git a/examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkApp.java b/examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkApp.java
new file mode 100644
index 000000000..d564eb9a0
--- /dev/null
+++ b/examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkApp.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2023 Amazon.com, Inc. or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package cdk;
+
+import software.amazon.awscdk.App;
+import software.amazon.awscdk.StackProps;
+
+public class CdkApp {
+ public static void main(final String[] args) {
+ App app = new App();
+
+ new CdkStack(app, "CdkStack", StackProps.builder()
+ // If you don't specify 'env', this stack will be environment-agnostic.
+ // Account/Region-dependent features and context lookups will not work,
+ // but a single synthesized template can be deployed anywhere.
+
+ // Uncomment the next block to specialize this stack for the AWS Account
+ // and Region that are implied by the current CLI configuration.
+ /*
+ .env(Environment.builder()
+ .account(System.getenv("CDK_DEFAULT_ACCOUNT"))
+ .region(System.getenv("CDK_DEFAULT_REGION"))
+ .build())
+ */
+
+
+ // Uncomment the next block if you know exactly what Account and Region you
+ // want to deploy the stack to.
+ /*
+ .env(Environment.builder()
+ .account("1234567890")
+ .region("region")
+ .build())
+ */
+
+ // For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html
+ .build());
+
+ app.synth();
+ }
+}
diff --git a/examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkStack.java b/examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkStack.java
new file mode 100644
index 000000000..8e6b44112
--- /dev/null
+++ b/examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkStack.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2023 Amazon.com, Inc. or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package cdk;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import software.amazon.awscdk.BundlingOptions;
+import software.amazon.awscdk.CfnOutput;
+import software.amazon.awscdk.Duration;
+import software.amazon.awscdk.Stack;
+import software.amazon.awscdk.StackProps;
+import software.amazon.awscdk.services.apigateway.LambdaIntegration;
+import software.amazon.awscdk.services.apigateway.RestApi;
+import software.amazon.awscdk.services.lambda.Code;
+import software.amazon.awscdk.services.lambda.Function;
+import software.amazon.awscdk.services.lambda.Runtime;
+import software.amazon.awscdk.services.lambda.Tracing;
+import software.amazon.awscdk.services.s3.assets.AssetOptions;
+import software.constructs.Construct;
+
+/**
+ * Defines a stack that consists of a single Java Lambda function and an API Gateway
+ */
+public class CdkStack extends Stack {
+ private static final String SHELL_COMMAND = "/bin/sh";
+ private static final String MAVEN_PACKAGE = "mvn package";
+ private static final String COPY_OUTPUT = "cp /asset-input/target/helloworld-lambda.jar /asset-output/";
+
+ public CdkStack(final Construct scope, final String id) {
+ this(scope, id, null);
+ }
+
+ public CdkStack(final Construct scope, final String id, final StackProps props) {
+ super(scope, id, props);
+
+ Function helloWorldFunction = createHelloWorldFunction();
+ Function helloWorldStreamFunction = createHelloWorldStreamFunction();
+ RestApi restApi = createHelloWorldApi();
+
+ restApi.getRoot().resourceForPath("/hello")
+ .addMethod("GET", LambdaIntegration.Builder.create(helloWorldFunction)
+ .build());
+
+ restApi.getRoot().resourceForPath("/hellostream")
+ .addMethod("GET", LambdaIntegration.Builder.create(helloWorldStreamFunction)
+ .build());
+
+ outputApiUrl(restApi);
+ }
+
+ private static List createFunctionPackageInstructions() {
+ // CDK will use this command to package your Java Lambda
+ return Arrays.asList(
+ SHELL_COMMAND,
+ "-c",
+ MAVEN_PACKAGE + " && " +
+ COPY_OUTPUT
+ );
+ }
+
+ /**
+ * Adds API URL to the outputs
+ *
+ * @param restApi
+ */
+ private void outputApiUrl(RestApi restApi) {
+ CfnOutput.Builder.create(this, "HelloWorldApiUrl")
+ .description("API Gateway endpoint URL for Prod stage for Hello World function")
+ .value(restApi.getUrl() + "hello").build();
+ }
+
+ // Method to create the Lambda function
+ private Function createHelloWorldFunction() {
+ List functionPackageInstructions = createFunctionPackageInstructions();
+
+ Map environment = new HashMap<>();
+ environment.put("POWERTOOLS_LOG_LEVEL", "INFO");
+ environment.put("POWERTOOLS_LOGGER_SAMPLE_RATE", "0.1");
+ environment.put("POWERTOOLS_LOGGER_LOG_EVENT", "true");
+ environment.put("POWERTOOLS_METRICS_NAMESPACE", "Coreutilities");
+
+ return Function.Builder.create(this, "HelloWorldFunction")
+ .runtime(Runtime.JAVA_11)
+ .memorySize(512)
+ .timeout(Duration.seconds(20))
+ .tracing(Tracing.ACTIVE)
+ .code(Code.fromAsset("../app/", AssetOptions.builder()
+ .bundling(BundlingOptions.builder()
+ .image(Runtime.JAVA_11.getBundlingImage())
+ .command(functionPackageInstructions)
+ .build())
+ .build()))
+ .handler("helloworld.App")
+ .environment(environment)
+ .build();
+ }
+
+ private Function createHelloWorldStreamFunction() {
+ List functionPackageInstructions = createFunctionPackageInstructions();
+
+ Map environment = new HashMap<>();
+ environment.put("POWERTOOLS_LOG_LEVEL", "INFO");
+ environment.put("POWERTOOLS_LOGGER_SAMPLE_RATE", "0.7");
+ environment.put("POWERTOOLS_LOGGER_LOG_EVENT", "true");
+ environment.put("POWERTOOLS_METRICS_NAMESPACE", "Coreutilities");
+ environment.put("POWERTOOLS_SERVICE_NAME", "hello");
+
+ return Function.Builder.create(this, "HelloWorldStreamFunction")
+ .runtime(Runtime.JAVA_11)
+ .memorySize(512)
+ .timeout(Duration.seconds(20))
+ .tracing(Tracing.ACTIVE)
+ .code(Code.fromAsset("../app/", AssetOptions.builder()
+ .bundling(BundlingOptions.builder()
+ .image(Runtime.JAVA_11.getBundlingImage())
+ .command(functionPackageInstructions)
+ .build())
+ .build()))
+ .handler("helloworld.AppStream")
+ .environment(environment)
+ .build();
+ }
+
+ // Method to create the REST API
+ private RestApi createHelloWorldApi() {
+ return RestApi.Builder.create(this, "HelloWorldApi")
+ .description("API Gateway endpoint URL for Prod stage for Hello World function")
+ .build();
+ }
+}
diff --git a/examples/powertools-examples-core/cdk/infra/src/test/java/cdk/CdkStackTest.java b/examples/powertools-examples-core/cdk/infra/src/test/java/cdk/CdkStackTest.java
new file mode 100644
index 000000000..29cb15545
--- /dev/null
+++ b/examples/powertools-examples-core/cdk/infra/src/test/java/cdk/CdkStackTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2023 Amazon.com, Inc. or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package cdk;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+import software.amazon.awscdk.App;
+import software.amazon.awscdk.assertions.Template;
+
+public class CdkStackTest {
+
+ @Test
+ public void testStack() {
+ App app = new App();
+ CdkStack stack = new CdkStack(app, "test");
+
+ Template template = Template.fromStack(stack);
+
+ // There should be 2 lambda functions, one to handle regular input, and another for streaming
+ template.resourceCountIs("AWS::Lambda::Function", 2);
+
+ // API Gateway should exist
+ template.resourceCountIs("AWS::ApiGateway::RestApi", 1);
+
+ // API Gateway should have a path pointing to the regular Lambda
+ Map resourceProperties = new HashMap<>();
+ resourceProperties.put("PathPart", "hello");
+ template.hasResourceProperties("AWS::ApiGateway::Resource", resourceProperties);
+
+ // API Gateway should have a path pointing to the streaming Lambda
+ resourceProperties = new HashMap<>();
+ resourceProperties.put("PathPart", "hellostream");
+ template.hasResourceProperties("AWS::ApiGateway::Resource", resourceProperties);
+ }
+}
diff --git a/examples/powertools-examples-core/sam/README.md b/examples/powertools-examples-core/sam/README.md
new file mode 100644
index 000000000..7a4279ae3
--- /dev/null
+++ b/examples/powertools-examples-core/sam/README.md
@@ -0,0 +1,24 @@
+# Powertools for AWS Lambda (Java) - Core Utilities Example with SAM
+
+This project demonstrates the Lambda for Powertools Java module deployed using [Serverless Application Model](https://aws.amazon.com/serverless/sam/).
+
+For general information on the deployed example itself, you can refer to the parent [README](../README.md)
+
+## Configuration
+SAM uses [template.yaml](template.yaml) to define the application's AWS resources.
+This file defines the Lambda function to be deployed as well as API Gateway for it.
+
+## Deploy the sample application
+To deploy the example, check out the instructions for getting
+started with SAM in [the examples directory](../../README.md)
+
+## Additional notes
+
+You can watch the trace information or log information using the SAM CLI:
+```bash
+# Tail the logs
+sam logs --tail $MY_STACK
+
+# Tail the traces
+sam traces --tail
+```
\ No newline at end of file
diff --git a/examples/powertools-examples-core/sam/events/event.json b/examples/powertools-examples-core/sam/events/event.json
new file mode 100644
index 000000000..3822fadaa
--- /dev/null
+++ b/examples/powertools-examples-core/sam/events/event.json
@@ -0,0 +1,63 @@
+{
+ "body": "{\"message\": \"hello world\"}",
+ "resource": "/{proxy+}",
+ "path": "/path/to/resource",
+ "httpMethod": "POST",
+ "isBase64Encoded": false,
+ "queryStringParameters": {
+ "foo": "bar"
+ },
+ "pathParameters": {
+ "proxy": "/path/to/resource"
+ },
+ "stageVariables": {
+ "baz": "qux"
+ },
+ "headers": {
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
+ "Accept-Encoding": "gzip, deflate, sdch",
+ "Accept-Language": "en-US,en;q=0.8",
+ "Cache-Control": "max-age=0",
+ "CloudFront-Forwarded-Proto": "https",
+ "CloudFront-Is-Desktop-Viewer": "true",
+ "CloudFront-Is-Mobile-Viewer": "false",
+ "CloudFront-Is-SmartTV-Viewer": "false",
+ "CloudFront-Is-Tablet-Viewer": "false",
+ "CloudFront-Viewer-Country": "US",
+ "Host": "1234567890.execute-api.us-east-1.amazonaws.com",
+ "Upgrade-Insecure-Requests": "1",
+ "User-Agent": "Custom User Agent String",
+ "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)",
+ "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==",
+ "X-Forwarded-For": "127.0.0.1, 127.0.0.2",
+ "X-Forwarded-Port": "443",
+ "X-Forwarded-Proto": "https"
+ },
+ "requestContext": {
+ "accountId": "123456789012",
+ "resourceId": "123456",
+ "stage": "prod",
+ "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
+ "requestTime": "09/Apr/2015:12:34:56 +0000",
+ "requestTimeEpoch": 1428582896000,
+ "identity": {
+ "cognitoIdentityPoolId": null,
+ "accountId": null,
+ "cognitoIdentityId": null,
+ "caller": null,
+ "accessKey": null,
+ "sourceIp": "127.0.0.1",
+ "cognitoAuthenticationType": null,
+ "cognitoAuthenticationProvider": null,
+ "userArn": null,
+ "userAgent": "Custom User Agent String",
+ "user": null
+ },
+ "path": "/prod/path/to/resource",
+ "resourcePath": "/{proxy+}",
+ "httpMethod": "POST",
+ "apiId": "1234567890",
+ "protocol": "HTTP/1.1"
+ }
+ }
+
\ No newline at end of file
diff --git a/examples/powertools-examples-core/pom.xml b/examples/powertools-examples-core/sam/pom.xml
similarity index 94%
rename from examples/powertools-examples-core/pom.xml
rename to examples/powertools-examples-core/sam/pom.xml
index d402ce09c..bb2e01097 100644
--- a/examples/powertools-examples-core/pom.xml
+++ b/examples/powertools-examples-core/sam/pom.xml
@@ -35,7 +35,7 @@
com.amazonaws
aws-lambda-java-core
- 1.2.2
+ 1.2.3
com.amazonaws
@@ -106,18 +106,16 @@
-
-
+
- com.github.edwgiz
- maven-shade-plugin.log4j2-cachefile-transformer
- 2.15
+ org.apache.logging.log4j
+ log4j-transform-maven-shade-plugin-extensions
+ 0.1.0
diff --git a/examples/powertools-examples-core/sam/src/main/java/helloworld/App.java b/examples/powertools-examples-core/sam/src/main/java/helloworld/App.java
new file mode 100644
index 000000000..fccc63b9a
--- /dev/null
+++ b/examples/powertools-examples-core/sam/src/main/java/helloworld/App.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2023 Amazon.com, Inc. or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package helloworld;
+
+import static software.amazon.lambda.powertools.metrics.MetricsUtils.metricsLogger;
+import static software.amazon.lambda.powertools.metrics.MetricsUtils.withSingleMetric;
+import static software.amazon.lambda.powertools.tracing.TracingUtils.putMetadata;
+
+import com.amazonaws.services.lambda.runtime.Context;
+import com.amazonaws.services.lambda.runtime.RequestHandler;
+import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
+import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import software.amazon.cloudwatchlogs.emf.model.DimensionSet;
+import software.amazon.cloudwatchlogs.emf.model.Unit;
+import software.amazon.lambda.powertools.logging.Logging;
+import software.amazon.lambda.powertools.logging.LoggingUtils;
+import software.amazon.lambda.powertools.metrics.Metrics;
+import software.amazon.lambda.powertools.tracing.CaptureMode;
+import software.amazon.lambda.powertools.tracing.Tracing;
+import software.amazon.lambda.powertools.tracing.TracingUtils;
+
+/**
+ * Handler for requests to Lambda function.
+ */
+public class App implements RequestHandler {
+ private final static Logger log = LogManager.getLogger(App.class);
+
+ @Logging(logEvent = true, samplingRate = 0.7)
+ @Tracing(captureMode = CaptureMode.RESPONSE_AND_ERROR)
+ @Metrics(namespace = "ServerlessAirline", service = "payment", captureColdStart = true)
+ public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
+ Map headers = new HashMap<>();
+
+ headers.put("Content-Type", "application/json");
+ headers.put("X-Custom-Header", "application/json");
+
+ metricsLogger().putMetric("CustomMetric1", 1, Unit.COUNT);
+
+ withSingleMetric("CustomMetrics2", 1, Unit.COUNT, "Another", (metric) ->
+ {
+ metric.setDimensions(DimensionSet.of("AnotherService", "CustomService"));
+ metric.setDimensions(DimensionSet.of("AnotherService1", "CustomService1"));
+ });
+
+ LoggingUtils.appendKey("test", "willBeLogged");
+
+ APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent()
+ .withHeaders(headers);
+ try {
+ final String pageContents = this.getPageContents("https://checkip.amazonaws.com");
+ log.info(pageContents);
+ TracingUtils.putAnnotation("Test", "New");
+ String output = String.format("{ \"message\": \"hello world\", \"location\": \"%s\" }", pageContents);
+
+ TracingUtils.withSubsegment("loggingResponse", subsegment ->
+ {
+ String sampled = "log something out";
+ log.info(sampled);
+ log.info(output);
+ });
+
+ log.info("After output");
+ return response
+ .withStatusCode(200)
+ .withBody(output);
+ } catch (RuntimeException | IOException e) {
+ return response
+ .withBody("{}")
+ .withStatusCode(500);
+ }
+ }
+
+ @Tracing
+ private void log() {
+ log.info("inside threaded logging for function");
+ }
+
+ @Tracing(namespace = "getPageContents", captureMode = CaptureMode.DISABLED)
+ private String getPageContents(String address) throws IOException {
+ URL url = new URL(address);
+ putMetadata("getPageContents", address);
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()))) {
+ return br.lines().collect(Collectors.joining(System.lineSeparator()));
+ }
+ }
+}
diff --git a/examples/powertools-examples-core/sam/src/main/java/helloworld/AppStream.java b/examples/powertools-examples-core/sam/src/main/java/helloworld/AppStream.java
new file mode 100644
index 000000000..401ef8c48
--- /dev/null
+++ b/examples/powertools-examples-core/sam/src/main/java/helloworld/AppStream.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2023 Amazon.com, Inc. or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package helloworld;
+
+import com.amazonaws.services.lambda.runtime.Context;
+import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Map;
+import software.amazon.lambda.powertools.logging.Logging;
+import software.amazon.lambda.powertools.metrics.Metrics;
+
+public class AppStream implements RequestStreamHandler {
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @Override
+ @Logging(logEvent = true)
+ @Metrics(namespace = "ServerlessAirline", service = "payment", captureColdStart = true)
+ public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException {
+ Map map = mapper.readValue(input, Map.class);
+
+ System.out.println(map.size());
+ }
+}
diff --git a/examples/powertools-examples-core/sam/src/main/resources/log4j2.xml b/examples/powertools-examples-core/sam/src/main/resources/log4j2.xml
new file mode 100644
index 000000000..e1fd14cea
--- /dev/null
+++ b/examples/powertools-examples-core/sam/src/main/resources/log4j2.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/powertools-examples-core/sam/src/test/java/helloworld/AppTest.java b/examples/powertools-examples-core/sam/src/test/java/helloworld/AppTest.java
new file mode 100644
index 000000000..70dad8d71
--- /dev/null
+++ b/examples/powertools-examples-core/sam/src/test/java/helloworld/AppTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2023 Amazon.com, Inc. or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package helloworld;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
+import com.amazonaws.xray.AWSXRay;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AppTest {
+
+ @Before
+ public void setup() {
+ if (null == System.getenv("LAMBDA_TASK_ROOT")) {
+ AWSXRay.beginSegment("test");
+ }
+ }
+
+ @After
+ public void tearDown() {
+ if (AWSXRay.getCurrentSubsegmentOptional().isPresent()) {
+ AWSXRay.endSubsegment();
+ }
+
+ if (null == System.getenv("LAMBDA_TASK_ROOT")) {
+ AWSXRay.endSegment();
+ }
+ }
+
+ @Test
+ public void successfulResponse() {
+ App app = new App();
+ APIGatewayProxyResponseEvent result = app.handleRequest(null, null);
+ assertEquals(result.getStatusCode().intValue(), 200);
+ assertEquals(result.getHeaders().get("Content-Type"), "application/json");
+ String content = result.getBody();
+ assertNotNull(content);
+ assertTrue(content.contains("\"message\""));
+ assertTrue(content.contains("\"hello world\""));
+ assertTrue(content.contains("\"location\""));
+ }
+}
diff --git a/examples/powertools-examples-core/template.yaml b/examples/powertools-examples-core/sam/template.yaml
similarity index 100%
rename from examples/powertools-examples-core/template.yaml
rename to examples/powertools-examples-core/sam/template.yaml
diff --git a/examples/powertools-examples-idempotency/pom.xml b/examples/powertools-examples-idempotency/pom.xml
index 38682e164..d0e98ec28 100644
--- a/examples/powertools-examples-idempotency/pom.xml
+++ b/examples/powertools-examples-idempotency/pom.xml
@@ -48,7 +48,7 @@
com.amazonaws
aws-lambda-java-core
- 1.2.2
+ 1.2.3
com.amazonaws
@@ -169,18 +169,16 @@
-
-
+
- com.github.edwgiz
- maven-shade-plugin.log4j2-cachefile-transformer
- 2.15
+ org.apache.logging.log4j
+ log4j-transform-maven-shade-plugin-extensions
+ 0.1.0
diff --git a/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java b/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java
index ac2c7ef1b..72fa621ad 100644
--- a/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java
+++ b/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
@@ -113,7 +114,7 @@ public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEv
*/
private String getPageContents(String address) throws IOException {
URL url = new URL(address);
- try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"))) {
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) {
return br.lines().collect(Collectors.joining(System.lineSeparator()));
}
}
diff --git a/examples/powertools-examples-parameters/pom.xml b/examples/powertools-examples-parameters/pom.xml
index 1c7d177f4..19be585a5 100644
--- a/examples/powertools-examples-parameters/pom.xml
+++ b/examples/powertools-examples-parameters/pom.xml
@@ -27,7 +27,7 @@
com.amazonaws
aws-lambda-java-core
- 1.2.2
+ 1.2.3
com.amazonaws
diff --git a/examples/powertools-examples-serialization/pom.xml b/examples/powertools-examples-serialization/pom.xml
index 0ec05cd82..d084df983 100644
--- a/examples/powertools-examples-serialization/pom.xml
+++ b/examples/powertools-examples-serialization/pom.xml
@@ -27,7 +27,7 @@
com.amazonaws
aws-lambda-java-core
- 1.2.2
+ 1.2.3
com.amazonaws
diff --git a/examples/powertools-examples-validation/pom.xml b/examples/powertools-examples-validation/pom.xml
index b3947513f..d4b26d166 100644
--- a/examples/powertools-examples-validation/pom.xml
+++ b/examples/powertools-examples-validation/pom.xml
@@ -41,7 +41,7 @@
com.amazonaws
aws-lambda-java-core
- 1.2.2
+ 1.2.3
diff --git a/mkdocs.yml b/mkdocs.yml
index 62d8d75ce..cde47c815 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -85,7 +85,7 @@ extra_javascript:
extra:
powertools:
- version: 1.16.1 # to update after each release (we do not want snapshot version here)
+ version: 1.17.0 # to update after each release (we do not want snapshot version here)
repo_url: https://github.com/aws-powertools/powertools-lambda-java
edit_uri: edit/main/docs
diff --git a/pom.xml b/pom.xml
index 7cdf8a71f..24f71c6bd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,11 +74,11 @@
2.20.0
2.15.2
1.9.7
- 2.20.119
+ 2.20.130
2.14.0
2.1.3
UTF-8
- 1.2.2
+ 1.2.3
3.11.2
1.1.2
3.11.0
diff --git a/powertools-batch/pom.xml b/powertools-batch/pom.xml
index 593b22444..2c878416a 100644
--- a/powertools-batch/pom.xml
+++ b/powertools-batch/pom.xml
@@ -9,6 +9,9 @@
2.0.0-SNAPSHOT
+ A suite of utilities that makes batch message processing using AWS Lambda easier.
+ Powertools for AWS Lambda (Java) batch messages
+
diff --git a/powertools-e2e-tests/handlers/pom.xml b/powertools-e2e-tests/handlers/pom.xml
index 49b4b5a20..7abaec9d0 100644
--- a/powertools-e2e-tests/handlers/pom.xml
+++ b/powertools-e2e-tests/handlers/pom.xml
@@ -120,19 +120,17 @@
-
-
+
-
- io.github.edwgiz
- log4j-maven-shade-plugin-extensions
- 2.17.2
-
+
+ org.apache.logging.log4j
+ log4j-transform-maven-shade-plugin-extensions
+ 0.1.0
+
diff --git a/powertools-e2e-tests/pom.xml b/powertools-e2e-tests/pom.xml
index e8a3273b1..8f3997dbd 100644
--- a/powertools-e2e-tests/pom.xml
+++ b/powertools-e2e-tests/pom.xml
@@ -31,7 +31,7 @@
1.8
1.8
10.2.69
- 2.89.0
+ 2.91.0
true
@@ -162,7 +162,7 @@
org.yaml
snakeyaml
- 2.0
+ 2.1
test
From 50e7b56feed62e1c964a0384a0b1968c2affe7b6 Mon Sep 17 00:00:00 2001
From: Scott Gerring
Date: Thu, 24 Aug 2023 14:26:16 +0100
Subject: [PATCH 04/16] chore: [V2] rename 'core' module to 'common' (#1364)
* First rename
* POM updates
* Rename namespace
* Fix
* Fix?
* More namespace changes
* Rename core examples to core utilities
* Finish renaming core utilities
* Clean up name/description of module
* More change
* Fix readme
---
examples/README.md | 8 ++++----
examples/pom.xml | 6 +++---
.../.gitignore | 0
.../README.md | 0
.../cdk/README.md | 10 +++++-----
.../cdk/app/events/event.json | 0
.../cdk/app/pom.xml | 2 +-
.../cdk/app/src/main/java/helloworld/App.java | 0
.../src/main/java/helloworld/AppStream.java | 0
.../cdk/app/src/main/resources/log4j2.xml | 0
.../app/src/test/java/helloworld/AppTest.java | 0
.../cdk/infra/cdk.json | 0
.../cdk/infra/pom.xml | 0
.../cdk/infra/src/main/java/cdk/CdkApp.java | 0
.../cdk/infra/src/main/java/cdk/CdkStack.java | 0
.../infra/src/test/java/cdk/CdkStackTest.java | 0
.../sam/README.md | 0
.../sam/events/event.json | 0
.../sam/pom.xml | 4 ++--
.../sam/src/main/java/helloworld/App.java | 0
.../src/main/java/helloworld/AppStream.java | 0
.../sam/src/main/resources/log4j2.xml | 0
.../sam/src/test/java/helloworld/AppTest.java | 0
.../sam/template.yaml | 0
pom.xml | 4 ++--
{powertools-core => powertools-common}/pom.xml | 10 ++++------
.../common}/internal/LambdaConstants.java | 2 +-
.../internal/LambdaHandlerProcessor.java | 4 ++--
.../common}/internal/SystemWrapper.java | 2 +-
.../internal/UserAgentConfigurator.java | 4 ++--
.../main/resources-filtered/version.properties | 0
.../internal/LambdaHandlerProcessorTest.java | 7 +++++--
.../internal/UserAgentConfiguratorTest.java | 13 +++++++------
.../src/test/resources/test.properties | 0
.../src/test/resources/unreadable.properties | 0
powertools-idempotency/pom.xml | 2 +-
.../idempotency/internal/IdempotentAspect.java | 2 +-
.../persistence/BasePersistenceStore.java | 2 +-
.../persistence/DynamoDBPersistenceStore.java | 6 +++---
powertools-large-messages/pom.xml | 2 +-
.../largemessages/LargeMessageConfig.java | 2 +-
powertools-logging/pom.xml | 2 +-
.../logging/internal/LambdaLoggingAspect.java | 16 ++++++++--------
.../internal/LambdaLoggingAspectTest.java | 6 +++---
powertools-metrics/pom.xml | 2 +-
.../powertools/metrics/MetricsUtils.java | 2 +-
.../metrics/internal/LambdaMetricsAspect.java | 12 ++++++------
.../powertools/metrics/MetricsLoggerTest.java | 18 +++++++++---------
.../internal/LambdaMetricsAspectTest.java | 16 ++++++++--------
powertools-parameters/pom.xml | 2 +-
.../parameters/AppConfigProvider.java | 2 +-
.../parameters/DynamoDbProvider.java | 2 +-
.../powertools/parameters/SSMProvider.java | 2 +-
.../powertools/parameters/SecretsProvider.java | 2 +-
powertools-tracing/pom.xml | 2 +-
.../powertools/tracing/TracingUtils.java | 2 +-
.../tracing/internal/LambdaTracingAspect.java | 10 +++++-----
.../internal/LambdaTracingAspectTest.java | 2 +-
powertools-validation/pom.xml | 2 +-
.../validation/internal/ValidationAspect.java | 2 +-
60 files changed, 99 insertions(+), 97 deletions(-)
create mode 100644 examples/powertools-examples-core-utilities/.gitignore
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/README.md (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/README.md (67%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/app/events/event.json (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/app/pom.xml (99%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/app/src/main/java/helloworld/App.java (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/app/src/main/java/helloworld/AppStream.java (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/app/src/main/resources/log4j2.xml (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/app/src/test/java/helloworld/AppTest.java (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/infra/cdk.json (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/infra/pom.xml (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/infra/src/main/java/cdk/CdkApp.java (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/infra/src/main/java/cdk/CdkStack.java (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/cdk/infra/src/test/java/cdk/CdkStackTest.java (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/sam/README.md (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/sam/events/event.json (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/sam/pom.xml (98%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/sam/src/main/java/helloworld/App.java (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/sam/src/main/java/helloworld/AppStream.java (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/sam/src/main/resources/log4j2.xml (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/sam/src/test/java/helloworld/AppTest.java (100%)
rename examples/{powertools-examples-core => powertools-examples-core-utilities}/sam/template.yaml (100%)
rename {powertools-core => powertools-common}/pom.xml (92%)
rename {powertools-core/src/main/java/software/amazon/lambda/powertools/core => powertools-common/src/main/java/software/amazon/lambda/powertools/common}/internal/LambdaConstants.java (96%)
rename {powertools-core/src/main/java/software/amazon/lambda/powertools/core => powertools-common/src/main/java/software/amazon/lambda/powertools/common}/internal/LambdaHandlerProcessor.java (96%)
rename {powertools-core/src/main/java/software/amazon/lambda/powertools/core => powertools-common/src/main/java/software/amazon/lambda/powertools/common}/internal/SystemWrapper.java (92%)
rename {powertools-core/src/main/java/software/amazon/lambda/powertools/core => powertools-common/src/main/java/software/amazon/lambda/powertools/common}/internal/UserAgentConfigurator.java (96%)
rename {powertools-core => powertools-common}/src/main/resources-filtered/version.properties (100%)
rename {powertools-core/src/test/java/software/amazon/lambda/powertools/core => powertools-common/src/test/java/software/amazon/lambda/powertools/common}/internal/LambdaHandlerProcessorTest.java (96%)
rename {powertools-core/src/test/java/software/amazon/lambda/powertools/core => powertools-common/src/test/java/software/amazon/lambda/powertools/common}/internal/UserAgentConfiguratorTest.java (86%)
rename {powertools-core => powertools-common}/src/test/resources/test.properties (100%)
rename {powertools-core => powertools-common}/src/test/resources/unreadable.properties (100%)
diff --git a/examples/README.md b/examples/README.md
index 0744c2bb1..79e2133ad 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -5,9 +5,9 @@ Each example can be copied from its subdirectory and used independently of the r
## Examples
-* [powertools-examples-core](powertools-examples-core) - Demonstrates the core logging, tracing, and metrics modules with different build tools
- * [SAM](./powertools-examples-core/sam)
- * [CDK](./powertools-examples-core/cdk)
+* [powertools-examples-core-utilities](powertools-examples-core-utilities) - Demonstrates the core logging, tracing, and metrics modules with different build tools
+ * [SAM](powertools-examples-core-utilities/sam)
+ * [CDK](powertools-examples-core-utilities/cdk)
* [powertools-examples-idempotency](powertools-examples-idempotency) - An idempotent HTTP API
* [powertools-examples-parameters](powertools-examples-parameters) - Uses the parameters module to provide runtime parameters to a function
* [powertools-examples-serialization](powertools-examples-serialization) - Uses the serialization module to serialize and deserialize API Gateway & SQS payloads
@@ -54,7 +54,7 @@ The first command will build the source of your application. The second command
You can find your API Gateway Endpoint URL in the output values displayed after deployment.
-If you're not using SAM, you can look for examples for other tools under [powertools-examples-core](./powertools-examples-core)
+If you're not using SAM, you can look for examples for other tools under [powertools-examples-core-utilities](./powertools-examples-core-utilities)
### External examples
diff --git a/examples/pom.xml b/examples/pom.xml
index f290b3951..b790cb12e 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -29,9 +29,9 @@
- powertools-examples-core/sam
- powertools-examples-core/cdk/app
- powertools-examples-core/cdk/infra
+ powertools-examples-core-utilities/sam
+ powertools-examples-core-utilities/cdk/app
+ powertools-examples-core-utilities/cdk/infra
powertools-examples-idempotency
powertools-examples-parameters
powertools-examples-serialization
diff --git a/examples/powertools-examples-core-utilities/.gitignore b/examples/powertools-examples-core-utilities/.gitignore
new file mode 100644
index 000000000..e69de29bb
diff --git a/examples/powertools-examples-core/README.md b/examples/powertools-examples-core-utilities/README.md
similarity index 100%
rename from examples/powertools-examples-core/README.md
rename to examples/powertools-examples-core-utilities/README.md
diff --git a/examples/powertools-examples-core/cdk/README.md b/examples/powertools-examples-core-utilities/cdk/README.md
similarity index 67%
rename from examples/powertools-examples-core/cdk/README.md
rename to examples/powertools-examples-core-utilities/cdk/README.md
index f15a24168..acd857ed7 100644
--- a/examples/powertools-examples-core/cdk/README.md
+++ b/examples/powertools-examples-core-utilities/cdk/README.md
@@ -6,11 +6,11 @@ For general information on the deployed example itself, you can refer to the par
## Configuration
CDK uses the following project structure:
-- [app](./app) - stores the source code of your application, which is similar between all examples
-- [infra](./infra) - stores the definition of your infrastructure
- - [cdk.json](./infra/cdk.json) - tells the CDK Toolkit how to execute your app
- - [CdkApp](./infra/src/main/java/cdk/CdkApp.java) - bootstraps your stack, taking AWS `account` and `region` as input
- - [CdkStack](./infra/src/main/java/cdk/CdkStack.java) - defines the Lambda function to be deployed as well as API Gateway for it.
+- [app](app) - stores the source code of your application, which is similar between all examples
+- [infra](infra) - stores the definition of your infrastructure
+ - [cdk.json](infra/cdk.json) - tells the CDK Toolkit how to execute your app
+ - [CdkApp](infra/src/main/java/cdk/CdkApp.java) - bootstraps your stack, taking AWS `account` and `region` as input
+ - [CdkStack](infra/src/main/java/cdk/CdkStack.java) - defines the Lambda function to be deployed as well as API Gateway for it.
It is a [Maven](https://maven.apache.org/) based project, so you can open this project with any Maven compatible Java IDE to build and run tests.
diff --git a/examples/powertools-examples-core/cdk/app/events/event.json b/examples/powertools-examples-core-utilities/cdk/app/events/event.json
similarity index 100%
rename from examples/powertools-examples-core/cdk/app/events/event.json
rename to examples/powertools-examples-core-utilities/cdk/app/events/event.json
diff --git a/examples/powertools-examples-core/cdk/app/pom.xml b/examples/powertools-examples-core-utilities/cdk/app/pom.xml
similarity index 99%
rename from examples/powertools-examples-core/cdk/app/pom.xml
rename to examples/powertools-examples-core-utilities/cdk/app/pom.xml
index a1aba1b8d..6895f4117 100644
--- a/examples/powertools-examples-core/cdk/app/pom.xml
+++ b/examples/powertools-examples-core-utilities/cdk/app/pom.xml
@@ -4,7 +4,7 @@
software.amazon.lambda.examples
1.16.1
- powertools-examples-core-cdk
+ powertools-examples-core-utilities-cdk
jar
Powertools for AWS Lambda (Java) library Examples - Core
diff --git a/examples/powertools-examples-core/cdk/app/src/main/java/helloworld/App.java b/examples/powertools-examples-core-utilities/cdk/app/src/main/java/helloworld/App.java
similarity index 100%
rename from examples/powertools-examples-core/cdk/app/src/main/java/helloworld/App.java
rename to examples/powertools-examples-core-utilities/cdk/app/src/main/java/helloworld/App.java
diff --git a/examples/powertools-examples-core/cdk/app/src/main/java/helloworld/AppStream.java b/examples/powertools-examples-core-utilities/cdk/app/src/main/java/helloworld/AppStream.java
similarity index 100%
rename from examples/powertools-examples-core/cdk/app/src/main/java/helloworld/AppStream.java
rename to examples/powertools-examples-core-utilities/cdk/app/src/main/java/helloworld/AppStream.java
diff --git a/examples/powertools-examples-core/cdk/app/src/main/resources/log4j2.xml b/examples/powertools-examples-core-utilities/cdk/app/src/main/resources/log4j2.xml
similarity index 100%
rename from examples/powertools-examples-core/cdk/app/src/main/resources/log4j2.xml
rename to examples/powertools-examples-core-utilities/cdk/app/src/main/resources/log4j2.xml
diff --git a/examples/powertools-examples-core/cdk/app/src/test/java/helloworld/AppTest.java b/examples/powertools-examples-core-utilities/cdk/app/src/test/java/helloworld/AppTest.java
similarity index 100%
rename from examples/powertools-examples-core/cdk/app/src/test/java/helloworld/AppTest.java
rename to examples/powertools-examples-core-utilities/cdk/app/src/test/java/helloworld/AppTest.java
diff --git a/examples/powertools-examples-core/cdk/infra/cdk.json b/examples/powertools-examples-core-utilities/cdk/infra/cdk.json
similarity index 100%
rename from examples/powertools-examples-core/cdk/infra/cdk.json
rename to examples/powertools-examples-core-utilities/cdk/infra/cdk.json
diff --git a/examples/powertools-examples-core/cdk/infra/pom.xml b/examples/powertools-examples-core-utilities/cdk/infra/pom.xml
similarity index 100%
rename from examples/powertools-examples-core/cdk/infra/pom.xml
rename to examples/powertools-examples-core-utilities/cdk/infra/pom.xml
diff --git a/examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkApp.java b/examples/powertools-examples-core-utilities/cdk/infra/src/main/java/cdk/CdkApp.java
similarity index 100%
rename from examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkApp.java
rename to examples/powertools-examples-core-utilities/cdk/infra/src/main/java/cdk/CdkApp.java
diff --git a/examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkStack.java b/examples/powertools-examples-core-utilities/cdk/infra/src/main/java/cdk/CdkStack.java
similarity index 100%
rename from examples/powertools-examples-core/cdk/infra/src/main/java/cdk/CdkStack.java
rename to examples/powertools-examples-core-utilities/cdk/infra/src/main/java/cdk/CdkStack.java
diff --git a/examples/powertools-examples-core/cdk/infra/src/test/java/cdk/CdkStackTest.java b/examples/powertools-examples-core-utilities/cdk/infra/src/test/java/cdk/CdkStackTest.java
similarity index 100%
rename from examples/powertools-examples-core/cdk/infra/src/test/java/cdk/CdkStackTest.java
rename to examples/powertools-examples-core-utilities/cdk/infra/src/test/java/cdk/CdkStackTest.java
diff --git a/examples/powertools-examples-core/sam/README.md b/examples/powertools-examples-core-utilities/sam/README.md
similarity index 100%
rename from examples/powertools-examples-core/sam/README.md
rename to examples/powertools-examples-core-utilities/sam/README.md
diff --git a/examples/powertools-examples-core/sam/events/event.json b/examples/powertools-examples-core-utilities/sam/events/event.json
similarity index 100%
rename from examples/powertools-examples-core/sam/events/event.json
rename to examples/powertools-examples-core-utilities/sam/events/event.json
diff --git a/examples/powertools-examples-core/sam/pom.xml b/examples/powertools-examples-core-utilities/sam/pom.xml
similarity index 98%
rename from examples/powertools-examples-core/sam/pom.xml
rename to examples/powertools-examples-core-utilities/sam/pom.xml
index bb2e01097..204a828c0 100644
--- a/examples/powertools-examples-core/sam/pom.xml
+++ b/examples/powertools-examples-core-utilities/sam/pom.xml
@@ -4,10 +4,10 @@
software.amazon.lambda.examples
2.0.0-SNAPSHOT
- powertools-examples-core
+ powertools-examples-core-utilities
jar
- Powertools for AWS Lambda (Java) library Examples - Core
+ Powertools for AWS Lambda (Java) library Examples - Core Utilities (logging, tracing, metrics)
2.20.0
diff --git a/examples/powertools-examples-core/sam/src/main/java/helloworld/App.java b/examples/powertools-examples-core-utilities/sam/src/main/java/helloworld/App.java
similarity index 100%
rename from examples/powertools-examples-core/sam/src/main/java/helloworld/App.java
rename to examples/powertools-examples-core-utilities/sam/src/main/java/helloworld/App.java
diff --git a/examples/powertools-examples-core/sam/src/main/java/helloworld/AppStream.java b/examples/powertools-examples-core-utilities/sam/src/main/java/helloworld/AppStream.java
similarity index 100%
rename from examples/powertools-examples-core/sam/src/main/java/helloworld/AppStream.java
rename to examples/powertools-examples-core-utilities/sam/src/main/java/helloworld/AppStream.java
diff --git a/examples/powertools-examples-core/sam/src/main/resources/log4j2.xml b/examples/powertools-examples-core-utilities/sam/src/main/resources/log4j2.xml
similarity index 100%
rename from examples/powertools-examples-core/sam/src/main/resources/log4j2.xml
rename to examples/powertools-examples-core-utilities/sam/src/main/resources/log4j2.xml
diff --git a/examples/powertools-examples-core/sam/src/test/java/helloworld/AppTest.java b/examples/powertools-examples-core-utilities/sam/src/test/java/helloworld/AppTest.java
similarity index 100%
rename from examples/powertools-examples-core/sam/src/test/java/helloworld/AppTest.java
rename to examples/powertools-examples-core-utilities/sam/src/test/java/helloworld/AppTest.java
diff --git a/examples/powertools-examples-core/sam/template.yaml b/examples/powertools-examples-core-utilities/sam/template.yaml
similarity index 100%
rename from examples/powertools-examples-core/sam/template.yaml
rename to examples/powertools-examples-core-utilities/sam/template.yaml
diff --git a/pom.xml b/pom.xml
index 24f71c6bd..17fb1a712 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,7 +41,7 @@
- powertools-core
+ powertools-common
powertools-serialization
powertools-logging
powertools-tracing
@@ -105,7 +105,7 @@
software.amazon.lambda
- powertools-core
+ powertools-common
${project.version}
diff --git a/powertools-core/pom.xml b/powertools-common/pom.xml
similarity index 92%
rename from powertools-core/pom.xml
rename to powertools-common/pom.xml
index c244f70fc..721f264e0 100644
--- a/powertools-core/pom.xml
+++ b/powertools-common/pom.xml
@@ -18,7 +18,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- powertools-core
+ powertools-common
jar
@@ -27,10 +27,8 @@
2.0.0-SNAPSHOT
- Powertools for AWS Lambda (Java) library Core
-
- A suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray, structured logging and creating custom metrics asynchronously easier.
-
+ Powertools for AWS Lambda (Java) library Common Internal Utilities
+ Internal utilities shared by the Powertools for AWS Lambda (Java) modules. Do not use directly in your project.
https://aws.amazon.com/lambda/
GitHub Issues
@@ -123,4 +121,4 @@
-
\ No newline at end of file
+
diff --git a/powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/LambdaConstants.java b/powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/LambdaConstants.java
similarity index 96%
rename from powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/LambdaConstants.java
rename to powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/LambdaConstants.java
index d0f94260b..f43cd52a3 100644
--- a/powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/LambdaConstants.java
+++ b/powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/LambdaConstants.java
@@ -12,7 +12,7 @@
*
*/
-package software.amazon.lambda.powertools.core.internal;
+package software.amazon.lambda.powertools.common.internal;
public class LambdaConstants {
public static final String LAMBDA_FUNCTION_NAME_ENV = "AWS_LAMBDA_FUNCTION_NAME";
diff --git a/powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/LambdaHandlerProcessor.java b/powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessor.java
similarity index 96%
rename from powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/LambdaHandlerProcessor.java
rename to powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessor.java
index e9e220e41..1a2b29c2c 100644
--- a/powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/LambdaHandlerProcessor.java
+++ b/powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessor.java
@@ -12,11 +12,11 @@
*
*/
-package software.amazon.lambda.powertools.core.internal;
+package software.amazon.lambda.powertools.common.internal;
import static java.util.Optional.empty;
import static java.util.Optional.of;
-import static software.amazon.lambda.powertools.core.internal.SystemWrapper.getenv;
+import static software.amazon.lambda.powertools.common.internal.SystemWrapper.getenv;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
diff --git a/powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/SystemWrapper.java b/powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/SystemWrapper.java
similarity index 92%
rename from powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/SystemWrapper.java
rename to powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/SystemWrapper.java
index 30f72232f..c537283b5 100644
--- a/powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/SystemWrapper.java
+++ b/powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/SystemWrapper.java
@@ -12,7 +12,7 @@
*
*/
-package software.amazon.lambda.powertools.core.internal;
+package software.amazon.lambda.powertools.common.internal;
public class SystemWrapper {
private SystemWrapper() {
diff --git a/powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/UserAgentConfigurator.java b/powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/UserAgentConfigurator.java
similarity index 96%
rename from powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/UserAgentConfigurator.java
rename to powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/UserAgentConfigurator.java
index 354305d33..585c38c59 100644
--- a/powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/UserAgentConfigurator.java
+++ b/powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/UserAgentConfigurator.java
@@ -12,9 +12,9 @@
*
*/
-package software.amazon.lambda.powertools.core.internal;
+package software.amazon.lambda.powertools.common.internal;
-import static software.amazon.lambda.powertools.core.internal.SystemWrapper.getenv;
+import static software.amazon.lambda.powertools.common.internal.SystemWrapper.getenv;
import java.io.FileInputStream;
import java.io.IOException;
diff --git a/powertools-core/src/main/resources-filtered/version.properties b/powertools-common/src/main/resources-filtered/version.properties
similarity index 100%
rename from powertools-core/src/main/resources-filtered/version.properties
rename to powertools-common/src/main/resources-filtered/version.properties
diff --git a/powertools-core/src/test/java/software/amazon/lambda/powertools/core/internal/LambdaHandlerProcessorTest.java b/powertools-common/src/test/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessorTest.java
similarity index 96%
rename from powertools-core/src/test/java/software/amazon/lambda/powertools/core/internal/LambdaHandlerProcessorTest.java
rename to powertools-common/src/test/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessorTest.java
index dc8f49580..589aab703 100644
--- a/powertools-core/src/test/java/software/amazon/lambda/powertools/core/internal/LambdaHandlerProcessorTest.java
+++ b/powertools-common/src/test/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessorTest.java
@@ -12,14 +12,14 @@
*
*/
-package software.amazon.lambda.powertools.core.internal;
+package software.amazon.lambda.powertools.common.internal;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
-import static software.amazon.lambda.powertools.core.internal.SystemWrapper.getenv;
+import static software.amazon.lambda.powertools.common.internal.SystemWrapper.getenv;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
@@ -31,6 +31,9 @@
import org.aspectj.lang.Signature;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
+import software.amazon.lambda.powertools.common.internal.LambdaConstants;
+import software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor;
+import software.amazon.lambda.powertools.common.internal.SystemWrapper;
class LambdaHandlerProcessorTest {
diff --git a/powertools-core/src/test/java/software/amazon/lambda/powertools/core/internal/UserAgentConfiguratorTest.java b/powertools-common/src/test/java/software/amazon/lambda/powertools/common/internal/UserAgentConfiguratorTest.java
similarity index 86%
rename from powertools-core/src/test/java/software/amazon/lambda/powertools/core/internal/UserAgentConfiguratorTest.java
rename to powertools-common/src/test/java/software/amazon/lambda/powertools/common/internal/UserAgentConfiguratorTest.java
index 2d75bdb3a..9e4d26504 100644
--- a/powertools-core/src/test/java/software/amazon/lambda/powertools/core/internal/UserAgentConfiguratorTest.java
+++ b/powertools-common/src/test/java/software/amazon/lambda/powertools/common/internal/UserAgentConfiguratorTest.java
@@ -12,15 +12,16 @@
*
*/
-package software.amazon.lambda.powertools.core.internal;
+package software.amazon.lambda.powertools.common.internal;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mockStatic;
-import static software.amazon.lambda.powertools.core.internal.SystemWrapper.getenv;
-import static software.amazon.lambda.powertools.core.internal.UserAgentConfigurator.AWS_EXECUTION_ENV;
-import static software.amazon.lambda.powertools.core.internal.UserAgentConfigurator.VERSION_KEY;
-import static software.amazon.lambda.powertools.core.internal.UserAgentConfigurator.VERSION_PROPERTIES_FILENAME;
-import static software.amazon.lambda.powertools.core.internal.UserAgentConfigurator.getVersionFromProperties;
+import static software.amazon.lambda.powertools.common.internal.UserAgentConfigurator.AWS_EXECUTION_ENV;
+import static software.amazon.lambda.powertools.common.internal.UserAgentConfigurator.VERSION_KEY;
+import static software.amazon.lambda.powertools.common.internal.UserAgentConfigurator.VERSION_PROPERTIES_FILENAME;
+import static software.amazon.lambda.powertools.common.internal.UserAgentConfigurator.getVersionFromProperties;
+import static software.amazon.lambda.powertools.common.internal.SystemWrapper.getenv;
+
import java.io.File;
import java.util.Objects;
diff --git a/powertools-core/src/test/resources/test.properties b/powertools-common/src/test/resources/test.properties
similarity index 100%
rename from powertools-core/src/test/resources/test.properties
rename to powertools-common/src/test/resources/test.properties
diff --git a/powertools-core/src/test/resources/unreadable.properties b/powertools-common/src/test/resources/unreadable.properties
similarity index 100%
rename from powertools-core/src/test/resources/unreadable.properties
rename to powertools-common/src/test/resources/unreadable.properties
diff --git a/powertools-idempotency/pom.xml b/powertools-idempotency/pom.xml
index 6b9e46a4a..6a39ae6e0 100644
--- a/powertools-idempotency/pom.xml
+++ b/powertools-idempotency/pom.xml
@@ -57,7 +57,7 @@
software.amazon.lambda
- powertools-core
+ powertools-common
software.amazon.lambda
diff --git a/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/internal/IdempotentAspect.java b/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/internal/IdempotentAspect.java
index 989e88eb7..0b9d729f4 100644
--- a/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/internal/IdempotentAspect.java
+++ b/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/internal/IdempotentAspect.java
@@ -14,7 +14,7 @@
package software.amazon.lambda.powertools.idempotency.internal;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.placedOnRequestHandler;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.placedOnRequestHandler;
import com.amazonaws.services.lambda.runtime.Context;
import com.fasterxml.jackson.databind.JsonNode;
diff --git a/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/BasePersistenceStore.java b/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/BasePersistenceStore.java
index f58b276fd..8ae3598b9 100644
--- a/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/BasePersistenceStore.java
+++ b/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/BasePersistenceStore.java
@@ -14,7 +14,7 @@
package software.amazon.lambda.powertools.idempotency.persistence;
-import static software.amazon.lambda.powertools.core.internal.LambdaConstants.LAMBDA_FUNCTION_NAME_ENV;
+import static software.amazon.lambda.powertools.common.internal.LambdaConstants.LAMBDA_FUNCTION_NAME_ENV;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
diff --git a/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/DynamoDBPersistenceStore.java b/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/DynamoDBPersistenceStore.java
index 82e7b9ead..054f61ef3 100644
--- a/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/DynamoDBPersistenceStore.java
+++ b/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/DynamoDBPersistenceStore.java
@@ -14,8 +14,8 @@
package software.amazon.lambda.powertools.idempotency.persistence;
-import static software.amazon.lambda.powertools.core.internal.LambdaConstants.AWS_REGION_ENV;
-import static software.amazon.lambda.powertools.core.internal.LambdaConstants.LAMBDA_FUNCTION_NAME_ENV;
+import static software.amazon.lambda.powertools.common.internal.LambdaConstants.AWS_REGION_ENV;
+import static software.amazon.lambda.powertools.common.internal.LambdaConstants.LAMBDA_FUNCTION_NAME_ENV;
import static software.amazon.lambda.powertools.idempotency.persistence.DataRecord.Status.INPROGRESS;
import java.time.Instant;
@@ -40,7 +40,7 @@
import software.amazon.awssdk.services.dynamodb.model.PutItemRequest;
import software.amazon.awssdk.services.dynamodb.model.UpdateItemRequest;
import software.amazon.awssdk.utils.StringUtils;
-import software.amazon.lambda.powertools.core.internal.UserAgentConfigurator;
+import software.amazon.lambda.powertools.common.internal.UserAgentConfigurator;
import software.amazon.lambda.powertools.idempotency.Constants;
import software.amazon.lambda.powertools.idempotency.exceptions.IdempotencyItemAlreadyExistsException;
import software.amazon.lambda.powertools.idempotency.exceptions.IdempotencyItemNotFoundException;
diff --git a/powertools-large-messages/pom.xml b/powertools-large-messages/pom.xml
index 19793d616..6cffecb73 100644
--- a/powertools-large-messages/pom.xml
+++ b/powertools-large-messages/pom.xml
@@ -56,7 +56,7 @@
software.amazon.lambda
- powertools-core
+ powertools-common
org.aspectj
diff --git a/powertools-large-messages/src/main/java/software/amazon/lambda/powertools/largemessages/LargeMessageConfig.java b/powertools-large-messages/src/main/java/software/amazon/lambda/powertools/largemessages/LargeMessageConfig.java
index fb8ea9b15..6ad529496 100644
--- a/powertools-large-messages/src/main/java/software/amazon/lambda/powertools/largemessages/LargeMessageConfig.java
+++ b/powertools-large-messages/src/main/java/software/amazon/lambda/powertools/largemessages/LargeMessageConfig.java
@@ -14,7 +14,7 @@
package software.amazon.lambda.powertools.largemessages;
-import static software.amazon.lambda.powertools.core.internal.LambdaConstants.AWS_REGION_ENV;
+import static software.amazon.lambda.powertools.common.internal.LambdaConstants.AWS_REGION_ENV;
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.regions.Region;
diff --git a/powertools-logging/pom.xml b/powertools-logging/pom.xml
index e13a88e57..e16dd0a8b 100644
--- a/powertools-logging/pom.xml
+++ b/powertools-logging/pom.xml
@@ -57,7 +57,7 @@
software.amazon.lambda
- powertools-core
+ powertools-common
com.amazonaws
diff --git a/powertools-logging/src/main/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspect.java b/powertools-logging/src/main/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspect.java
index 4a98735af..0a36723f6 100644
--- a/powertools-logging/src/main/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspect.java
+++ b/powertools-logging/src/main/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspect.java
@@ -17,14 +17,14 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Optional.empty;
import static java.util.Optional.ofNullable;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.coldStartDone;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.extractContext;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.getXrayTraceId;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.isColdStart;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.isHandlerMethod;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.placedOnRequestHandler;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.placedOnStreamHandler;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.serviceName;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.coldStartDone;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.extractContext;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.getXrayTraceId;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.isColdStart;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.isHandlerMethod;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.placedOnRequestHandler;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.placedOnStreamHandler;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.serviceName;
import static software.amazon.lambda.powertools.logging.LoggingUtils.appendKey;
import static software.amazon.lambda.powertools.logging.LoggingUtils.appendKeys;
import static software.amazon.lambda.powertools.logging.LoggingUtils.objectMapper;
diff --git a/powertools-logging/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspectTest.java b/powertools-logging/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspectTest.java
index b78710586..942f79d32 100644
--- a/powertools-logging/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspectTest.java
+++ b/powertools-logging/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspectTest.java
@@ -24,7 +24,7 @@
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.openMocks;
import static org.skyscreamer.jsonassert.JSONAssert.assertEquals;
-import static software.amazon.lambda.powertools.core.internal.SystemWrapper.getenv;
+import static software.amazon.lambda.powertools.common.internal.SystemWrapper.getenv;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
@@ -59,8 +59,8 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.mockito.Mock;
import org.mockito.MockedStatic;
-import software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor;
-import software.amazon.lambda.powertools.core.internal.SystemWrapper;
+import software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor;
+import software.amazon.lambda.powertools.common.internal.SystemWrapper;
import software.amazon.lambda.powertools.logging.handlers.PowerLogToolApiGatewayHttpApiCorrelationId;
import software.amazon.lambda.powertools.logging.handlers.PowerLogToolApiGatewayRestApiCorrelationId;
import software.amazon.lambda.powertools.logging.handlers.PowerLogToolEnabled;
diff --git a/powertools-metrics/pom.xml b/powertools-metrics/pom.xml
index 0681ed000..e67aca7e2 100644
--- a/powertools-metrics/pom.xml
+++ b/powertools-metrics/pom.xml
@@ -58,7 +58,7 @@
software.amazon.lambda
- powertools-core
+ powertools-common
com.amazonaws
diff --git a/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/MetricsUtils.java b/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/MetricsUtils.java
index 09517d46e..8ab2a2f29 100644
--- a/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/MetricsUtils.java
+++ b/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/MetricsUtils.java
@@ -16,7 +16,7 @@
import static java.util.Objects.requireNonNull;
import static java.util.Optional.ofNullable;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.getXrayTraceId;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.getXrayTraceId;
import static software.amazon.lambda.powertools.metrics.internal.LambdaMetricsAspect.REQUEST_ID_PROPERTY;
import static software.amazon.lambda.powertools.metrics.internal.LambdaMetricsAspect.TRACE_ID_PROPERTY;
diff --git a/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/internal/LambdaMetricsAspect.java b/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/internal/LambdaMetricsAspect.java
index 8ca069b01..56a35f67f 100644
--- a/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/internal/LambdaMetricsAspect.java
+++ b/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/internal/LambdaMetricsAspect.java
@@ -16,11 +16,11 @@
import static software.amazon.cloudwatchlogs.emf.model.MetricsLoggerHelper.dimensionsCount;
import static software.amazon.cloudwatchlogs.emf.model.MetricsLoggerHelper.hasNoMetrics;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.coldStartDone;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.extractContext;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.isColdStart;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.isHandlerMethod;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.serviceName;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.coldStartDone;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.extractContext;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.isColdStart;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.isHandlerMethod;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.serviceName;
import static software.amazon.lambda.powertools.metrics.MetricsUtils.hasDefaultDimension;
import static software.amazon.lambda.powertools.metrics.MetricsUtils.metricsLogger;
@@ -34,7 +34,7 @@
import software.amazon.cloudwatchlogs.emf.model.DimensionSet;
import software.amazon.cloudwatchlogs.emf.model.MetricsContext;
import software.amazon.cloudwatchlogs.emf.model.Unit;
-import software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor;
+import software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.metrics.MetricsUtils;
import software.amazon.lambda.powertools.metrics.ValidationException;
diff --git a/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/MetricsLoggerTest.java b/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/MetricsLoggerTest.java
index 7f234a4d6..89cba6bc4 100644
--- a/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/MetricsLoggerTest.java
+++ b/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/MetricsLoggerTest.java
@@ -18,7 +18,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNullPointerException;
import static org.mockito.Mockito.mockStatic;
-import static software.amazon.lambda.powertools.core.internal.SystemWrapper.getenv;
+import static software.amazon.lambda.powertools.common.internal.SystemWrapper.getenv;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -62,8 +62,8 @@ void tearDown() {
@Test
void singleMetricsCaptureUtilityWithDefaultDimension() {
try (MockedStatic mocked = mockStatic(SystemWrapper.class);
- MockedStatic internalWrapper = mockStatic(
- software.amazon.lambda.powertools.core.internal.SystemWrapper.class)) {
+ MockedStatic internalWrapper = mockStatic(
+ software.amazon.lambda.powertools.common.internal.SystemWrapper.class)) {
mocked.when(() -> SystemWrapper.getenv("AWS_EMF_ENVIRONMENT")).thenReturn("Lambda");
internalWrapper.when(() -> getenv("_X_AMZN_TRACE_ID"))
.thenReturn("Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1\"");
@@ -92,8 +92,8 @@ void singleMetricsCaptureUtilityWithDefaultDimension() {
@Test
void singleMetricsCaptureUtility() {
try (MockedStatic mocked = mockStatic(SystemWrapper.class);
- MockedStatic internalWrapper = mockStatic(
- software.amazon.lambda.powertools.core.internal.SystemWrapper.class)) {
+ MockedStatic internalWrapper = mockStatic(
+ software.amazon.lambda.powertools.common.internal.SystemWrapper.class)) {
mocked.when(() -> SystemWrapper.getenv("AWS_EMF_ENVIRONMENT")).thenReturn("Lambda");
internalWrapper.when(() -> getenv("_X_AMZN_TRACE_ID"))
.thenReturn("Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1\"");
@@ -118,8 +118,8 @@ void singleMetricsCaptureUtility() {
@Test
void singleMetricsCaptureUtilityWithDefaultNameSpace() {
try (MockedStatic mocked = mockStatic(SystemWrapper.class);
- MockedStatic internalWrapper = mockStatic(
- software.amazon.lambda.powertools.core.internal.SystemWrapper.class)) {
+ MockedStatic internalWrapper = mockStatic(
+ software.amazon.lambda.powertools.common.internal.SystemWrapper.class)) {
mocked.when(() -> SystemWrapper.getenv("AWS_EMF_ENVIRONMENT")).thenReturn("Lambda");
mocked.when(() -> SystemWrapper.getenv("POWERTOOLS_METRICS_NAMESPACE")).thenReturn("GlobalName");
internalWrapper.when(() -> getenv("_X_AMZN_TRACE_ID"))
@@ -167,8 +167,8 @@ void shouldThrowExceptionWhenDefaultDimensionIsNull() {
private void testLogger(Consumer> methodToTest) {
try (MockedStatic mocked = mockStatic(SystemWrapper.class);
- MockedStatic internalWrapper = mockStatic(
- software.amazon.lambda.powertools.core.internal.SystemWrapper.class)) {
+ MockedStatic internalWrapper = mockStatic(
+ software.amazon.lambda.powertools.common.internal.SystemWrapper.class)) {
mocked.when(() -> SystemWrapper.getenv("AWS_EMF_ENVIRONMENT")).thenReturn("Lambda");
mocked.when(() -> SystemWrapper.getenv("POWERTOOLS_METRICS_NAMESPACE")).thenReturn("GlobalName");
internalWrapper.when(() -> getenv("_X_AMZN_TRACE_ID"))
diff --git a/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/internal/LambdaMetricsAspectTest.java b/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/internal/LambdaMetricsAspectTest.java
index eaddfa75d..d24cd5bb3 100644
--- a/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/internal/LambdaMetricsAspectTest.java
+++ b/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/internal/LambdaMetricsAspectTest.java
@@ -21,7 +21,7 @@
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.openMocks;
-import static software.amazon.lambda.powertools.core.internal.SystemWrapper.getenv;
+import static software.amazon.lambda.powertools.common.internal.SystemWrapper.getenv;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
@@ -40,7 +40,7 @@
import org.mockito.Mock;
import org.mockito.MockedStatic;
import software.amazon.cloudwatchlogs.emf.config.SystemWrapper;
-import software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor;
+import software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor;
import software.amazon.lambda.powertools.metrics.MetricsUtils;
import software.amazon.lambda.powertools.metrics.ValidationException;
import software.amazon.lambda.powertools.metrics.handlers.PowertoolsMetricsColdStartEnabledHandler;
@@ -86,8 +86,8 @@ void tearDown() {
@Test
public void metricsWithoutColdStart() {
try (MockedStatic mocked = mockStatic(SystemWrapper.class);
- MockedStatic internalWrapper = mockStatic(
- software.amazon.lambda.powertools.core.internal.SystemWrapper.class)) {
+ MockedStatic internalWrapper = mockStatic(
+ software.amazon.lambda.powertools.common.internal.SystemWrapper.class)) {
mocked.when(() -> SystemWrapper.getenv("AWS_EMF_ENVIRONMENT")).thenReturn("Lambda");
internalWrapper.when(() -> getenv("_X_AMZN_TRACE_ID"))
@@ -130,8 +130,8 @@ public void metricsWithoutColdStart() {
@Test
public void metricsWithDefaultDimensionSpecified() {
try (MockedStatic mocked = mockStatic(SystemWrapper.class);
- MockedStatic internalWrapper = mockStatic(
- software.amazon.lambda.powertools.core.internal.SystemWrapper.class)) {
+ MockedStatic internalWrapper = mockStatic(
+ software.amazon.lambda.powertools.common.internal.SystemWrapper.class)) {
mocked.when(() -> SystemWrapper.getenv("AWS_EMF_ENVIRONMENT")).thenReturn("Lambda");
internalWrapper.when(() -> getenv("_X_AMZN_TRACE_ID"))
@@ -174,8 +174,8 @@ public void metricsWithDefaultDimensionSpecified() {
@Test
public void metricsWithDefaultNoDimensionSpecified() {
try (MockedStatic mocked = mockStatic(SystemWrapper.class);
- MockedStatic internalWrapper = mockStatic(
- software.amazon.lambda.powertools.core.internal.SystemWrapper.class)) {
+ MockedStatic internalWrapper = mockStatic(
+ software.amazon.lambda.powertools.common.internal.SystemWrapper.class)) {
mocked.when(() -> SystemWrapper.getenv("AWS_EMF_ENVIRONMENT")).thenReturn("Lambda");
internalWrapper.when(() -> getenv("_X_AMZN_TRACE_ID"))
diff --git a/powertools-parameters/pom.xml b/powertools-parameters/pom.xml
index 367996e9c..a703bf36b 100644
--- a/powertools-parameters/pom.xml
+++ b/powertools-parameters/pom.xml
@@ -57,7 +57,7 @@
software.amazon.lambda
- powertools-core
+ powertools-common
software.amazon.awssdk
diff --git a/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/AppConfigProvider.java b/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/AppConfigProvider.java
index f2e4faebb..5a1e575dd 100644
--- a/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/AppConfigProvider.java
+++ b/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/AppConfigProvider.java
@@ -25,7 +25,7 @@
import software.amazon.awssdk.services.appconfigdata.model.GetLatestConfigurationRequest;
import software.amazon.awssdk.services.appconfigdata.model.GetLatestConfigurationResponse;
import software.amazon.awssdk.services.appconfigdata.model.StartConfigurationSessionRequest;
-import software.amazon.lambda.powertools.core.internal.UserAgentConfigurator;
+import software.amazon.lambda.powertools.common.internal.UserAgentConfigurator;
import software.amazon.lambda.powertools.parameters.cache.CacheManager;
import software.amazon.lambda.powertools.parameters.transform.TransformationManager;
diff --git a/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/DynamoDbProvider.java b/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/DynamoDbProvider.java
index 3a8732e18..363f39d7c 100644
--- a/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/DynamoDbProvider.java
+++ b/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/DynamoDbProvider.java
@@ -28,7 +28,7 @@
import software.amazon.awssdk.services.dynamodb.model.GetItemResponse;
import software.amazon.awssdk.services.dynamodb.model.QueryRequest;
import software.amazon.awssdk.services.dynamodb.model.QueryResponse;
-import software.amazon.lambda.powertools.core.internal.UserAgentConfigurator;
+import software.amazon.lambda.powertools.common.internal.UserAgentConfigurator;
import software.amazon.lambda.powertools.parameters.cache.CacheManager;
import software.amazon.lambda.powertools.parameters.exception.DynamoDbProviderSchemaException;
import software.amazon.lambda.powertools.parameters.transform.TransformationManager;
diff --git a/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/SSMProvider.java b/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/SSMProvider.java
index 549cdfbab..10bb70c15 100644
--- a/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/SSMProvider.java
+++ b/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/SSMProvider.java
@@ -27,7 +27,7 @@
import software.amazon.awssdk.services.ssm.model.GetParametersByPathRequest;
import software.amazon.awssdk.services.ssm.model.GetParametersByPathResponse;
import software.amazon.awssdk.utils.StringUtils;
-import software.amazon.lambda.powertools.core.internal.UserAgentConfigurator;
+import software.amazon.lambda.powertools.common.internal.UserAgentConfigurator;
import software.amazon.lambda.powertools.parameters.cache.CacheManager;
import software.amazon.lambda.powertools.parameters.transform.TransformationManager;
import software.amazon.lambda.powertools.parameters.transform.Transformer;
diff --git a/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/SecretsProvider.java b/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/SecretsProvider.java
index 2612f6c7f..b77f501f2 100644
--- a/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/SecretsProvider.java
+++ b/powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/SecretsProvider.java
@@ -26,7 +26,7 @@
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest;
-import software.amazon.lambda.powertools.core.internal.UserAgentConfigurator;
+import software.amazon.lambda.powertools.common.internal.UserAgentConfigurator;
import software.amazon.lambda.powertools.parameters.cache.CacheManager;
import software.amazon.lambda.powertools.parameters.transform.TransformationManager;
import software.amazon.lambda.powertools.parameters.transform.Transformer;
diff --git a/powertools-tracing/pom.xml b/powertools-tracing/pom.xml
index 5f397aa9f..0c9ed8f71 100644
--- a/powertools-tracing/pom.xml
+++ b/powertools-tracing/pom.xml
@@ -58,7 +58,7 @@
software.amazon.lambda
- powertools-core
+ powertools-common
software.amazon.awssdk
diff --git a/powertools-tracing/src/main/java/software/amazon/lambda/powertools/tracing/TracingUtils.java b/powertools-tracing/src/main/java/software/amazon/lambda/powertools/tracing/TracingUtils.java
index 9fb021548..98aaf9c57 100644
--- a/powertools-tracing/src/main/java/software/amazon/lambda/powertools/tracing/TracingUtils.java
+++ b/powertools-tracing/src/main/java/software/amazon/lambda/powertools/tracing/TracingUtils.java
@@ -14,7 +14,7 @@
package software.amazon.lambda.powertools.tracing;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.serviceName;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.serviceName;
import com.amazonaws.xray.AWSXRay;
import com.amazonaws.xray.entities.Entity;
diff --git a/powertools-tracing/src/main/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspect.java b/powertools-tracing/src/main/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspect.java
index 62416fce6..198cb7f34 100644
--- a/powertools-tracing/src/main/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspect.java
+++ b/powertools-tracing/src/main/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspect.java
@@ -14,11 +14,11 @@
package software.amazon.lambda.powertools.tracing.internal;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.coldStartDone;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.isColdStart;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.isHandlerMethod;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.isSamLocal;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.serviceName;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.coldStartDone;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.isColdStart;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.isHandlerMethod;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.isSamLocal;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.serviceName;
import static software.amazon.lambda.powertools.tracing.TracingUtils.objectMapper;
import com.amazonaws.xray.AWSXRay;
diff --git a/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspectTest.java b/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspectTest.java
index d61206886..a676bf683 100644
--- a/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspectTest.java
+++ b/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspectTest.java
@@ -35,7 +35,7 @@
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockedStatic;
-import software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor;
+import software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor;
import software.amazon.lambda.powertools.tracing.handlers.PowerToolDisabled;
import software.amazon.lambda.powertools.tracing.handlers.PowerToolDisabledForStream;
import software.amazon.lambda.powertools.tracing.handlers.PowerTracerToolEnabled;
diff --git a/powertools-validation/pom.xml b/powertools-validation/pom.xml
index 1b939f46f..5868629de 100644
--- a/powertools-validation/pom.xml
+++ b/powertools-validation/pom.xml
@@ -58,7 +58,7 @@
software.amazon.lambda
- powertools-core
+ powertools-common
software.amazon.lambda
diff --git a/powertools-validation/src/main/java/software/amazon/lambda/powertools/validation/internal/ValidationAspect.java b/powertools-validation/src/main/java/software/amazon/lambda/powertools/validation/internal/ValidationAspect.java
index 6055f8d58..0d71104f3 100644
--- a/powertools-validation/src/main/java/software/amazon/lambda/powertools/validation/internal/ValidationAspect.java
+++ b/powertools-validation/src/main/java/software/amazon/lambda/powertools/validation/internal/ValidationAspect.java
@@ -16,7 +16,7 @@
import static com.networknt.schema.SpecVersion.VersionFlag.V201909;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static software.amazon.lambda.powertools.core.internal.LambdaHandlerProcessor.placedOnRequestHandler;
+import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.placedOnRequestHandler;
import static software.amazon.lambda.powertools.utilities.jmespath.Base64Function.decode;
import static software.amazon.lambda.powertools.utilities.jmespath.Base64GZipFunction.decompress;
import static software.amazon.lambda.powertools.validation.ValidationUtils.getJsonSchema;
From b5135c9a3b1557b3aa7e10728fd1fe95ac6605dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Van=20Der=20Linden?=
<117538+jeromevdl@users.noreply.github.com>
Date: Thu, 31 Aug 2023 16:57:43 +0200
Subject: [PATCH 05/16] chore: update v2 (#1409)
---
.github/workflows/auto-merge.yml | 8 +-
.github/workflows/build-docs.yml | 4 +-
.github/workflows/build.yml | 13 +-
.github/workflows/dispatch_analytics.yml | 2 +-
.github/workflows/docs.yml | 4 +-
.github/workflows/publish.yml | 9 +-
.github/workflows/release-drafter.yml | 2 +-
.github/workflows/release-prep.yml | 16 +-
.github/workflows/run-e2e-tests.yml | 6 +-
.github/workflows/secure_workflows.yml | 32 +++
.github/workflows/spotbugs.yml | 6 +-
.gitignore | 2 +
README.md | 18 +-
docs/index.md | 17 +-
examples/pom.xml | 16 +-
examples/powertools-examples-batch/pom.xml | 11 +-
.../pom.xml | 11 +-
.../README.md | 5 +
.../cdk/app/pom.xml | 11 +-
.../cdk/infra/pom.xml | 13 +-
.../gradle/README.md | 38 +++
.../gradle/build.gradle | 35 +++
.../gradle/events/event.json | 62 +++++
.../gradle/gradle/wrapper/.gitignore | 2 +
.../gradle/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 63375 bytes
.../gradle/wrapper/gradle-wrapper.properties | 7 +
.../gradle/gradlew | 248 ++++++++++++++++++
.../gradle/gradlew.bat | 92 +++++++
.../gradle/src/main/java/helloworld/App.java | 107 ++++++++
.../src/main/java/helloworld/AppStream.java | 38 +++
.../src/test/java/helloworld/AppTest.java | 24 ++
.../gradle/template.yaml | 71 +++++
.../sam/pom.xml | 142 +++++-----
.../powertools-examples-idempotency/pom.xml | 202 +++++++-------
.../powertools-examples-parameters/pom.xml | 75 +++---
.../powertools-examples-serialization/pom.xml | 9 +-
.../powertools-examples-validation/pom.xml | 73 +++---
pom.xml | 2 +-
powertools-e2e-tests/pom.xml | 13 +-
39 files changed, 1161 insertions(+), 285 deletions(-)
create mode 100644 .github/workflows/secure_workflows.yml
create mode 100644 examples/powertools-examples-core-utilities/gradle/README.md
create mode 100644 examples/powertools-examples-core-utilities/gradle/build.gradle
create mode 100644 examples/powertools-examples-core-utilities/gradle/events/event.json
create mode 100644 examples/powertools-examples-core-utilities/gradle/gradle/wrapper/.gitignore
create mode 100644 examples/powertools-examples-core-utilities/gradle/gradle/wrapper/gradle-wrapper.jar
create mode 100644 examples/powertools-examples-core-utilities/gradle/gradle/wrapper/gradle-wrapper.properties
create mode 100755 examples/powertools-examples-core-utilities/gradle/gradlew
create mode 100644 examples/powertools-examples-core-utilities/gradle/gradlew.bat
create mode 100644 examples/powertools-examples-core-utilities/gradle/src/main/java/helloworld/App.java
create mode 100644 examples/powertools-examples-core-utilities/gradle/src/main/java/helloworld/AppStream.java
create mode 100644 examples/powertools-examples-core-utilities/gradle/src/test/java/helloworld/AppTest.java
create mode 100644 examples/powertools-examples-core-utilities/gradle/template.yaml
diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml
index 21b5e20e5..5401eedc9 100644
--- a/.github/workflows/auto-merge.yml
+++ b/.github/workflows/auto-merge.yml
@@ -17,12 +17,12 @@ jobs:
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' && github.actor == 'dependabot[bot]'
steps:
- - uses: actions/checkout@v3
- - uses: ahmadnassri/action-workflow-run-wait@v1
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
+ - uses: ahmadnassri/action-workflow-run-wait@2aa3d9e1a12ecaaa9908e368eaf2123bb084323e # v1.4.4
with:
timeout: 300000
- name: 'Download artifact'
- uses: actions/github-script@v3.1.0
+ uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # v3.1.0
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
@@ -43,7 +43,7 @@ jobs:
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- name: Create review
- uses: actions/github-script@v3
+ uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # v3.1.0
with:
script: |
var fs = require('fs');
diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml
index f4a9c4d3f..a4ab6e7de 100644
--- a/.github/workflows/build-docs.yml
+++ b/.github/workflows/build-docs.yml
@@ -22,9 +22,9 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up Python
- uses: actions/setup-python@v4
+ uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 # v4.6.1
with:
python-version: "3.8"
- name: Capture branch and tag
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 9ed871a6c..2ded092ef 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -54,17 +54,22 @@ jobs:
JAVA: ${{ matrix.java }}
AWS_REGION: eu-west-1
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
with:
distribution: 'corretto'
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Build with Maven
run: mvn -B install --file pom.xml
+ - name: Build Gradle Example
+ if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8
+ run: |
+ cd examples/powertools-examples-core-utilities/gradle
+ ./gradlew build
- name: Upload coverage to Codecov
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # 3.1.1
+ uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
if: ${{ matrix.java == '11' }} # publish results once
with:
files: ./powertools-cloudformation/target/site/jacoco/jacoco.xml,./powertools-core/target/site/jacoco/jacoco.xml,./powertools-idempotency/target/site/jacoco/jacoco.xml,./powertools-logging/target/site/jacoco/jacoco.xml,./powertools-metrics/target/site/jacoco/jacoco.xml,./powertools-parameters/target/site/jacoco/jacoco.xml,./powertools-serialization/target/site/jacoco/jacoco.xml,./powertools-sqs/target/site/jacoco/jacoco.xml,./powertools-tracing/target/site/jacoco/jacoco.xml,./powertools-validation/target/site/jacoco/jacoco.xml
@@ -78,7 +83,7 @@ jobs:
mkdir -p ./pr
echo ${{ github.event.number }}
echo ${{ github.event.number }} > ./pr/NR
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
name: Upload artifact
with:
name: pr
diff --git a/.github/workflows/dispatch_analytics.yml b/.github/workflows/dispatch_analytics.yml
index 49a276f6f..c93cb5b36 100644
--- a/.github/workflows/dispatch_analytics.yml
+++ b/.github/workflows/dispatch_analytics.yml
@@ -29,7 +29,7 @@ jobs:
environment: analytics
steps:
- name: Configure AWS credentials
- uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef
+ uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
aws-region: eu-central-1
role-to-assume: ${{ secrets.AWS_ANALYTICS_ROLE_ARN }}
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 9c09e294d..5e37c5f45 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -16,9 +16,9 @@ jobs:
runs-on: ubuntu-latest
environment: Docs
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up Python
- uses: actions/setup-python@v4
+ uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 # v4.6.1
with:
python-version: "3.8"
- name: Capture branch and tag
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 2068c09c5..03f04e0f4 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -8,15 +8,16 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up Maven Central Repository
- uses: actions/setup-java@v2
+ uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
with:
- distribution: 'zulu'
+ distribution: 'corretto'
java-version: 8
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
+ # TODO: use environments https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }} # Value of the GPG private key to import
gpg-passphrase: GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Set release notes tag
@@ -30,7 +31,7 @@ jobs:
MAVEN_PASSWORD: ${{ secrets.OSSRH_JIRA_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Close issues related to this release
- uses: actions/github-script@v5
+ uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
script: |
const post_release = require('.github/workflows/post_release.js')
diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml
index 5b27fd671..72bd5c24f 100644
--- a/.github/workflows/release-drafter.yml
+++ b/.github/workflows/release-drafter.yml
@@ -10,6 +10,6 @@ jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- - uses: release-drafter/release-drafter@v5
+ - uses: release-drafter/release-drafter@569eb7ee3a85817ab916c8f8ff03a5bd96c9c83e # v5.23.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/release-prep.yml b/.github/workflows/release-prep.yml
index 345bd2a10..f7a3c74c0 100644
--- a/.github/workflows/release-prep.yml
+++ b/.github/workflows/release-prep.yml
@@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
@@ -18,42 +18,42 @@ jobs:
run: |
echo "CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: Find and Replace ${{ env.CURRENT_VERSION }} with ${{ github.event.inputs.targetRelease }} in mkdocs.yml
- uses: jacobtomlinson/gha-find-replace@v2
+ uses: jacobtomlinson/gha-find-replace@f485fdc3f67a6d87ae6e3d11e41f648c26d7aee3 # v2.0.0
with:
find: 'version: ${{ env.CURRENT_VERSION }}'
replace: 'version: ${{ github.event.inputs.targetRelease }}'
regex: false
include: "mkdocs.yml"
- name: Find and Replace ${{ env.CURRENT_VERSION }} with ${{ github.event.inputs.targetRelease }} in main pom.xml
- uses: jacobtomlinson/gha-find-replace@v2
+ uses: jacobtomlinson/gha-find-replace@f485fdc3f67a6d87ae6e3d11e41f648c26d7aee3 # v2.0.0
with:
find: ${{ env.CURRENT_VERSION }}
replace: ${{ github.event.inputs.targetRelease }}
regex: false
include: "pom.xml"
- name: Find and Replace ${{ env.CURRENT_VERSION }} with ${{ github.event.inputs.targetRelease }} in modules pom.xml
- uses: jacobtomlinson/gha-find-replace@v2
+ uses: jacobtomlinson/gha-find-replace@f485fdc3f67a6d87ae6e3d11e41f648c26d7aee3 # v2.0.0
with:
find: ${{ env.CURRENT_VERSION }}
replace: ${{ github.event.inputs.targetRelease }}
regex: false
include: "**/*pom.xml"
- name: Find and Replace ${{ env.CURRENT_VERSION }} with ${{ github.event.inputs.targetRelease }} in build.gradle
- uses: jacobtomlinson/gha-find-replace@v2
+ uses: jacobtomlinson/gha-find-replace@f485fdc3f67a6d87ae6e3d11e41f648c26d7aee3 # v2.0.0
with:
find: ${{ env.CURRENT_VERSION }}
replace: ${{ github.event.inputs.targetRelease }}
regex: false
include: "**/*build.gradle"
- name: Find and Replace ${{ env.CURRENT_VERSION }} with ${{ github.event.inputs.targetRelease }} in README.md
- uses: jacobtomlinson/gha-find-replace@v2
+ uses: jacobtomlinson/gha-find-replace@f485fdc3f67a6d87ae6e3d11e41f648c26d7aee3 # v2.0.0
with:
find: ${{ env.CURRENT_VERSION }}
replace: ${{ github.event.inputs.targetRelease }}
regex: false
include: "README.md"
- name: Create changelog placeholder for ${{ github.event.inputs.targetRelease }}
- uses: jacobtomlinson/gha-find-replace@v2
+ uses: jacobtomlinson/gha-find-replace@f485fdc3f67a6d87ae6e3d11e41f648c26d7aee3 # v2.0.0
with:
find: '## [Unreleased]'
replace: |
@@ -66,7 +66,7 @@ jobs:
regex: false
include: CHANGELOG.md
- name: Create Release Pull Request
- uses: peter-evans/create-pull-request@v3
+ uses: peter-evans/create-pull-request@18f7dc018cc2cd597073088f7c7591b9d1c02672 # v3.14.0
with:
commit-message: chore:prep release ${{ github.event.inputs.targetRelease }}
token: ${{ secrets.RELEASE }}
diff --git a/.github/workflows/run-e2e-tests.yml b/.github/workflows/run-e2e-tests.yml
index 36c9dd97a..c4a8c6fb2 100644
--- a/.github/workflows/run-e2e-tests.yml
+++ b/.github/workflows/run-e2e-tests.yml
@@ -41,15 +41,15 @@ jobs:
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
contents: read
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
with:
distribution: 'corretto'
java-version: ${{ matrix.java }}
cache: maven
- name: Setup AWS credentials
- uses: aws-actions/configure-aws-credentials@v1.6.1
+ uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
diff --git a/.github/workflows/secure_workflows.yml b/.github/workflows/secure_workflows.yml
new file mode 100644
index 000000000..1430e91d6
--- /dev/null
+++ b/.github/workflows/secure_workflows.yml
@@ -0,0 +1,32 @@
+name: Lockdown untrusted workflows
+
+# PROCESS
+#
+# 1. Scans for any external GitHub Action being used without version pinning (@ vs @v3)
+# 2. Scans for insecure practices for inline bash scripts (shellcheck)
+# 3. Fail CI and prevent PRs to be merged if any malpractice is found
+
+# USAGE
+#
+# Always triggered on new PR, PR changes and PR merge.
+
+
+on:
+ push:
+ paths:
+ - ".github/workflows/**"
+ pull_request:
+ paths:
+ - ".github/workflows/**"
+
+jobs:
+ enforce_pinned_workflows:
+ name: Harden Security
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read # checkout code and subsequently GitHub action workflows
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
+ - name: Ensure 3rd party workflows have SHA pinned
+ uses: zgosalvez/github-actions-ensure-sha-pinned-actions@555a30da2656b4a7cf47b107800bef097723363e # v2.1.3
diff --git a/.github/workflows/spotbugs.yml b/.github/workflows/spotbugs.yml
index 0b07bcd81..d314107fa 100644
--- a/.github/workflows/spotbugs.yml
+++ b/.github/workflows/spotbugs.yml
@@ -23,11 +23,11 @@ jobs:
codecheck:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup java JDK 1.8
- uses: actions/setup-java@v2
+ uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
with:
- distribution: 'zulu'
+ distribution: 'corretto'
java-version: 8
# https://github.com/jwgmeligmeyling/spotbugs-github-action/issues/6
# https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/
diff --git a/.gitignore b/.gitignore
index 04e85211d..b404d2cb2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -107,3 +107,5 @@ example/HelloWorldFunction/.gradle
example/HelloWorldFunction/build
/example/.gradle/
/example/.java-version
+.gradle
+build/
\ No newline at end of file
diff --git a/README.md b/README.md
index 76f8b2e4b..ed3f86e77 100644
--- a/README.md
+++ b/README.md
@@ -132,11 +132,18 @@ Next, configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lam
Gradle - Java 11+
```groovy
+
plugins {
id 'java'
- id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0'
+ id 'io.freefair.aspectj.post-compile-weaving' version '8.2.2'
}
+ // the freefair aspect plugins targets gradle 8.2.1
+ // https://docs.freefair.io/gradle-plugins/8.2.2/reference/
+ wrapper {
+ gradleVersion = "8.2.1"
+ }
+
repositories {
mavenCentral()
}
@@ -145,6 +152,7 @@ Next, configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lam
aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}'
aspect 'software.amazon.lambda:powertools-tracing:{{ powertools.version }}'
aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}'
+ implementation "org.aspectj:aspectjrt:1.9.8.RC3"
}
sourceCompatibility = 11
@@ -161,6 +169,12 @@ Next, configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lam
id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3'
}
+ // the freefair aspect plugins targets gradle 7.6.1
+ // https://docs.freefair.io/gradle-plugins/6.6.3/reference/
+ wrapper {
+ gradleVersion = "7.6.1"
+ }
+
repositories {
mavenCentral()
}
@@ -178,7 +192,7 @@ Next, configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lam
## Examples
-See the **[examples](examples)** directory for example projects showcasing usage of different utilities.
+See the latest release of the **[examples](https://github.com/aws-powertools/powertools-lambda-java/tree/v1.17.0/examples)** for example projects showcasing usage of different utilities.
Have a demo project to contribute which showcase usage of different utilities from powertools? We are happy to accept it [here](CONTRIBUTING.md#security-issue-notifications).
diff --git a/docs/index.md b/docs/index.md
index d3e487174..6af4c5e8d 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -211,10 +211,17 @@ Depending on your version of Java (either Java 1.8 or 11+), the configuration sl
=== "Gradle Java 11+"
```groovy
+
plugins {
id 'java'
- id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0'
+ id 'io.freefair.aspectj.post-compile-weaving' version '8.2.2'
}
+
+ // the freefair aspect plugins targets gradle 8.2.1
+ // https://docs.freefair.io/gradle-plugins/8.2.2/reference/
+ wrapper {
+ gradleVersion = "8.2.1"
+ }
repositories {
mavenCentral()
@@ -233,10 +240,18 @@ Depending on your version of Java (either Java 1.8 or 11+), the configuration sl
=== "Gradle Java 1.8"
```groovy
+
plugins {
id 'java'
id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3'
}
+
+ // the freefair aspect plugins targets gradle 7.6.1
+ // https://docs.freefair.io/gradle-plugins/6.6.3/reference/
+ wrapper {
+ gradleVersion = "7.6.1"
+ }
+
repositories {
mavenCentral()
diff --git a/examples/pom.xml b/examples/pom.xml
index b790cb12e..da6e272de 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -40,9 +40,17 @@
powertools-examples-cloudformation
-
-
- true
-
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
+
+
\ No newline at end of file
diff --git a/examples/powertools-examples-batch/pom.xml b/examples/powertools-examples-batch/pom.xml
index 9efa7fa63..cfc035238 100644
--- a/examples/powertools-examples-batch/pom.xml
+++ b/examples/powertools-examples-batch/pom.xml
@@ -14,8 +14,7 @@
2.20.0
1.8
1.8
- true
- 2.20.128
+ 2.20.133
@@ -120,6 +119,14 @@
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
diff --git a/examples/powertools-examples-cloudformation/pom.xml b/examples/powertools-examples-cloudformation/pom.xml
index 50cfff85d..85e330742 100644
--- a/examples/powertools-examples-cloudformation/pom.xml
+++ b/examples/powertools-examples-cloudformation/pom.xml
@@ -13,10 +13,9 @@
2.20.0
1.8
1.8
- true
1.2.3
3.11.2
- 2.20.130
+ 2.20.136
@@ -145,6 +144,14 @@
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
diff --git a/examples/powertools-examples-core-utilities/README.md b/examples/powertools-examples-core-utilities/README.md
index f11982477..6960bb1f5 100644
--- a/examples/powertools-examples-core-utilities/README.md
+++ b/examples/powertools-examples-core-utilities/README.md
@@ -6,9 +6,14 @@ This project demonstrates the Lambda for Powertools Java module - including
[metrics](https://docs.powertools.aws.dev/lambda/java/core/metrics/).
We provide examples for the following infrastructure-as-code tools:
+
* [AWS SAM](sam/)
* [AWS CDK](cdk/)
+We also provide an example showing the integration of SAM, Powertools, and Gradle:
+
+* [AWS SAM with a Gradle build](../powertools-examples-core-utilities/gradle/)
+
For each of the tools, the example application is the same, and consists of the following files:
- [App.java](sam/src/main/java/helloworld/App.java) - Code for the application's Lambda function.
diff --git a/examples/powertools-examples-core-utilities/cdk/app/pom.xml b/examples/powertools-examples-core-utilities/cdk/app/pom.xml
index 6895f4117..76e02ea48 100644
--- a/examples/powertools-examples-core-utilities/cdk/app/pom.xml
+++ b/examples/powertools-examples-core-utilities/cdk/app/pom.xml
@@ -3,7 +3,7 @@
4.0.0
software.amazon.lambda.examples
- 1.16.1
+ 1.17.0
powertools-examples-core-utilities-cdk
jar
@@ -13,7 +13,6 @@
2.20.0
1.8
1.8
- true
@@ -120,6 +119,14 @@
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
diff --git a/examples/powertools-examples-core-utilities/cdk/infra/pom.xml b/examples/powertools-examples-core-utilities/cdk/infra/pom.xml
index d81118cde..d67077fae 100644
--- a/examples/powertools-examples-core-utilities/cdk/infra/pom.xml
+++ b/examples/powertools-examples-core-utilities/cdk/infra/pom.xml
@@ -4,13 +4,12 @@
4.0.0
software.amazon.lambda.examples
cdk
- 1.18.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
UTF-8
- 2.91.0
+ 2.93.0
[10.0.0,11.0.0)
5.10.0
- true
@@ -31,6 +30,14 @@
cdk.CdkApp
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
diff --git a/examples/powertools-examples-core-utilities/gradle/README.md b/examples/powertools-examples-core-utilities/gradle/README.md
new file mode 100644
index 000000000..cd6107151
--- /dev/null
+++ b/examples/powertools-examples-core-utilities/gradle/README.md
@@ -0,0 +1,38 @@
+# Powertools for AWS Lambda (Java) - Core Utilities Example with Gradle
+
+This project demonstrates the Lambda for Powertools Java module deployed using [Serverless Application Model](https://aws.amazon.com/serverless/sam/) with
+[Gradle](https://gradle.org/) running the build. This example is configured for Java 1.8 only; in order to use a newer version, check out the Gradle
+configuration guide [in the main project README](../../../README.md).
+
+You can also use `sam init` to create a new Gradle-powered Powertools application - choose to use the **AWS Quick Start Templates**,
+and then **Hello World Example with Powertools for AWS Lambda**, **Java 17** runtime, and finally **gradle**.
+
+
+For general information on the deployed example itself, you can refer to the parent [README](../../powertools-examples-core/README.md)
+
+## Configuration
+SAM uses [template.yaml](template.yaml) to define the application's AWS resources.
+This file defines the Lambda function to be deployed as well as API Gateway for it.
+
+The build of the project is managed by Gradle, and configured in [build.gradle](build.gradle).
+
+## Deploy the sample application
+To get started, you can use the Gradle wrapper to bootstrap Gradle and run the build:
+
+```bash
+./gradlew build
+```
+
+Once this is done to deploy the example, check out the instructions for getting started with SAM in
+[the examples directory](../../README.md)
+
+## Additional notes
+
+You can watch the trace information or log information using the SAM CLI:
+```bash
+# Tail the logs
+sam logs --tail $MY_STACK
+
+# Tail the traces
+sam traces --tail
+```
\ No newline at end of file
diff --git a/examples/powertools-examples-core-utilities/gradle/build.gradle b/examples/powertools-examples-core-utilities/gradle/build.gradle
new file mode 100644
index 000000000..e7367c246
--- /dev/null
+++ b/examples/powertools-examples-core-utilities/gradle/build.gradle
@@ -0,0 +1,35 @@
+
+plugins {
+ id 'java'
+ id "io.freefair.aspectj.post-compile-weaving" version "6.6.3"
+}
+
+wrapper {
+ gradleVersion = "7.6.1"
+}
+
+compileJava {
+ sourceCompatibility = "1.8"
+ targetCompatibility = "1.8"
+
+ ajc {
+ enabled = true
+ }
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ implementation 'com.amazonaws:aws-lambda-java-core:1.2.2'
+ implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.2'
+ implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.2.2'
+ implementation 'com.amazonaws:aws-lambda-java-events:3.11.0'
+ implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.2'
+ aspect 'software.amazon.lambda:powertools-tracing:1.17.0'
+ aspect 'software.amazon.lambda:powertools-logging:1.17.0'
+ aspect 'software.amazon.lambda:powertools-metrics:1.17.0'
+ testImplementation 'junit:junit:4.13.2'
+}
+
diff --git a/examples/powertools-examples-core-utilities/gradle/events/event.json b/examples/powertools-examples-core-utilities/gradle/events/event.json
new file mode 100644
index 000000000..070ad8e01
--- /dev/null
+++ b/examples/powertools-examples-core-utilities/gradle/events/event.json
@@ -0,0 +1,62 @@
+{
+ "body": "{\"message\": \"hello world\"}",
+ "resource": "/{proxy+}",
+ "path": "/path/to/resource",
+ "httpMethod": "POST",
+ "isBase64Encoded": false,
+ "queryStringParameters": {
+ "foo": "bar"
+ },
+ "pathParameters": {
+ "proxy": "/path/to/resource"
+ },
+ "stageVariables": {
+ "baz": "qux"
+ },
+ "headers": {
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
+ "Accept-Encoding": "gzip, deflate, sdch",
+ "Accept-Language": "en-US,en;q=0.8",
+ "Cache-Control": "max-age=0",
+ "CloudFront-Forwarded-Proto": "https",
+ "CloudFront-Is-Desktop-Viewer": "true",
+ "CloudFront-Is-Mobile-Viewer": "false",
+ "CloudFront-Is-SmartTV-Viewer": "false",
+ "CloudFront-Is-Tablet-Viewer": "false",
+ "CloudFront-Viewer-Country": "US",
+ "Host": "1234567890.execute-api.us-east-1.amazonaws.com",
+ "Upgrade-Insecure-Requests": "1",
+ "User-Agent": "Custom User Agent String",
+ "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)",
+ "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==",
+ "X-Forwarded-For": "127.0.0.1, 127.0.0.2",
+ "X-Forwarded-Port": "443",
+ "X-Forwarded-Proto": "https"
+ },
+ "requestContext": {
+ "accountId": "123456789012",
+ "resourceId": "123456",
+ "stage": "prod",
+ "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
+ "requestTime": "09/Apr/2015:12:34:56 +0000",
+ "requestTimeEpoch": 1428582896000,
+ "identity": {
+ "cognitoIdentityPoolId": null,
+ "accountId": null,
+ "cognitoIdentityId": null,
+ "caller": null,
+ "accessKey": null,
+ "sourceIp": "127.0.0.1",
+ "cognitoAuthenticationType": null,
+ "cognitoAuthenticationProvider": null,
+ "userArn": null,
+ "userAgent": "Custom User Agent String",
+ "user": null
+ },
+ "path": "/prod/path/to/resource",
+ "resourcePath": "/{proxy+}",
+ "httpMethod": "POST",
+ "apiId": "1234567890",
+ "protocol": "HTTP/1.1"
+ }
+}
diff --git a/examples/powertools-examples-core-utilities/gradle/gradle/wrapper/.gitignore b/examples/powertools-examples-core-utilities/gradle/gradle/wrapper/.gitignore
new file mode 100644
index 000000000..59c09e205
--- /dev/null
+++ b/examples/powertools-examples-core-utilities/gradle/gradle/wrapper/.gitignore
@@ -0,0 +1,2 @@
+!gradle-wrapper.jar
+
diff --git a/examples/powertools-examples-core-utilities/gradle/gradle/wrapper/gradle-wrapper.jar b/examples/powertools-examples-core-utilities/gradle/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000000000000000000000000000000000..033e24c4cdf41af1ab109bc7f253b2b887023340
GIT binary patch
literal 63375
zcmb5VV{~QRw)Y#`wrv{~+qP{x72B%VwzFc}c2cp;N~)5ZbDrJayPv(!dGEd-##*zr
z)#n-$y^sH|_dchh3@8{H5D*j;5D<{i*8l5IFJ|DjL!e)upfGNX(kojugZ3I`oH1PvW`wFW_ske0j@lB9bX
zO;2)`y+|!@X(fZ1<2n!Qx*)_^Ai@Cv-dF&(vnudG?0CsddG_&Wtae(n|K59ew)6St
z#dj7_(Cfwzh$H$5M!$UDd8=4>IQsD3xV=lXUq($;(h*$0^yd+b{qq63f0r_de#!o_
zXDngc>zy`uor)4A^2M#U*DC~i+dc<)Tb1Tv&~Ev@oM)5iJ4Sn#8iRw16XXuV50BS7
zdBL5Mefch(&^{luE{*5qtCZk$oFr3RH=H!c3wGR=HJ(yKc_re_X9pD`
zJ;uxPzUfVpgU>DSq?J;I@a+10l0ONXPcDkiYcihREt5~T5Gb}sT0+6Q;AWHl`S5dV>lv%-p9l#xNNy7ZCr%cyqHY%TZ8Q4
zbpov1*$#grNG#1vgfFOLJCaNG@K|2!W&HSh@3@Y%T?3YI75bJp!VP*$*!<
z;(ffNS_;@RJ`=c7yX04!u3JP*<8jeqLHVJu#WV&v6wA!OYJS4h<_}^QI&97-;=ojW
zQ-1t)7wnxG*5I%U4)9$wlv5Fr;cIizft@&N+32O%B{R1POm$oap@&f|
zh+5J{>U6ftv|vAeKGc|zC=kO(+l7_cLpV}-D#oUltScw})N>~JOZLU_0{Ka2e1evz
z{^a*ZrLr+JUj;)K&u2CoCAXLC2=fVScI(m_p~0FmF>>&3DHziouln?;sxW`NB}cSX
z8?IsJB)Z=aYRz!X=yJn$kyOWK%rCYf-YarNqKzmWu$ZvkP12b4qH
zhS9Q>j<}(*frr?z<%9hl*i^#@*O2q(Z^CN)c2c
z>1B~D;@YpG?G!Yk+*yn4vM4sO-_!&m6+`k|3zd;8DJnxsBYtI;W3We+FN@|tQ5EW=
z!VU>jtim0Mw#iaT8t_<+qKIEB-WwE04lBd%Letbml9N!?SLrEG$nmn7&W(W`VB@5S
zaY=sEw2}i@F_1P4OtEw?xj4@D6>_e=m=797#hg}f*l^`AB|Y0#
z9=)o|%TZFCY$SzgSjS|8AI-%J4x}J)!IMxY3_KYze`_I=c1nmrk@E8c9?MVRu)7+Ue79|)rBX7tVB7U|w4*h(;Gi3D9le49B38`wuv
zp7{4X^p+K4*$@gU(Tq3K1a#3SmYhvI42)GzG4f|u
zwQFT1n_=n|jpi=70-yE9LA+d*T8u
z`=VmmXJ_f6WmZveZPct$Cgu^~gFiyL>Lnpj*6ee>*0pz=t$IJ}+rE
zsf@>jlcG%Wx;Cp5x)YSVvB1$yyY1l&o
zvwX=D7k)Dn;ciX?Z)Pn8$flC8#m`nB&(8?RSdBvr?>T9?E$U3uIX7T?$v4dWCa46
z+&`ot8ZTEgp7G+c52oHJ8nw5}a^dwb_l%MOh(ebVj9>_koQP^$2B~eUfSbw9RY$_<
z&DDWf2LW;b0ZDOaZ&2^i^g+5uTd;GwO(-bbo|P^;CNL-%?9mRmxEw~5&z=X^Rvbo^WJW=n_%*7974RY}JhFv46>
zd}`2|qkd;89l}R;i~9T)V-Q%K)O=yfVKNM4Gbacc7AOd>#^&W&)Xx!Uy5!BHnp9kh
z`a(7MO6+Ren#>R^D0K)1sE{Bv>}s6Rb9MT14u!(NpZOe-?4V=>qZ>}uS)!y~;jEUK
z&!U7Fj&{WdgU#L0%bM}SYXRtM5z!6M+kgaMKt%3FkjWYh=#QUpt$XX1!*XkpSq-pl
zhMe{muh#knk{9_V3%qdDcWDv}v)m4t9
zQhv{;}
zc{}#V^N3H>9mFM8`i`0p+fN@GqX+kl|M94$BK3J-X`Hyj8r!#x6Vt(PXjn?N)qedP
z=o1T^#?1^a{;bZ&x`U{f?}TMo8ToN
zkHj5v|}r}wDEi7I@)Gj+S1aE-GdnLN+$hw!=DzglMaj#{qjXi_dwpr|HL(gcCXwGLEmi|{4&4#OZ4ChceA
zKVd4K!D>_N=_X;{poT~4Q+!Le+ZV>=H7v1*l%w`|`Dx8{)McN@NDlQyln&N3@bFpV
z_1w~O4EH3fF@IzJ9kDk@7@QctFq8FbkbaH7K$iX=bV~o#gfh?2JD6lZf(XP>~DACF)fGFt)X%-h1yY~MJU{nA5
ze2zxWMs{YdX3q5XU*9hOH0!_S24DOBA5usB+Ws$6{|AMe*joJ?RxfV}*7AKN9V*~J
zK+OMcE@bTD>TG1*yc?*qGqjBN8mgg@h1cJLDv)0!WRPIkC`
zZrWXrceVw;fB%3`6kq=a!pq|hFIsQ%ZSlo~)D
z|64!aCnw-?>}AG|*iOl44KVf8@|joXi&|)1rB;EQWgm+iHfVbgllP$f!$Wf42%NO5b(j9Bw6L
z;0dpUUK$5GX4QbMlTmLM_jJt!ur`_0~$b#BB7FL*%XFf<b__1o)Ao3rlobbN8-(T!1d-bR8D3S0@d
zLI!*GMb5s~Q<&sjd}lBb8Nr0>PqE6_!3!2d(KAWFxa{hm`@u|a(%#i(#f8{BP2wbs
zt+N_slWF4IF_O|{w`c~)Xvh&R{Au~CFmW#0+}MBd2~X}t9lz6*E7uAD`@EBDe$>7W
zzPUkJx<`f$0VA$=>R57^(K^h86>09?>_@M(R4q($!Ck6GG@pnu-x*exAx1jOv|>KH
zjNfG5pwm`E-=ydcb+3BJwuU;V&OS=6yM^4Jq{%AVqnTTLwV`AorIDD}T&jWr8pB&j28fVtk_y*JRP^t@l*($UZ
z6(B^-PBNZ+z!p?+e8@$&jCv^EWLb$WO=}Scr$6SM*&~B95El~;W_0(Bvoha|uQ1T<
zO$%_oLAwf1bW*rKWmlD+@CP&$ObiDy=nh1b2ejz%LO9937N{LDe7gle4i!{}I$;&Y
zkexJ9Ybr+lrCmKWg&}p=`2&Gf10orS?4$VrzWidT=*6{KzOGMo?KI0>GL0{iFWc;C
z+LPq%VH5g}6V@-tg2m{C!-$fapJ9y}c$U}aUmS{9#0CM*8pC|sfer!)nG7Ji>mfRh
z+~6CxNb>6eWKMHBz-w2{mLLwdA7dA-qfTu^A2yG1+9s5k
zcF=le_UPYG&q!t5Zd_*E_P3Cf5T6821bO`daa`;DODm8Ih8k89=RN;-asHIigj`n=ux>*f!OC5#;X5i;Q
z+V!GUy0|&Y_*8k_QRUA8$lHP;GJ3UUD08P|ALknng|YY13)}!!HW@0z$q+kCH%xet
zlWf@BXQ=b=4}QO5eNnN~CzWBbHGUivG=`&eWK}beuV*;?zt=P#pM*eTuy3
zP}c#}AXJ0OIaqXji78l;YrP4sQe#^pOqwZUiiN6^0RCd#D271XCbEKpk`HI0IsN^s
zES7YtU#7=8gTn#lkrc~6)R9u&SX6*Jk4GFX7){E)WE?pT8a-%6P+zS6o&A#ml{$WX
zABFz#i7`DDlo{34)oo?bOa4Z_lNH>n;f0nbt$JfAl~;4QY@}NH!X|A$KgMmEsd^&Y
zt;pi=>AID7ROQfr;MsMtClr5b0)xo|fwhc=qk33wQ|}$@?{}qXcmECh>#kUQ-If0$
zseb{Wf4VFGLNc*Rax#P8ko*=`MwaR-DQ8L8V8r=2N{Gaips2_^cS|oC$+yScRo*uF
zUO|5=?Q?{p$inDpx*t#Xyo6=s?bbN}y>NNVxj9NZCdtwRI70jxvm3!5R7yiWjREEd
zDUjrsZhS|P&|Ng5r+f^kA6BNN#|Se}_GF>P6sy^e8kBrgMv3#vk%m}9PCwUWJg-AD
zFnZ=}lbi*mN-AOm
zCs)r=*YQAA!`e#1N>aHF=bb*z*hXH#Wl$z^o}x##ZrUc=kh%OHWhp=7;?8%Xj||@V?1c
ziWoaC$^&04;A|T)!Zd9sUzE&$ODyJaBpvqsw19Uiuq{i#VK1!htkdRWBnb
z`{rat=nHArT%^R>u#CjjCkw-7%g53|&7z-;X+ewb?OLWiV|#nuc8mp*LuGSi3IP<<*Wyo9GKV7l0Noa4Jr0g3p_$
z*R9{qn=?IXC#WU>48-k5V2Oc_>P;4_)J@bo1|pf=%Rcbgk=5m)CJZ`caHBTm3%!Z9
z_?7LHr_BXbKKr=JD!%?KhwdYSdu8XxPoA{n8^%_lh5cjRHuCY9Zlpz8g+$f@bw@0V
z+6DRMT9c|>1^3D|$Vzc(C?M~iZurGH2pXPT%F!JSaAMdO%!5o0uc&iqHx?ImcX6fI
zCApkzc~OOnfzAd_+-DcMp&AOQxE_EsMqKM{%dRMI5`5CT&%mQO?-@F6tE*xL?aEGZ
z8^wH@wRl`Izx4sDmU>}Ym{ybUm@F83qqZPD6nFm?t?(7>h*?`fw)L3t*l%*iw0Qu#?$5eq!Qc
zpQvqgSxrd83NsdO@lL6#{%lsYXWen~d3p4fGBb7&5xqNYJ)yn84!e1PmPo7ChVd%4
zHUsV0Mh?VpzZD=A6%)Qrd~i7
z96*RPbid;BN{Wh?adeD_p8YU``kOrGkNox3D9~!K?w>#kFz!4lzOWR}puS(DmfjJD
z`x0z|qB33*^0mZdM&6$|+T>fq>M%yoy(BEjuh9L0>{P&XJ3enGpoQRx`v6$txXt#c
z0#N?b5%srj(4xmPvJxrlF3H%OMB!jvfy
z;wx8RzU~lb?h_}@V=bh6p8PSb-dG|-T#A?`c&H2`_!u+uenIZe`6f~A7r)`9m8atC
zt(b|6Eg#!Q*DfRU=Ix`#B_dK)nnJ_+>Q<1d7W)eynaVn`FNuN~%B;uO2}vXr5^zi2
z!ifIF5@Zlo0^h~8+ixFBGqtweFc`C~JkSq}&*a3C}L?b5Mh-bW=e)({F_g4O3
zb@SFTK3VD9QuFgFnK4Ve_pXc3{S$=+Z;;4+;*{H}Rc;845rP?DLK6G5Y-xdUKkA6E3Dz&5f{F^FjJQ(NSpZ8q-_!L3LL@H*
zxbDF{gd^U3uD;)a)sJwAVi}7@%pRM&?5IaUH%+m{E)DlA_$IA1=&jr{KrhD5q&lTC
zAa3c)A(K!{#nOvenH6XrR-y>*4M#DpTTOGQEO5Jr6kni9pDW`rvY*fs|ItV;CVITh
z=`rxcH2nEJpkQ^(;1c^hfb8vGN;{{oR=qNyKtR1;J>CByul*+=`NydWnSWJR#I2lN
zTvgnR|MBx*XFsfdA&;tr^dYaqRZp*2NwkAZE6kV@1f{76e56eUmGrZ>MDId)oqSWw
z7d&r3qfazg+W2?bT}F)4jD6sWaw`_fXZGY&wnGm$FRPFL$HzVTH^MYBHWGCOk-89y
zA+n+Q6EVSSCpgC~%uHfvyg@ufE^#u?JH?<73A}jj5iILz4Qqk5$+^U(SX(-qv5agK
znUkfpke(KDn~dU0>gdKqjTkVk`0`9^0n_wzXO7R!0Thd@S;U`y)VVP&mOd-2
z(hT(|$=>4FY;CBY9#_lB$;|Wd$aOMT5O_3}DYXEHn&Jrc3`2JiB`b6X@EUOD
zVl0S{ijm65@n^19T3l%>*;F(?3r3s?zY{thc4%AD30CeL_4{8x6&cN}zN3fE+x<9;
zt2j1RRVy5j22-8U8a6$pyT+<`f+x2l$fd_{qEp_bfxfzu>ORJsXaJn4>U6oNJ#|~p
z`*ZC&NPXl&=vq2{Ne79AkQncuxvbOG+28*2wU$R=GOmns3W@HE%^r)Fu%Utj=r9t`
zd;SVOnA(=MXgnOzI2@3SGKHz8HN~Vpx&!Ea+Df~`*n@8O=0!b4m?7cE^K*~@fqv9q
zF*uk#1@6Re_<^9eElgJD!nTA@K9C732tV~;B`hzZ321Ph=^BH?zXddiu{Du5*IPg}
zqDM=QxjT!Rp|#Bkp$(mL)aar)f(dOAXUiw81pX0DC|Y4;>Vz>>DMshoips^8Frdv}
zlTD=cKa48M>dR<>(YlLPOW%rokJZNF2gp8fwc8b2sN+i6&-pHr?$rj|uFgktK@jg~
zIFS(%=r|QJ=$kvm_~@n=ai1lA{7Z}i+zj&yzY+!t$iGUy|9jH#&oTNJ;JW-3n>DF+
z3aCOzqn|$X-Olu_p7brzn`uk1F*N4@=b=m;S_C?#hy{&NE#3HkATrg?enaVGT^$qIjvgc61y!T$9<1B@?_ibtDZ{G
zeXInVr5?OD_nS_O|CK3|RzzMmu+8!#Zb8Ik;rkIAR%6?$pN@d<0dKD2c@k2quB%s(
zQL^<_EM6ow8F6^wJN1QcPOm|ehA+dP(!>IX=Euz5qqIq}Y3;ibQtJnkDmZ8c8=Cf3
zu`mJ!Q6wI7EblC5RvP*@)j?}W=WxwCvF3*5Up_`3*a~z$`wHwCy)2risye=1mSp%p
zu+tD6NAK3o@)4VBsM!@);qgsjgB$kkCZhaimHg&+k69~drbvRTacWKH;YCK(!rC?8
zP#cK5JPHSw;V;{Yji=55X~S+)%(8fuz}O>*F3)hR;STU`z6T1aM#Wd+FP(M5*@T1P
z^06O;I20Sk!bxW<-O;E081KRdHZrtsGJflFRRFS
zdi5w9OVDGSL3
zNrC7GVsGN=b;YH9jp8Z2$^!K@h=r-xV(aEH@#JicPy;A0k1>g1g^XeR`YV2HfmqXY
zYbRwaxHvf}OlCAwHoVI&QBLr5R|THf?nAevV-=~V8;gCsX>jndvNOcFA+DI+zbh~#
zZ7`qNk&w+_+Yp!}j;OYxIfx_{f0-ONc?mHCiCUak=>j>~>YR4#w#
zuKz~UhT!L~GfW^CPqG8Lg)&Rc6y^{%3H7iLa%^l}cw_8UuG;8nn9)kbPGXS}p3!L_
zd#9~5CrH8xtUd?{d2y^PJg+z(xIfRU;`}^=OlehGN2=?}9yH$4Rag}*+AWotyxfCJ
zHx=r7ZH>j2kV?%7WTtp+-HMa0)_*DBBmC{sd$)np&GEJ__kEd`xB5a2A
z*J+yx>4o#ZxwA{;NjhU*1KT~=ZK~GAA;KZHDyBNTaWQ1+;tOFFthnD)DrCn`DjBZ%
zk$N5B4^$`n^jNSOr=t(zi8TN4fpaccsb`zOPD~iY=UEK$0Y70bG{idLx@IL)7^(pL
z{??Bnu=lDeguDrd%qW1)H)H`9otsOL-f4bSu};o9OXybo6J!Lek`a4ff>*O)BDT_g
z<6@SrI|C9klY(>_PfA^qai7A_)VNE4c^ZjFcE$Isp>`e5fLc)rg@8Q_d^Uk24$2bn
z9#}6kZ2ZxS9sI(RqT7?El2@B+($>eBQrNi_k#CDJ8D9}8$mmm
z4oSKO^F$i+NG)-HE$O6s1--6EzJa?C{x=QgK&c=)b(Q9OVoAXYEEH20G|q$}Hue%~
zO3B^bF=t7t48sN
zWh_zA`w~|){-!^g?6Mqf6ieV
zFx~aPUOJGR=4{KsW7I?<=J2|lY`NTU=lt=%JE9H1vBpkcn=uq(q~=?iBt_-r(PLBM
zP-0dxljJO>4Wq-;stY)CLB4q`-r*T$!K2o}?E-w_i>3_aEbA^MB7P5piwt1dI-6o!qWCy0
ztYy!x9arGTS?kabkkyv*yxvsPQ7Vx)twkS6z2T@kZ|kb8yjm+^$|sEBmvACeqbz)RmxkkDQX-A*K!YFziuhwb|ym>C$}U|J)4y
z$(z#)GH%uV6{ec%Zy~AhK|+GtG8u@c884Nq%w`O^wv2#A(&xH@c5M`Vjk*SR_tJnq
z0trB#aY)!EKW_}{#L3lph5ow=@|D5LzJYUFD6
z7XnUeo_V0DVSIKMFD_T0AqAO|#VFDc7c?c-Q%#u00F%!_TW1@JVnsfvm@_9HKWflBOUD~)RL``-!P;(bCON_4eVdduMO>?IrQ__*zE@7(OX
zUtfH@AX*53&xJW*Pu9zcqxGiM>xol0I~QL5B%Toog3Jlenc^WbVgeBvV8C8AX^Vj&
z^I}H})B=VboO%q1;aU5ACMh{yK4J;xlMc`jCnZR^!~LDs_MP&8;dd@4LDWw~*>#OT
zeZHwdQWS!tt5MJQI~cw|Ka^b4c|qyd_ly(+Ql2m&AAw^
zQeSXDOOH!!mAgzAp0z)DD>6Xo``b6QwzUV@w%h}Yo>)a|xRi$jGuHQhJVA%>)PUvK
zBQ!l0hq<3VZ*RnrDODP)>&iS^wf64C;MGqDvx>|p;35%6(u+IHoNbK
z;Gb;TneFo*`zUKS6kwF*&b!U8e5m4YAo03a_e^!5BP42+r)LFhEy?_7U1IR<;
z^0v|DhCYMSj<-;MtY%R@Fg;9Kky^pz_t2nJfKWfh5Eu@_l{^ph%1z{jkg5jQrkvD<
z#vdK!nku*RrH~TdN~`wDs;d>XY1PH?O<4^U4lmA|wUW{Crrv#r%N>7k#{Gc44Fr|t
z@UZP}Y-TrAmnEZ39A*@6;ccsR>)$A)S>$-Cj!=x$rz7IvjHIPM(TB+JFf{ehuIvY$
zsDAwREg*%|=>Hw$`us~RP&3{QJg%}RjJKS^mC_!U;E5u>`X`jW$}P`Mf}?7G7FX#{
zE(9u1SO;3q@ZhDL9O({-RD+SqqPX)`0l5IQu4q)49TUTkxR(czeT}4`WV~pV*KY&i
zAl3~X%D2cPVD^B43*~&f%+Op)wl<&|D{;=SZwImydWL6@_RJjxP2g)s=dH)u9Npki
zs~z9A+3fj0l?yu4N0^4aC5x)Osnm0qrhz@?nwG_`h(71P
znbIewljU%T*cC=~NJy|)#hT+lx#^5MuDDnkaMb*Efw9eThXo|*WOQzJ*#3dmRWm@!
zfuSc@#kY{Um^gBc^_Xdxnl!n&y&}R4yAbK&RMc+P^Ti;YIUh|C+K1|=Z^{nZ}}rxH*v{xR!i%qO~o
zTr`WDE@k$M9o0r4YUFFeQO7xCu_Zgy)==;fCJ94M_rLAv&~NhfvcLWCoaGg2ao~3e
zBG?Ms9B+efMkp}7BhmISGWmJsKI@a8b}4lLI48oWKY|8?zuuNc$lt5Npr+p7a#sWu
zh!@2nnLBVJK!$S~>r2-pN||^w|fY`CT{TFnJy`B|e5;=+_v4l8O-fkN&UQbA4NKTyntd
zqK{xEKh}U{NHoQUf!M=2(&w+eef77VtYr;xs%^cPfKLObyOV_9q<(%76-J%vR>w9!us-0c-~Y?_EVS%v!*
z15s2s3eTs$Osz$JayyH|5nPAIPEX=U;r&p;K14G<1)bvn@?bM5kC{am|C5%hyxv}a
z(DeSKI5ZfZ1*%dl8frIX2?);R^^~LuDOpNpk-2R8U1w92HmG1m&|j&J{EK=|p$;f9
z7Rs5|jr4r8k5El&qcuM+YRlKny%t+1CgqEWO>3;BSRZi(LA3U%Jm{@{y+A+w(gzA<
z7dBq6a1sEWa4cD0W7=Ld9z0H7RI^Z7vl(bfA;72j?SWCo`#5mVC$l1Q2--%V)-uN*
z9ha*s-AdfbDZ8R8*fpwjzx=WvOtmSzGFjC#X)hD%Caeo^OWjS(3h|d9_*U)l%{Ab8
zfv$yoP{OuUl@$(-sEVNt{*=qi5P=lpxWVuz2?I7Dc%BRc+NGNw+323^
z5BXGfS71oP^%apUo(Y#xkxE)y?>BFzEBZ}UBbr~R4$%b7h3iZu3S(|A;&HqBR{nK&
z$;GApNnz=kNO^FL&nYcfpB7Qg;hGJPsCW44CbkG1@l9pn0`~oKy5S777uH)l{irK!ru|X+;4&0D;VE*Ii|<3P
zUx#xUqvZT5kVQxsF#~MwKnv7;1pR^0;PW@$@T7I?s`_rD1EGUdSA5Q(C<>5SzE!vw
z;{L&kKFM-MO>hy#-8z`sdVx})^(Dc-dw;k-h*9O2_YZw}|9^y-|8RQ`BWJUJL(Cer
zP5Z@fNc>pTXABbTRY-B5*MphpZv6#i802giwV&SkFCR
zGMETyUm(KJbh+&$8X*RB#+{surjr;8^REEt`2&Dubw3$mx>|~B5IKZJ`s_6fw
zKAZx9&PwBqW1Oz0r0A4GtnZd7XTKViX2%kPfv+^X3|_}RrQ2e3l=KG_VyY`H?I5&CS+lAX5HbA%TD9u6&s#v!G>
zzW9n4J%d5ye7x0y`*{KZvqyXUfMEE^ZIffzI=Hh|3J}^yx7eL=s+TPH(Q2GT-sJ~3
zI463C{(ag7-hS1ETtU;_&+49ABt5!A7C