Skip to content

Commit c8d2404

Browse files
authored
Merge branch 'main' into support_crac_on_powertools_metrics
2 parents 747dad8 + 871a844 commit c8d2404

File tree

106 files changed

+4322
-2026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+4322
-2026
lines changed

.github/workflows/build-docs.yml

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Build Docs
1+
# Build Latest Docs
22
#
33
# Description:
4-
# Builds the docs and stores them in S3 to be served by our docs platform
4+
# Builds the latest docs and stores them in S3 to be served by our docs platform
55
#
66
# The workflow allows us to build to the main location (/lambda/java/) and to an alias
77
# (i.e. /lambda/java/preview/) if needed
@@ -15,17 +15,13 @@
1515
on:
1616
workflow_dispatch:
1717
inputs:
18-
alias:
18+
version:
19+
description: "Version to build and publish docs (1.28.0, develop)"
20+
required: true
1921
type: string
20-
required: false
21-
description: |
22-
Alias to deploy the documentation into, this is mostly for testing pre-release
23-
versions of the documentation, such as beta versions or snapshots.
2422

25-
https://docs.powertools.aws.dev/lambda/java/<alias>
26-
27-
name: Build Docs
28-
run-name: Build Docs - ${{ contains(github.head_ref, 'main') && 'main' || inputs.alias }}
23+
name: Build Latest Docs
24+
run-name: Build Latest Docs - ${{ inputs.version }}
2925

3026
jobs:
3127
docs:
@@ -35,28 +31,58 @@ jobs:
3531
id-token: write
3632
environment: Docs
3733
steps:
38-
- name: Sanity Check
39-
if: ${{ github.head_ref != 'main' || inputs.alias == '' }}
40-
run:
41-
echo "::error::No buildable docs"
42-
4334
- name: Checkout Repository
4435
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
45-
with:
36+
with:
4637
fetch-depth: 0
4738
- name: Build
4839
run: |
4940
mkdir -p dist
5041
docker build -t squidfunk/mkdocs-material ./docs/
5142
docker run --rm -t -v ${PWD}:/docs squidfunk/mkdocs-material build
52-
cp -R site/* dist/
5343
- name: Configure AWS credentials
5444
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722
5545
with:
5646
aws-region: us-east-1
5747
role-to-assume: ${{ secrets.AWS_DOCS_ROLE_ARN }}
58-
- name: Deploy
48+
- name: Deploy Docs (Version)
49+
env:
50+
VERSION: ${{ inputs.version }}
51+
ALIAS: "latest"
5952
run: |
6053
aws s3 sync \
61-
dist \
62-
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/${{ github.head_ref == 'main' && '' || format('{0}/', inputs.alias )}}
54+
site/ \
55+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/${{ env.VERSION }}/
56+
- name: Deploy Docs (Alias)
57+
env:
58+
VERSION: ${{ inputs.version }}
59+
ALIAS: "latest"
60+
run: |
61+
aws s3 sync \
62+
site/ \
63+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/${{ env.ALIAS }}/
64+
- name: Deploy Docs (Version JSON)
65+
env:
66+
VERSION: ${{ inputs.version }}
67+
ALIAS: "latest"
68+
# We originally used "mike" from PyPi to manage versions for us, but since we moved to S3, we can't use it to manage versions any more.
69+
# Instead, we're using some shell script that manages the versions.
70+
#
71+
# Operations:
72+
# 1. Download the versions.json file from S3
73+
# 2. Find any reference to the alias and delete it from the versions file
74+
# 3. This is voodoo (don't use JQ):
75+
# - we assign the input as $o and the new version/alias as $n,
76+
# - we check if the version number exists in the file already (for republishing docs)
77+
# - if it's an alias (stage/latest/*) or old version, we do nothing and output $o (original input)
78+
# - if it's a new version number, we add it at position 0 in the array.
79+
# 4. Once done, we'll upload it back to S3.
80+
run: |
81+
aws s3 cp \
82+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/versions.json \
83+
versions_old.json
84+
jq 'del(.[].aliases[] | select(. == "${{ env.ALIAS }}"))' < versions_old.json > versions_proc.json
85+
jq '. as $o | [{"title": "${{ env.VERSION }}", "version": "${{ env.VERSION }}", "aliases": ["${{ env.ALIAS }}"] }] as $n | $n | if .[0].title | test("[a-z]+") or any($o[].title == $n[0].title;.) then [($o | .[] | select(.title == $n[0].title).aliases += $n[0].aliases | . )] else $n + $o end' < versions_proc.json > versions.json
86+
aws s3 cp \
87+
versions.json \
88+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/versions.json

.github/workflows/release.yml

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#
2121
# Triggers:
2222
# - workflow_dispatch
23-
#
23+
#
2424
# Secrets:
2525
# - RELEASE.GPG_SIGNING_KEY
2626
# - RELEASE.OSSRH_JIRA_USERNAME
@@ -39,23 +39,23 @@ on:
3939
type: boolean
4040
description: Create snapshot release
4141
default: false
42-
skip_checks:
42+
skip_checks:
4343
type: boolean
4444
description: Skip quality checks
4545
default: false
4646
skip_publish:
4747
type: boolean
4848
description: Skip publish to Maven Central
4949
default: false
50-
continue_on_error:
50+
continue_on_error:
5151
type: boolean
5252
description: Continue to build if there's an error in quality checks
5353
default: false
5454

5555
name: Release
5656
run-name: Release – ${{ inputs.version }}
5757

58-
permissions:
58+
permissions:
5959
contents: read
6060

6161
env:
@@ -124,7 +124,7 @@ jobs:
124124

125125
quality:
126126
runs-on: ubuntu-latest
127-
needs:
127+
needs:
128128
- version_seal
129129
if: ${{ inputs.skip_checks == false }}
130130
permissions:
@@ -211,7 +211,7 @@ jobs:
211211
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
212212
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
213213
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
214-
214+
215215
create_pr:
216216
runs-on: ubuntu-latest
217217
if: ${{ inputs.snapshot == false && always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
@@ -270,24 +270,57 @@ jobs:
270270
id-token: write
271271
environment: Docs
272272
steps:
273-
- id: download_source
274-
name: Download artifacts
275-
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.6.1
276-
with:
277-
name: source
273+
- id: checkout
274+
name: Checkout repository
275+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
278276
- name: Build
279277
run: |
280278
mkdir -p dist
281279
docker build -t squidfunk/mkdocs-material ./docs/
282280
docker run --rm -t -v ${PWD}:/docs squidfunk/mkdocs-material build
283-
cp -R site/* dist/
284281
- name: Configure AWS credentials
285282
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722
286283
with:
287284
aws-region: us-east-1
288285
role-to-assume: ${{ secrets.AWS_DOCS_ROLE_ARN }}
289-
- name: Deploy
286+
- name: Deploy Docs (Version)
287+
env:
288+
VERSION: ${{ inputs.version }}
289+
ALIAS: 'latest'
290+
run: |
291+
aws s3 sync \
292+
site/ \
293+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/${{ env.VERSION }}/
294+
- name: Deploy Docs (Alias)
295+
env:
296+
VERSION: ${{ inputs.version }}
297+
ALIAS: 'latest'
290298
run: |
291299
aws s3 sync \
292-
dist \
293-
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/
300+
site/ \
301+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/${{ env.ALIAS }}/
302+
- name: Deploy Docs (Version JSON)
303+
env:
304+
VERSION: ${{ inputs.version }}
305+
ALIAS: 'latest'
306+
# We originally used "mike" from PyPi to manage versions for us, but since we moved to S3, we can't use it to manage versions any more.
307+
# Instead, we're using some shell script that manages the versions.
308+
#
309+
# Operations:
310+
# 1. Download the versions.json file from S3
311+
# 2. Find any reference to the alias and delete it from the versions file
312+
# 3. This is voodoo (don't use JQ):
313+
# - we assign the input as $o and the new version/alias as $n,
314+
# - we check if the version number exists in the file already (for republishing docs)
315+
# - if it's an alias (stage/latest/*) or old version, we do nothing and output $o (original input)
316+
# - if it's a new version number, we add it at position 0 in the array.
317+
# 4. Once done, we'll upload it back to S3.
318+
run: |
319+
aws s3 cp \
320+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/versions.json \
321+
versions_old.json
322+
jq 'del(.[].aliases[] | select(. == "${{ env.ALIAS }}"))' < versions_old.json > versions_proc.json
323+
jq '. as $o | [{"title": "${{ env.VERSION }}", "version": "${{ env.VERSION }}", "aliases": ["${{ env.ALIAS }}"] }] as $n | $n | if .[0].title | test("[a-z]+") or any($o[].title == $n[0].title;.) then [($o | .[] | select(.title == $n[0].title).aliases += $n[0].aliases | . )] else $n + $o end' < versions_proc.json > versions.json
324+
aws s3 cp \
325+
versions.json \
326+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/versions.json

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ Powertools for AWS Lambda (Java) is available in Maven Central. You can use your
2222
<dependency>
2323
<groupId>software.amazon.lambda</groupId>
2424
<artifactId>powertools-tracing</artifactId>
25-
<version>2.0.0-SNAPSHOT</version>
25+
<version>2.0.0</version>
2626
</dependency>
2727
<dependency>
2828
<groupId>software.amazon.lambda</groupId>
2929
<artifactId>powertools-logging</artifactId>
30-
<version>2.0.0-SNAPSHOT</version>
30+
<version>2.0.0</version>
3131
</dependency>
3232
<dependency>
3333
<groupId>software.amazon.lambda</groupId>
3434
<artifactId>powertools-metrics</artifactId>
35-
<version>2.0.0-SNAPSHOT</version>
35+
<version>2.0.0</version>
3636
</dependency>
3737
...
3838
</dependencies>

docs/FAQs.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ title: FAQs
33
description: Frequently Asked Questions
44
---
55

6-
76
## How can I use Powertools for AWS Lambda (Java) with Lombok?
87

9-
Powertools uses `aspectj-maven-plugin` to compile-time weave (CTW) aspects into the project. In case you want to use `Lombok` or other compile-time preprocessor for your project, it is required to change `aspectj-maven-plugin` configuration to enable in-place weaving feature. Otherwise the plugin will ignore changes introduced by `Lombok` and will use `.java` files as a source.
8+
Many utilities in this library use `aspectj-maven-plugin` to compile-time weave (CTW) aspects into the project. In case you want to use `Lombok` or other compile-time preprocessor for your project, it is required to change `aspectj-maven-plugin` configuration to enable in-place weaving feature. Otherwise the plugin will ignore changes introduced by `Lombok` and will use `.java` files as a source.
109

1110
To enable in-place weaving feature you need to use following `aspectj-maven-plugin` configuration:
1211

1312
```xml hl_lines="2-6"
1413
<configuration>
15-
<forceAjcCompile>true</forceAjcCompile>
14+
<forceAjcCompile>true</forceAjcCompile>
1615
<sources/>
1716
<weaveDirectories>
1817
<weaveDirectory>${project.build.directory}/classes</weaveDirectory>
@@ -29,14 +28,14 @@ To enable in-place weaving feature you need to use following `aspectj-maven-plug
2928

3029
## How can I use Powertools for AWS Lambda (Java) with Kotlin projects?
3130

32-
Powertools uses `aspectj-maven-plugin` to compile-time weave (CTW) aspects into the project. When using it with Kotlin projects, it is required to `forceAjcCompile`.
33-
No explicit configuration should be required for gradle projects.
31+
Many utilities use `aspectj-maven-plugin` to compile-time weave (CTW) aspects into the project. When using it with Kotlin projects, it is required to `forceAjcCompile`.
32+
No explicit configuration should be required for gradle projects.
3433

3534
To enable `forceAjcCompile` you need to use following `aspectj-maven-plugin` configuration:
3635

3736
```xml hl_lines="2"
3837
<configuration>
39-
<forceAjcCompile>true</forceAjcCompile>
38+
<forceAjcCompile>true</forceAjcCompile>
4039
...
4140
<aspectLibraries>
4241
<aspectLibrary>
@@ -49,17 +48,17 @@ To enable `forceAjcCompile` you need to use following `aspectj-maven-plugin` con
4948

5049
## How can I use Powertools for AWS Lambda (Java) with the AWS CRT HTTP Client?
5150

52-
Powertools uses the `url-connection-client` as the default HTTP client. The `url-connection-client` is a lightweight HTTP client, which keeps the impact on Lambda cold starts to a minimum.
53-
With the [announcement](https://aws.amazon.com/blogs/developer/announcing-availability-of-the-aws-crt-http-client-in-the-aws-sdk-for-java-2-x/) of the `aws-crt-client` a new HTTP client has been released, which offers faster SDK startup time and smaller memory footprint.
51+
Utilities relying on AWS SDK clients use the `url-connection-client` as the default HTTP client. The `url-connection-client` is a lightweight HTTP client, which keeps the impact on Lambda cold starts to a minimum.
52+
With the [announcement](https://aws.amazon.com/blogs/developer/announcing-availability-of-the-aws-crt-http-client-in-the-aws-sdk-for-java-2-x/) of the `aws-crt-client` a new HTTP client has been released, which offers faster SDK startup time and smaller memory footprint.
5453

55-
Unfortunately, replacing the `url-connection-client` dependency with the `aws-crt-client` will not immediately improve the lambda cold start performance and memory footprint,
56-
as the default version of the dependency contains native system libraries for all supported runtimes and architectures (Linux, MacOS, Windows, AMD64, ARM64, etc). This makes the CRT client portable, without the user having to consider _where_ their code will run, but comes at the cost of JAR size.
54+
Unfortunately, replacing the `url-connection-client` dependency with the `aws-crt-client` will not immediately improve the lambda cold start performance and memory footprint,
55+
as the default version of the dependency contains native system libraries for all supported runtimes and architectures (Linux, MacOS, Windows, AMD64, ARM64, etc). This makes the CRT client portable, without the user having to consider _where_ their code will run, but comes at the cost of JAR size.
5756

5857
### Configuring dependencies
5958

60-
Using the `aws-crt-client` in your project requires the exclusion of the `url-connection-client` transitive dependency from the powertools dependency.
59+
Using the `aws-crt-client` in your project requires the exclusion of the `url-connection-client` transitive dependency from the `powertools-*` dependency.
6160

62-
```xml
61+
```xml
6362
<dependency>
6463
<groupId>software.amazon.lambda</groupId>
6564
<artifactId>powertools-parameters</artifactId>
@@ -72,8 +71,9 @@ Using the `aws-crt-client` in your project requires the exclusion of the `url-co
7271
</exclusions>
7372
</dependency>
7473
```
75-
Next, add the `aws-crt-client` and exclude the "generic" `aws-crt` dependency (contains all runtime libraries).
76-
Instead, set a specific classifier of the `aws-crt` to use the one for your target runtime: either `linux-x86_64` for a Lambda configured for x86 or `linux-aarch_64` for Lambda using arm64.
74+
75+
Next, add the `aws-crt-client` and exclude the "generic" `aws-crt` dependency (contains all runtime libraries).
76+
Instead, set a specific classifier of the `aws-crt` to use the one for your target runtime: either `linux-x86_64` for a Lambda configured for x86 or `linux-aarch_64` for Lambda using arm64.
7777

7878
!!! note "You will need to add a separate maven profile to build and debug locally when your development environment does not share the target architecture you are using in Lambda."
7979
By specifying the specific target runtime, we prevent other target runtimes from being included in the jar file, resulting in a smaller Lambda package and improved cold start times.
@@ -102,10 +102,11 @@ By specifying the specific target runtime, we prevent other target runtimes from
102102
```
103103

104104
### Explicitly set the AWS CRT HTTP Client
105-
After configuring the dependencies, it's required to explicitly specify the AWS SDK HTTP client.
106-
Depending on the Powertools module, there is a different way to configure the SDK client.
107105

108-
The following example shows how to use the Lambda Powertools Parameters module while leveraging the AWS CRT Client.
106+
After configuring the dependencies, it's required to explicitly specify the AWS SDK HTTP client.
107+
Depending on the utility you are using, there is a different way to configure the SDK client.
108+
109+
The following example shows how to use the Parameters module while leveraging the AWS CRT Client.
109110

110111
```java hl_lines="16 23-24"
111112
import static software.amazon.lambda.powertools.parameters.transform.Transformer.base64;
@@ -141,12 +142,12 @@ public class RequestHandlerWithParams implements RequestHandler<String, String>
141142
}
142143
```
143144

144-
The `aws-crt-client` was considered for adoption as the default HTTP client in Lambda Powertools for Java as mentioned in [Move SDK http client to CRT](https://github.com/aws-powertools/powertools-lambda-java/issues/1092),
145+
The `aws-crt-client` was considered for adoption as the default HTTP client in Powertools for AWS Lambda (Java) as mentioned in [Move SDK http client to CRT](https://github.com/aws-powertools/powertools-lambda-java/issues/1092),
145146
but due to the impact on the developer experience it was decided to stick with the `url-connection-client`.
146147

147148
## How can I use Powertools for AWS Lambda (Java) with GraalVM?
148149

149-
Powertools core utilities, i.e. [logging](./core/logging.md), [metrics](./core/metrics.md) and [tracing](./core/tracing.md), include the [GraalVM Reachability Metadata (GRM)](https://www.graalvm.org/latest/reference-manual/native-image/metadata/) in the `META-INF` directories of the respective JARs. You can find a working example of Serverless Application Model (SAM) based application in the [examples](../examples/powertools-examples-core-utilities/sam-graalvm/README.md) directory.
150+
Core utilities, i.e. [logging](./core/logging.md), [metrics](./core/metrics.md) and [tracing](./core/tracing.md), include the [GraalVM Reachability Metadata (GRM)](https://www.graalvm.org/latest/reference-manual/native-image/metadata/) in the `META-INF` directories of the respective JARs. You can find a working example of Serverless Application Model (SAM) based application in the [examples](../examples/powertools-examples-core-utilities/sam-graalvm/README.md) directory.
150151

151152
Below, you find typical steps you need to follow in a Maven based Java project:
152153

@@ -157,6 +158,7 @@ export JAVA_HOME=<path to GraalVM>
157158
```
158159

159160
### Use log4j `>2.24.0`
161+
160162
Log4j version `2.24.0` adds [support for GraalVM](https://github.com/apache/logging-log4j2/issues/1539#issuecomment-2106766878). Depending on your project's dependency hierarchy, older version of log4j might be included in the final dependency graph. Make sure version `>2.24.0` of these dependencies are used by your Maven project:
161163

162164
```xml
@@ -245,10 +247,11 @@ Create a Docker image using a `Dockerfile` like [this](../examples/powertools-ex
245247
docker build --platform linux/amd64 . -t your-org/your-app-graalvm-builder
246248
```
247249

248-
Create the native image of you Lambda function using the Docker command below.
250+
Create the native image of you Lambda function using the Docker command below.
249251

250252
```shell
251253
docker run --platform linux/amd64 -it -v `pwd`:`pwd` -w `pwd` -v ~/.m2:/root/.m2 your-org/your-app-graalvm-builder mvn clean -Pnative-image package
252254

253255
```
256+
254257
The native image is created in the `target/` directory.

0 commit comments

Comments
 (0)