Summary
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!
✨ Lambda Metadata Utility
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() + "\"}";
}
}✨ SLF4J Fluent API Key-Value Pairs in Logging
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";
}
}Changes
- chore: bump release-drafter/release-drafter from 7.1.0 to 7.1.1 (#2428) by @dependabot[bot]
- chore: bump org.apache.maven.plugins:maven-jar-plugin from 3.4.2 to 3.5.0 (#2427) by @dependabot[bot]
- chore: bump org.codehaus.mojo:versions-maven-plugin from 2.20.1 to 2.21.0 (#2426) by @dependabot[bot]
- chore(ci): bump version to 2.10.0 (#2429) by @github-actions[bot]
- feat(lmds): Add support for Lambda Metadata Service (#2424) by @phipag
- chore: modernize native maven profiles (#2419) by @phipag
- chore: bump release-drafter/release-drafter from 7.0.0 to 7.1.0 (#2423) by @dependabot[bot]
- chore: bump aws.sdk.version from 2.42.14 to 2.42.15 (#2421) by @dependabot[bot]
- chore: bump com.amazonaws:aws-lambda-java-runtime-interface-client from 2.8.7 to 2.9.0 (#2420) by @dependabot[bot]
- chore: bump aws.sdk.version from 2.41.10 to 2.42.5 (#2400) by @dependabot[bot]
- chore: bump org.assertj:assertj-core from 3.27.6 to 3.27.7 in /powertools-tracing (#2417) by @dependabot[bot]
- chore: bump software.amazon.awscdk:aws-cdk-lib from 2.224.0 to 2.243.0 (#2418) by @dependabot[bot]
- chore: bump com.fasterxml.jackson:jackson-bom from 2.20.1 to 2.21.1 (#2403) by @dependabot[bot]
- chore: bump sam/build-java25 from
15e69d9to32b91abin /powertools-e2e-tests/src/test/resources/docker (#2406) by @dependabot[bot] - chore: bump release-drafter/release-drafter from 6.2.0 to 7.0.0 (#2415) by @dependabot[bot]
- chore: bump github/codeql-action from 4.32.5 to 4.33.0 (#2414) by @dependabot[bot]
- chore: bump actions/download-artifact from 8.0.0 to 8.0.1 (#2411) by @dependabot[bot]
- chore: bump squidfunk/mkdocs-material from
f4332a8toc373999in /docs (#2410) by @dependabot[bot] - chore: bump markdown from 3.7 to 3.8.1 in /docs (#2405) by @dependabot[bot]
- chore: bump graalvm/setup-graalvm from 1.4.5 to 1.5.0 (#2412) by @dependabot[bot]
- chore: bump squidfunk/mkdocs-material from
8f41b60tof4332a8in /docs (#2401) by @dependabot[bot] - chore: bump actions/dependency-review-action from 4.8.3 to 4.9.0 (#2402) by @dependabot[bot]
- chore: bump actions/dependency-review-action from 4.8.2 to 4.8.3 (#2390) by @dependabot[bot]
- chore: bump squidfunk/mkdocs-material from
3bba0a9to8f41b60in /docs (#2392) by @dependabot[bot] - chore: bump actions/download-artifact from 7.0.0 to 8.0.0 (#2393) by @dependabot[bot]
- chore: bump com.google.protobuf:protobuf-java from 4.33.2 to 4.33.4 (#2360) by @dependabot[bot]
- chore: bump aws.sdk.version from 2.39.3 to 2.41.11 (#2359) by @dependabot[bot]
- chore: bump tj-actions/changed-files from 47.0.4 to 47.0.5 (#2399) by @dependabot[bot]
- chore(ci): Run E2E tests in a per-test matrix (#2398) by @phipag
- chore: bump actions/upload-artifact from 6.0.0 to 7.0.0 (#2394) by @dependabot[bot]
- chore: bump github/codeql-action from 4.32.3 to 4.32.5 (#2396) by @dependabot[bot]
- feat(logging): add support for key-value pairs in LambdaJsonEncoder (#2377) by @cmtjk
- chore: bump aws-actions/configure-aws-credentials from 5.1.1 to 6.0.0 (#2382) by @dependabot[bot]
- chore: bump sam/build-java25 from
bffac7dto15e69d9in /powertools-e2e-tests/src/test/resources/docker (#2385) by @dependabot[bot] - chore: bump org.apache.avro:avro from 1.12.0 to 1.12.1 in /examples/powertools-examples-kafka/tools (#2386) by @dependabot[bot]
- chore: bump tj-actions/changed-files from 47.0.1 to 47.0.4 (#2388) by @dependabot[bot]
- chore: bump github/codeql-action from 4.32.0 to 4.32.3 (#2387) by @dependabot[bot]
- chore(ci): harden GitHub Actions workflow permissions (#2370) by @phipag
- chore: bump release-drafter/release-drafter from 6.1.1 to 6.2.0 (#2362) by @dependabot[bot]
- chore: bump actions/setup-java from 5.1.0 to 5.2.0 (#2363) by @dependabot[bot]
- chore: bump actions/checkout from 6.0.1 to 6.0.2 (#2365) by @dependabot[bot]
- chore: bump github/codeql-action from 4.31.10 to 4.32.0 (#2369) by @dependabot[bot]
- chore: bump release-drafter/release-drafter from 6.1.0 to 6.1.1 (#2357) by @dependabot[bot]
- chore: bump aws.sdk.version from 2.40.13 to 2.41.10 (#2354) by @dependabot[bot]
- chore: bump org.codehaus.mojo:aspectj-maven-plugin from 1.15.0 to 1.16.0 (#2353) by @dependabot[bot]
- chore: bump mockito.version from 5.18.0 to 5.21.0 (#2352) by @dependabot[bot]
- chore: bump graalvm/setup-graalvm from 1.4.4 to 1.4.5 (#2349) by @dependabot[bot]
- chore: bump github/codeql-action from 4.31.9 to 4.31.10 (#2350) by @dependabot[bot]
- chore: bump aws.sdk.version from 2.40.9 to 2.40.13 (#2346) by @dependabot[bot]
- chore: bump com.google.protobuf:protobuf-java from 4.33.1 to 4.33.2 (#2347) by @dependabot[bot]
- chore: bump squidfunk/mkdocs-material from
980e11fto3bba0a9in /docs (#2341) by @dependabot[bot] - feat(crac): Support CRaC and priming of powertools tracing (#2345) by @Attyuttam
- chore: bump org.apache.logging.log4j:log4j-core from 2.25.2 to 2.25.3 (#2344) by @dependabot[bot]
- chore: bump sam/build-java25 from
b34fc78tobffac7din /powertools-e2e-tests/src/test/resources/docker (#2342) by @dependabot[bot] - chore: bump github/codeql-action from 4.31.8 to 4.31.9 (#2340) by @dependabot[bot]
- chore: bump actions/download-artifact from 6.0.0 to 7.0.0 (#2339) by @dependabot[bot]
- chore: bump actions/upload-artifact from 5.0.0 to 6.0.0 (#2338) by @dependabot[bot]
- chore: bump org.mockito:mockito-junit-jupiter from 5.20.0 to 5.21.0 (#2336) by @dependabot[bot]
- chore: bump aws.sdk.version from 2.39.1 to 2.40.9 (#2335) by @dependabot[bot]
- docs: Announce end-of-life of version 1.x.x (#2333) by @phipag
- chore(ci): bump version to 2.9.0 (#2332) by @github-actions[bot]
This release was made possible by the following contributors:
@Attyuttam, @cmtjk, @dependabot[bot], @github-actions[bot], @phipag, dependabot[bot] and github-actions[bot]