Powertools is a developer toolkit to implement Serverless best practices and increase developer velocity.
Repo aws-powertools/powertools-lambda-java, read from GitHub 18 h ago. aws-powertools has not joined Take My Repo.
๐ฃ Starting with this release, Powertools for AWS Lambda (Java) requires Java 17 or later. If your functions still run on the java11 runtime, we recommend that you upgrade to Java 21 or 25 to get the latest features and fixes.
This release also adds an S3 bucket allowlist to the Large Messages utility, automatic tenant ID logging for functions that use Lambda tenant isolation, and SnapStart priming for the Large Messages utility. We fixed a bug that stopped SnapStart priming from loading any classes in the Tracing utility, and we updated Jackson and Logback to address 10 CVEs.
๐ Thanks to @David-DAM, @pascalknupper, and @Pratapchandradeo for contributing for the first time!
Powertools for AWS Lambda (Java) now compiles to Java 17 bytecode and no longer supports Java 11. Move your functions to the java17, java21, or java25 Lambda runtime before you upgrade. The public API is unchanged, so you don't need to change your code.
The change stays within v2, as our versioning policy allows. Java 11 blocked upgrades to dependencies such as JUnit 6 and protobuf-maven-plugin. See the announcement for details.
The message sender chooses the S3 bucket in a large message pointer. To limit the buckets the utility reads from and deletes from, pass an allowlist to LargeMessageConfig. If a pointer names a bucket that is not in the list, the utility throws LargeMessageProcessingException before it calls S3. The allowlist is empty by default, and an empty list applies no restriction, so existing functions behave as before. The allowlist works with the @LargeMessage annotation and with the functional API.
We recommend that you also scope your function's IAM policy to the offload bucket.
Basic usage:
import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.RequestHandler; import com.amazonaws.services.lambda.runtime.events.SQSBatchResponse; import com.amazonaws.services.lambda.runtime.events.SQSEvent; import java.util.Set; import software.amazon.lambda.powertools.largemessages.LargeMessageConfig; import software.amazon.lambda.powertools.largemessages.LargeMessages; public class SqsMessageHandler implements RequestHandler<SQSEvent, SQSBatchResponse> { public SqsMessageHandler() { LargeMessageConfig.init().withAllowedBuckets(Set.of("my-offload-bucket")); } @Override public SQSBatchResponse handleRequest(SQSEvent event, Context context) { for (SQSEvent.SQSMessage message : event.getRecords()) { // throws LargeMessageProcessingException if the bucket is not in the allowlist LargeMessages.processLargeMessage(message, this::processRawMessage); } return SQSBatchResponse.builder().build(); } private String processRawMessage(SQSEvent.SQSMessage sqsMessage) { // sqsMessage.getBody() contains the content of the S3 object return sqsMessage.getBody(); } }
If your function uses Lambda tenant isolation, Logger now adds the tenant ID next to the other Lambda context fields, such as function_request_id. The field is tenant_id in the JSON format and tenant.id in the ECS format. You don't need to change your code. Logger leaves out the field when the tenant ID is null or empty. This works with Log4j2 and Logback.
Example output:
{
"level": "INFO",
"message": "Processing order",
"function_request_id": "c6af9ac6-7b61-11e6-9a41-93e812345678",
"tenant_id": "tenant-a",
...
}The Large Messages utility now supports CRaC. It loads its classes before SnapStart takes the snapshot, which reduces restore duration. To let the utility register before the snapshot, reference LargeMessages in your handler's initialization code.
Static initializer:
import software.amazon.lambda.powertools.largemessages.LargeMessages; public class SqsMessageHandler implements RequestHandler<SQSEvent, SQSBatchResponse> { static { LargeMessages.init(); // registers LargeMessages for SnapStart priming } // ... }
classesloaded.txt file has a leading space on each line, and the class loader kept that space in the class names. The loader now strips the space, and a deployed test function loaded 4,062 classes during priming instead of 0 (#2560).jackson-databind 2.15.2 in Large Messages. Tracing also moves to X-Ray SDK 2.21.1 (#2574, #2640, #2653).logback-classic to 1.5.38 to address CVE-2025-11226, CVE-2026-1225, CVE-2026-9828, and CVE-2026-10532 (#2644).kafka-clients 4.2.0 depends on lz4-java 1.10.1, which is affected by CVE-2026-59949. The Kafka utility declares kafka-clients with provided scope, so your build resolves lz4-java through your own kafka-clients dependency. Pin at.yawk.lz4:lz4-java to 1.11.2 in your build to address the CVE. We pinned it in the Kafka example (#2656).2d12901 to 35c398d in /powertools-e2e-tests/src/test/resources/docker (#2669) by @dependabot[bot]This release introduces a new Lambda Metadata utility that provides idiomatic access to the Lambda Metadata Endpoint (LMDS), allowing you to retrieve execution environment metadata like Availability Zone ID.
We also added support for SLF4J fluent API key-value pairs in the Logback and ECS encoders, the Logback and ECS encoders now properly serialize addKeyValue() pairs in structured log output.
๐ Thanks to @cmtjk for contributing for the first time!
Added a new powertools-lambda-metadata module that provides access to Lambda execution environment metadata from the Lambda Metadata Service (LMDS). The utility exposes a simple static API with automatic caching for the sandbox lifetime, thread-safe concurrent access for Lambda Managed Instances, automatic SnapStart cache invalidation via CRaC, and GraalVM native-image support.
Install:
<dependency> <groupId>software.amazon.lambda</groupId> <artifactId>powertools-lambda-metadata</artifactId> <version>2.10.0</version> </dependency>
Basic usage:
import software.amazon.lambda.powertools.metadata.LambdaMetadata; import software.amazon.lambda.powertools.metadata.LambdaMetadataClient; public class App implements RequestHandler<Object, String> { @Override public String handleRequest(Object input, Context context) { // Fetch metadata (automatically cached after first call) LambdaMetadata metadata = LambdaMetadataClient.get(); String azId = metadata.getAvailabilityZoneId(); // e.g., "use1-az1" return "{\"az\": \"" + azId + "\"}"; } }
Eager loading at class initialization:
import software.amazon.lambda.powertools.metadata.LambdaMetadata; import software.amazon.lambda.powertools.metadata.LambdaMetadataClient; public class App implements RequestHandler<Object, String> { // Fetch during cold start (class loading) - cache auto-invalidated on SnapStart restore private static final LambdaMetadata METADATA = LambdaMetadataClient.get(); @Override public String handleRequest(Object input, Context context) { return "{\"az\": \"" + METADATA.getAvailabilityZoneId() + "\"}"; } }
Key-value pairs added via SLF4J's fluent API (addKeyValue) are now properly serialized in both LambdaJsonEncoder and LambdaEcsEncoder for Logback. Previously, these values were silently ignored.
import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class App implements RequestHandler<Object, String> { private static final Logger LOG = LoggerFactory.getLogger(App.class); @Override public String handleRequest(Object input, Context context) { LOG.atInfo() .addKeyValue("orderId", "12345") .addKeyValue("customerId", "C-100") .setMessage("Processing order") .log(); return "ok"; } }
15e69d9 to 32b91ab in /powertools-e2e-tests/src/test/resources/docker (#2406) by @dependabot[bot]f4332a8 to c373999 in /docs (#2410) by @dependabot[bot]8f41b60 to f4332a8 in /docs (#2401) by @dependabot[bot]3bba0a9 to 8f41b60 in /docs (#2392) by @dependabot[bot]bffac7d to 15e69d9 in /powertools-e2e-tests/src/test/resources/docker (๐๏ธ Powertools for AWS Lambda (Java) 1.x.x is now end-of-life. See announcement in #1895. We strongly recommend you to upgrade to 2.x.x following our upgrade guide.
This release fixes a bug where metrics dimensions were incorrectly persisted across Lambda invocations. Additionally, cold start detection now respects the Lambda environment (e.g. Lambda Managed Instances does not incur cold starts).
๐ Thanks to @Attyuttam for contributing for the first time!
af599d0 to b34fc78 in /powertools-e2e-tests/src/test/resources/docker (#2324) by @dependabot[bot]2ef9e5b to af599d0 in /powertools-e2e-tests/src/test/resources/docker (#2309) by @dependabot[bot]โก This release completes the effort of making all utilities thread-safe helping you run multi-concurrent workloads on AWS Lambda.
51709ae to ced5388 in /powertools-e2e-tests/src/test/resources/docker (#2292) by @dependabot[bot]๐ฃ We are excited to announce support for Java 25 across all utilities, including compatibility with the new AWS Lambda Java 25 runtime. Read more in the announcement blog post.
We also introduced a new functional approach for all utilities. This pattern is ideal when you want to avoid AspectJ setup or prefer a more imperative style. Key benefits include:
You can now make any function idempotent without AspectJ using the new functional API. This approach provides explicit control over idempotency behavior.
Basic usage:
public class App implements RequestHandler<Subscription, SubscriptionResult> { public App() { Idempotency.config().withPersistenceStore( DynamoDBPersistenceStore.builder() .withTableName(System.getenv("TABLE_NAME")) .build() ).configure(); } public SubscriptionResult handleRequest(Subscription event, Context context) { Idempotency.registerLambdaContext(context); return Idempotency.makeIdempotent(this::processEvent, event, SubscriptionResult.class); } private SubscriptionResult processEvent(Subscription event) { // Your business logic here return new SubscriptionResult(payment.getId(), "success", 200); } }
โจ New feature: Generic return types support
The functional API now supports making methods with generic return types idempotent using Jackson's TypeReference. This was not possible with the @Idempotent annotation due to type erasure.
public Map<String, Basket> handleRequest(Product input, Context context) { Idempotency.registerLambdaContext(context); return Idempotency.makeIdempotent( this::processProduct, input, new TypeReference<Map<String, Basket>>() {} ); } private Map<String, Basket> processProduct(Product product) { // business logic returning generic type }
The new functional API for Logging provides a way to add structured logging to your Lambda functions without AspectJ configuration. It automatically manages logging context and state cleanup.
Basic usage:
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> { private static final Logger log = LoggerFactory.getLogger(App.class); public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) { return PowertoolsLogging.withLogging(context, () -> { log.info("Processing request"); return new APIGatewayProxyResponseEvent().withStatusCode(200); }); } }
With correlation ID and sampling:
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) { return PowertoolsLogging.withLogging( context, 0.5, // 50% sampling rate CorrelationIdPaths.API_GATEWAY_REST, input, () -> { log.info("Processing payment"); return new APIGatewayProxyResponseEvent().withStatusCode(200); } ); }
The Large Messages utility now supports a functional API for processing SQS and SNS messages with payloads offloaded to S3. This approach is thread-safe and works seamlessly with the Batch utility.
public class SqsBatchHandler implements RequestHandler<SQSEvent, SQSBatchResponse> { private final BatchMessageHandler<SQSEvent, SQSBatchResponse> handler; public SqsBatchHandler() { // Compatible with the Batch utility handler = new BatchMessageHandlerBuilder() .withSqsBatchHandler() .buildWithRawMessageHandler(this::processMessage); } @Override public SQSBatchResponse handleRequest(SQSEvent sqsEvent, Context context) { return handler.processBatch(sqsEvent, context); } private void processMessage(SQSEvent.SQSMessage sqsMessage) { LargeMessages.processLargeMessage(sqsMessage, this::handleProcessedMessage); } private void handleProcessedMessage(SQSEvent.SQSMessage processedMessage) { // do something with the message } }
58dee36 to 980e11f in /docs (#2280) by @dependabot[bot]72709a0 to 51709ae in /powertools-e2e-tests/src/test/resources/docker (#2275) by @dependabot[bot]๐ This release contains improvements and bug fixes across different utilities.
In Logging, we fix a bug in the Log4j 2 logging backend that caused correlation ids to be missing from the JSON log.
In Idempotency, we resolve a regression that caused the payload validation feature to be ignored in certain cases since v2.0.0.
We also improve the reliability of JSON serialization for a larger variety of AWS events including Joda time fields and fix a warning message that was emitted for customers using the AWS SDK v2 for Java.
f5c556a to 58dee36 in /docs (#2259) by @dependabot[bot]Idempotency API (#2244) by @phipag@Logging annotation (#2205) by @phipag068d2ab to 72709a0 in /powertools-e2e-tests/src/test/resources/docker (#2233) by @dependabot[bot]e12c501 to 068d2ab in /powertools-e2e-tests/src/test/resources/docker (#2226) by @dependabot[bot]