Skip to content

Commit c739383

Browse files
authored
Merge pull request #1477 from aws-powertools/chore/main-into-v2
chore: Merge main into v2
2 parents 8586bf6 + 857fd4c commit c739383

File tree

43 files changed

+807
-1043
lines changed

Some content is hidden

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

43 files changed

+807
-1043
lines changed
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Artifacts Size
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths:
8+
- 'powertools-cloudformation/**'
9+
- 'powertools-core/**'
10+
- 'powertools-serialization/**'
11+
- 'powertools-logging/**'
12+
- 'powertools-sqs/**'
13+
- 'powertools-tracing/**'
14+
- 'powertools-validation/**'
15+
- 'powertools-parameters/**'
16+
- 'powertools-idempotency/**'
17+
- 'powertools-metrics/**'
18+
- 'pom.xml'
19+
jobs:
20+
codecheck:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
24+
- name: Setup java JDK 11
25+
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
26+
with:
27+
distribution: 'corretto'
28+
java-version: 11
29+
- name: Build with Maven
30+
run: mvn clean package --file pom.xml -DskipTests
31+
- name: Get artifacts size & build report
32+
id: artifacts-size-report
33+
run: |
34+
echo '## :floppy_disk: Artifacts Size Report' > report.md
35+
echo '| Module | Version | Size (KB) |' >> report.md
36+
echo '| --- | --- | --- |' >> report.md
37+
artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
38+
for artifact in $(cat target/powertools-parent-*.buildinfo | grep 'outputs.*.jar' | grep -v 'sources.jar'); do
39+
artifact_name=$(echo "$artifact" | cut -d '=' -f2)
40+
artifact_name=${artifact_name%-$artifact_version.jar}
41+
artifact_size=$(grep "${artifact%%.filename*}.length" target/powertools-parent-*.buildinfo | cut -d '=' -f2)
42+
printf "| %s | %s | %.2f |\n" "$artifact_name" "$artifact_version" "$(bc <<< "scale=2; $artifact_size/1000")" >> report.md
43+
done
44+
- name: Find potential existing report
45+
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # 2.4.0
46+
id: find-comment
47+
with:
48+
issue-number: ${{ github.event.pull_request.number }}
49+
comment-author: 'github-actions[bot]'
50+
body-includes: Artifacts Size Report
51+
- name: Write artifacts size report in comment
52+
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # 3.0.2
53+
with:
54+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
55+
issue-number: ${{ github.event.pull_request.number }}
56+
body-path: 'report.md'
57+
edit-mode: replace
File renamed without changes.

docs/core/logging.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ You can set a Correlation ID using `correlationIdPath` attribute by passing a [J
347347
"functionName": "test",
348348
"functionMemorySize": 128,
349349
"functionArn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
350-
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
350+
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
351351
"correlation_id": "correlation_id_value"
352352
}
353353
```
@@ -397,7 +397,7 @@ for known event sources, where either a request ID or X-Ray Trace ID are present
397397
"functionName": "test",
398398
"functionMemorySize": 128,
399399
"functionArn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
400-
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
400+
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
401401
"correlation_id": "correlation_id_value"
402402
}
403403
```
@@ -510,7 +510,7 @@ this means that custom keys can be persisted across invocations. If you want all
510510
"functionName": "test",
511511
"functionMemorySize": 128,
512512
"functionArn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
513-
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
513+
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
514514
"specialKey": "value"
515515
}
516516
```
@@ -527,7 +527,7 @@ this means that custom keys can be persisted across invocations. If you want all
527527
"functionName": "test",
528528
"functionMemorySize": 128,
529529
"functionArn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
530-
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72"
530+
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72"
531531
}
532532
```
533533

docs/stylesheets/extra.css

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
}
44

55
.highlight .hll {
6-
background-color: lavender
6+
[data-md-color-scheme="default"] {
7+
background-color: lavender;
8+
}
79
}
810

911
.md-typeset table:not([class]) {

examples/README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ Each example can be copied from its subdirectory and used independently of the r
55

66
## Examples
77

8-
* [powertools-examples-core-utilities](powertools-examples-core-utilities) - Demonstrates the core logging, tracing, and metrics modules with different build tools
9-
* [SAM](powertools-examples-core-utilities/sam)
10-
* [CDK](powertools-examples-core-utilities/cdk)
8+
* [powertools-examples-core](powertools-examples-core) - Demonstrates the core logging, tracing, and metrics modules with different build tools
9+
* [SAM](./powertools-examples-core/sam)
10+
* [CDK](./powertools-examples-core/cdk)
11+
* [Serverless](./powertools-examples-core/serverless)
1112
* [powertools-examples-idempotency](powertools-examples-idempotency) - An idempotent HTTP API
1213
* [powertools-examples-parameters](powertools-examples-parameters) - Uses the parameters module to provide runtime parameters to a function
1314
* [powertools-examples-serialization](powertools-examples-serialization) - Uses the serialization module to serialize and deserialize API Gateway & SQS payloads
@@ -54,7 +55,7 @@ The first command will build the source of your application. The second command
5455

5556
You can find your API Gateway Endpoint URL in the output values displayed after deployment.
5657

57-
If you're not using SAM, you can look for examples for other tools under [powertools-examples-core-utilities](./powertools-examples-core-utilities)
58+
If you're not using SAM, you can look for examples for other tools under [powertools-examples-core](./powertools-examples-core)
5859

5960
### External examples
6061

examples/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<module>powertools-examples-core-utilities/sam</module>
3333
<module>powertools-examples-core-utilities/cdk/app</module>
3434
<module>powertools-examples-core-utilities/cdk/infra</module>
35+
<module>powertools-examples-core-utilities/serverless</module>
3536
<module>powertools-examples-idempotency</module>
3637
<module>powertools-examples-parameters</module>
3738
<module>powertools-examples-serialization</module>

examples/powertools-examples-batch/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
<log4j.version>2.20.0</log4j.version>
1515
<maven.compiler.source>1.8</maven.compiler.source>
1616
<maven.compiler.target>1.8</maven.compiler.target>
17-
<sdk.version>2.20.133</sdk.version>
17+
<sdk.version>2.20.162</sdk.version>
1818
<aspectj.version>1.9.20</aspectj.version>
19+
1920
</properties>
2021

2122
<dependencies>

examples/powertools-examples-cloudformation/pom.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
<maven.compiler.source>1.8</maven.compiler.source>
1515
<maven.compiler.target>1.8</maven.compiler.target>
1616
<lambda.core.version>1.2.3</lambda.core.version>
17-
<lambda.events.version>3.11.2</lambda.events.version>
18-
<aws.sdk.version>2.20.136</aws.sdk.version>
17+
<lambda.events.version>3.11.3</lambda.events.version>
18+
<aws.sdk.version>2.20.162</aws.sdk.version>
1919
<aspectj.version>1.9.20</aspectj.version>
20+
2021
</properties>
2122
<dependencyManagement>
2223
<dependencies>

examples/powertools-examples-core-utilities/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ We provide examples for the following infrastructure-as-code tools:
99

1010
* [AWS SAM](sam/)
1111
* [AWS CDK](cdk/)
12+
* [Serverless framework](serverless/)
1213

1314
We also provide an example showing the integration of SAM, Powertools, and Gradle:
1415

15-
* [AWS SAM with a Gradle build](../powertools-examples-core-utilities/gradle/)
16+
* [AWS SAM with a Gradle build](gradle/)
1617

1718
For each of the tools, the example application is the same, and consists of the following files:
1819

examples/powertools-examples-core-utilities/cdk/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ For general information on the deployed example itself, you can refer to the par
66

77
## Configuration
88
CDK uses the following project structure:
9-
- [app](app) - stores the source code of your application, which is similar between all examples
10-
- [infra](infra) - stores the definition of your infrastructure
11-
- [cdk.json](infra/cdk.json) - tells the CDK Toolkit how to execute your app
12-
- [CdkApp](infra/src/main/java/cdk/CdkApp.java) - bootstraps your stack, taking AWS `account` and `region` as input
13-
- [CdkStack](infra/src/main/java/cdk/CdkStack.java) - defines the Lambda function to be deployed as well as API Gateway for it.
9+
- [app](./app) - stores the source code of your application, which is similar between all examples
10+
- [infra](./infra) - stores the definition of your infrastructure
11+
- [cdk.json](./infra/cdk.json) - tells the CDK Toolkit how to execute your app
12+
- [CdkApp](./infra/src/main/java/cdk/CdkApp.java) - bootstraps your stack, taking AWS `account` and `region` as input
13+
- [CdkStack](./infra/src/main/java/cdk/CdkStack.java) - defines the Lambda function to be deployed as well as API Gateway for it.
1414

1515
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.
1616

examples/powertools-examples-core-utilities/cdk/app/pom.xml

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
<modelVersion>4.0.0</modelVersion>
44

55
<groupId>software.amazon.lambda.examples</groupId>
6+
<!-- TODO TODO TODO this should build from SNAPSHOT, but it doesn't, because the snapshots
7+
don't appear in the docker environment CDK builds it in in our CDK tests. How to procede? V2 blocker -->
68
<version>1.17.0</version>
79
<artifactId>powertools-examples-core-utilities-cdk</artifactId>
810
<packaging>jar</packaging>
9-
10-
<name>Powertools for AWS Lambda (Java) library Examples - Core Utilities (logging, tracing, metrics) with CDK</name>
11+
<name>Powertools for AWS Lambda (Java) library Examples - Core</name>
1112

1213
<properties>
1314
<log4j.version>2.20.0</log4j.version>
@@ -40,7 +41,7 @@
4041
<dependency>
4142
<groupId>com.amazonaws</groupId>
4243
<artifactId>aws-lambda-java-events</artifactId>
43-
<version>3.11.2</version>
44+
<version>3.11.3</version>
4445
</dependency>
4546
<dependency>
4647
<groupId>org.apache.logging.log4j</groupId>
@@ -119,7 +120,8 @@
119120
</goals>
120121
<configuration>
121122
<transformers>
122-
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
123+
<transformer
124+
implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
123125
</transformers>
124126
</configuration>
125127
</execution>

examples/powertools-examples-core-utilities/gradle/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ You can also use `sam init` to create a new Gradle-powered Powertools applicatio
88
and then **Hello World Example with Powertools for AWS Lambda**, **Java 17** runtime, and finally **gradle**.
99

1010

11-
For general information on the deployed example itself, you can refer to the parent [README](../../powertools-examples-core/README.md)
11+
For general information on the deployed example itself, you can refer to the parent [README](../README.md)
1212

1313
## Configuration
1414
SAM uses [template.yaml](template.yaml) to define the application's AWS resources.

examples/powertools-examples-core-utilities/sam/pom.xml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

5+
<name>Powertools for AWS Lambda (Java) library Examples - Core Utilities (logging, tracing, metrics) with SAM</name>
56
<groupId>software.amazon.lambda.examples</groupId>
67
<version>2.0.0-SNAPSHOT</version>
78
<artifactId>powertools-examples-core-utilities-sam</artifactId>
89
<packaging>jar</packaging>
9-
10-
<name>Powertools for AWS Lambda (Java) library Examples - Core Utilities (logging, tracing, metrics) with SAM</name>
1110

1211
<properties>
1312
<log4j.version>2.20.0</log4j.version>
@@ -40,7 +39,7 @@
4039
<dependency>
4140
<groupId>com.amazonaws</groupId>
4241
<artifactId>aws-lambda-java-events</artifactId>
43-
<version>3.11.2</version>
42+
<version>3.11.3</version>
4443
</dependency>
4544
<dependency>
4645
<groupId>org.apache.logging.log4j</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Powertools for AWS Lambda (Java) - Core Utilities Example with Serverless Framework
2+
3+
This project demonstrates the Lambda for Powertools Java module deployed using [Serverless Framework](https://www.serverless.com/framework).
4+
For general information on the deployed example itself, you can refer to the parent [README](../README.md).
5+
To install Serverless Framework if you don't have it yet, you can follow the [Getting Started Guide](https://www.serverless.com/framework/docs/getting-started).
6+
7+
## Configuration
8+
Serverless Framework uses [serverless.yml](./serverless.yml) to define the application's AWS resources.
9+
This file defines the Lambda function to be deployed as well as API Gateway for it.
10+
11+
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.
12+
13+
14+
## Deploy the sample application
15+
16+
To deploy the app, simply run the following commands:
17+
```bash
18+
mvn package && sls deploy
19+
```
20+
21+
## Useful commands
22+
23+
Deploy a single function
24+
```bash
25+
sls deploy function -f hello
26+
```

0 commit comments

Comments
 (0)