Skip to content

Commit c79400d

Browse files
authored
Merge pull request #1492 from aws-powertools/main-into-v2-again
chore(v2): Merge main
2 parents c739383 + 327846f commit c79400d

File tree

59 files changed

+1512
-734
lines changed

Some content is hidden

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

59 files changed

+1512
-734
lines changed

.github/dependabot.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ updates:
33
- package-ecosystem: "maven"
44
directory: "/"
55
schedule:
6-
interval: "daily"
6+
interval: "weekly"
77
labels:
88
- "maven"
99
- "dependencies"
1010
ignore:
1111
# Ignore Mockito 5.X.X as it does not support Java 8
1212
- dependency-name: "org.mockito:mockito-*"
13-
update-types: ["version-update:semver-major"]
13+
update-types: ["version-update:semver-major"]

.github/workflows/pr_build.yml

+53-19
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ on:
66
- main
77
- v2
88
paths:
9+
- 'powertools-batch/**'
910
- 'powertools-cloudformation/**'
10-
- 'powertools-core/**'
11-
- 'powertools-serialization/**'
11+
- 'powertools-core/**' # not in v2
12+
- 'powertools-common/**' # v2 only
13+
- 'powertools-e2e-tests/**'
14+
- 'powertools-idempotency/**'
15+
- 'powertools-large-messages/**'
1216
- 'powertools-logging/**'
13-
- 'powertools-sqs/**'
17+
- 'powertools-metrics/**'
18+
- 'powertools-parameters/**'
19+
- 'powertools-serialization/**'
1420
- 'powertools-tracing/**'
1521
- 'powertools-validation/**'
16-
- 'powertools-idempotency/**'
17-
- 'powertools-parameters/**'
18-
- 'powertools-metrics/**'
19-
- 'powertools-test-suite/**'
20-
- 'powertools-e2e-tests/**'
2122
- 'examples/**'
2223
- 'pom.xml'
2324
- 'examples/pom.xml'
@@ -26,18 +27,18 @@ on:
2627
branches:
2728
- main
2829
paths:
30+
- 'powertools-batch/**'
2931
- 'powertools-cloudformation/**'
3032
- 'powertools-core/**'
33+
- 'powertools-e2e-tests/**'
34+
- 'powertools-idempotency/**'
35+
- 'powertools-large-messages/**'
36+
- 'powertools-metrics/**'
37+
- 'powertools-parameters/**'
3138
- 'powertools-serialization/**'
32-
- 'powertools-logging/**'
3339
- 'powertools-sqs/**'
3440
- 'powertools-tracing/**'
3541
- 'powertools-validation/**'
36-
- 'powertools-idempotency/**'
37-
- 'powertools-parameters/**'
38-
- 'powertools-metrics/**'
39-
- 'powertools-test-suite/**'
40-
- 'powertools-e2e-tests/**'
4142
- 'examples/**'
4243
- 'pom.xml'
4344
- 'examples/pom.xml'
@@ -48,11 +49,14 @@ jobs:
4849
strategy:
4950
max-parallel: 5
5051
matrix:
51-
java: [8, 11, 15, 16, 17, 18, 19, 20 ]
52+
java: [8, 11, 17, 21, 15, 16, 18, 19, 20]
5253
name: Java ${{ matrix.java }}
5354
env:
5455
JAVA: ${{ matrix.java }}
5556
AWS_REGION: eu-west-1
57+
permissions:
58+
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
59+
contents: read
5660
steps:
5761
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
5862
- name: Setup java
@@ -63,16 +67,46 @@ jobs:
6367
cache: 'maven'
6468
- name: Build with Maven
6569
run: mvn -B install --file pom.xml
66-
- name: Build Gradle Example
70+
- name: Build Gradle Example - Java
6771
if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8
72+
working-directory: examples/powertools-examples-core-utilities/gradle
73+
run: ./gradlew build
74+
- name: Build Gradle Example - Kotlin
75+
if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8
76+
working-directory: examples/powertools-examples-core-utilities/kotlin
77+
run: ./gradlew build
78+
- name: Setup Terraform
79+
if: ${{ matrix.java == '11' }}
80+
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 #v2.0.3
81+
- name: Setup AWS credentials
82+
if: ${{ matrix.java == '11' }}
83+
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
84+
with:
85+
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
86+
aws-region: ${{ env.AWS_REGION }}
87+
- name: Terraform validate
88+
working-directory: examples/powertools-examples-core-utilities/terraform
89+
if: ${{ matrix.java == '11' }}
90+
run: |
91+
terraform -version
92+
terraform init -backend=false
93+
terraform validate
94+
terraform plan
95+
- name: Setup Terraform lint
96+
if: ${{ matrix.java == '11' }}
97+
uses: terraform-linters/setup-tflint@a5a1af8c6551fb10c53f1cd4ba62359f1973746f # v3.1.1
98+
- name: Terraform lint
99+
working-directory: examples/powertools-examples-core-utilities/terraform
100+
if: ${{ matrix.java == '11' }}
68101
run: |
69-
cd examples/powertools-examples-core-utilities/gradle
70-
./gradlew build
102+
tflint --version
103+
tflint --init
104+
tflint -f compact
71105
- name: Upload coverage to Codecov
72106
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
73107
if: ${{ matrix.java == '11' }} # publish results once
74108
with:
75-
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
109+
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,./powertools-large-messages/target/site/jacoco/jacoco.xml,./powertools-batch/target/site/jacoco/jacoco.xml
76110
savepr:
77111
runs-on: ubuntu-latest
78112
name: Save PR number if running on PR by dependabot

.github/workflows/run-e2e-tests.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ on:
99
- v2
1010
paths: # add other modules when there are under e2e tests
1111
- 'powertools-e2e-tests/**'
12+
- 'powertools-batch/**'
1213
- 'powertools-core/**'
13-
- 'powertools-serialization/**'
14-
- 'powertools-logging/**'
15-
- 'powertools-tracing/**'
14+
- 'powertools-common/**'
1615
- 'powertools-idempotency/**'
17-
- 'powertools-parameters/**'
16+
- 'powertools-large-message/**'
17+
- 'powertools-logging/**'
1818
- 'powertools-metrics/**'
19-
- 'powertools-large-messages/**'
19+
- 'powertools-parameters/**'
20+
- 'powertools-serialization/**'
21+
- 'powertools-tracing/**'
2022
- 'pom.xml'
2123
- '.github/workflows/**'
2224

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,6 @@ example/HelloWorldFunction/build
108108
/example/.gradle/
109109
/example/.java-version
110110
.gradle
111-
build/
111+
build/
112+
.terraform*
113+
terraform.tfstate*

examples/README.md

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

66
## Examples
77

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)
8+
* [powertools-examples-core-utilities](powertools-examples-core-utilities) - Demonstrates the core logging, tracing, and metrics modules with different build tools and languages
9+
* [CDK](./powertools-examples-core-utilities/cdk)
10+
* [Gradle](./powertools-examples-core-utilities/gradle)
11+
* [SAM](./powertools-examples-core-utilities/sam)
12+
* [Serverless](./powertools-examples-core-utilities/serverless)
13+
* [Kotlin](./powertools-examples-core-utilities/kotlin)
1214
* [powertools-examples-idempotency](powertools-examples-idempotency) - An idempotent HTTP API
1315
* [powertools-examples-parameters](powertools-examples-parameters) - Uses the parameters module to provide runtime parameters to a function
1416
* [powertools-examples-serialization](powertools-examples-serialization) - Uses the serialization module to serialize and deserialize API Gateway & SQS payloads

examples/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<module>powertools-examples-core-utilities/cdk/app</module>
3434
<module>powertools-examples-core-utilities/cdk/infra</module>
3535
<module>powertools-examples-core-utilities/serverless</module>
36+
<module>powertools-examples-core-utilities/terraform</module>
3637
<module>powertools-examples-idempotency</module>
3738
<module>powertools-examples-parameters</module>
3839
<module>powertools-examples-serialization</module>

examples/powertools-examples-batch/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
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.162</sdk.version>
1817
<aspectj.version>1.9.20</aspectj.version>
19-
18+
<sdk.version>2.21.1</sdk.version>
2019
</properties>
2120

2221
<dependencies>
@@ -119,6 +118,7 @@
119118
<goal>shade</goal>
120119
</goals>
121120
<configuration>
121+
<createDependencyReducedPom>false</createDependencyReducedPom>
122122
<transformers>
123123
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
124124
</transformers>

examples/powertools-examples-cloudformation/pom.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<maven.compiler.target>1.8</maven.compiler.target>
1616
<lambda.core.version>1.2.3</lambda.core.version>
1717
<lambda.events.version>3.11.3</lambda.events.version>
18-
<aws.sdk.version>2.20.162</aws.sdk.version>
18+
<aws.sdk.version>2.21.0</aws.sdk.version>
1919
<aspectj.version>1.9.20</aspectj.version>
2020

2121
</properties>
@@ -96,6 +96,9 @@
9696
<artifactId>log4j-jcl</artifactId>
9797
<version>${log4j.version}</version>
9898
</dependency>
99+
100+
101+
99102
</dependencies>
100103

101104
<build>
@@ -141,6 +144,7 @@
141144
<goal>shade</goal>
142145
</goals>
143146
<configuration>
147+
<createDependencyReducedPom>false</createDependencyReducedPom>
144148
<transformers>
145149
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
146150
</transformers>
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1-
# Powertools for AWS Lambda (Java) - Core Utilities Example
1+
# Powertools for AWS Lambda (Java) - Core Utilities Example
22

33
This project demonstrates the Lambda for Powertools Java module - including
44
[logging](https://docs.powertools.aws.dev/lambda/java/core/logging/),
55
[tracing](https://docs.powertools.aws.dev/lambda/java/core/tracing/), and
66
[metrics](https://docs.powertools.aws.dev/lambda/java/core/metrics/).
77

8-
We provide examples for the following infrastructure-as-code tools:
8+
The example application is the same, and you can now also use Kotlin!
99

10+
## Java
1011
* [AWS SAM](sam/)
1112
* [AWS CDK](cdk/)
1213
* [Serverless framework](serverless/)
14+
* [Terraform](terraform/)
1315

1416
We also provide an example showing the integration of SAM, Powertools, and Gradle:
1517

1618
* [AWS SAM with a Gradle build](gradle/)
1719

18-
For each of the tools, the example application is the same, and consists of the following files:
20+
- App.java - Code for the application's Lambda function.
21+
- AppTests.java - Unit tests for the application code.
22+
- events - Invocation events that you can use to invoke the function.
1923

20-
- [App.java](sam/src/main/java/helloworld/App.java) - Code for the application's Lambda function.
21-
- [AppTests.java](sam/src/test/java/helloworld/AppTest.java) - Unit tests for the application code.
22-
- [events](sam/events/event.json) - Invocation events that you can use to invoke the function.
24+
Configuration files and deployment process for each tool are described in corresponding README files.
25+
26+
## Kotlin
27+
28+
- [Gradle](kotlin/)
29+
30+
Example application consists of the following files:
31+
32+
- App.kt - Code for the application's Lambda function.
33+
- AppTests.kt - Unit tests for the application code.
34+
- events - Invocation events that you can use to invoke the function.
2335

2436
Configuration files and deployment process for each tool are described in corresponding README files.
2537

@@ -31,14 +43,13 @@ Once the app is deployed, you can invoke the endpoint like this:
3143
curl https://[REST-API-ID].execute-api.[REGION].amazonaws.com/Prod/hello/
3244
```
3345

34-
The response itself isn't particularly interesting - you will get back some information about your IP address. If
46+
The response itself isn't particularly interesting - you will get back some information about your IP address. If
3547
you go to the Lambda Console and locate the lambda you have deployed, then click the "Monitoring" tab you will
3648
be able to find:
3749

38-
* **View X-Ray traces** - Display the traces captured by the traces module. These include subsegments for the
39-
different function calls within the example
40-
* **View Cloudwatch logs** - Display the structured logging output of the example
50+
- **View X-Ray traces** - Display the traces captured by the traces module. These include subsegments for the
51+
different function calls within the example
52+
- **View Cloudwatch logs** - Display the structured logging output of the example
4153

42-
Likewise, from the CloudWatch dashboard, under **Metrics**, **all metrics**, you will find the namespaces `Another`
43-
and `ServerlessAirline`. The values in each of these are published by the code in
44-
[App.java](sam/src/main/java/helloworld/App.java).
54+
Likewise, from the CloudWatch dashboard, under **Metrics**, **all metrics**, you will find the namespaces `Another`
55+
and `ServerlessAirline`. The values in each of these are published by the code in the respective application's Lambda function.

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ 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
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
1212
- [CdkApp](./infra/src/main/java/cdk/CdkApp.java) - bootstraps your stack, taking AWS `account` and `region` as input
1313
- [CdkStack](./infra/src/main/java/cdk/CdkStack.java) - defines the Lambda function to be deployed as well as API Gateway for it.
1414

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

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
<goal>shade</goal>
120120
</goals>
121121
<configuration>
122+
<createDependencyReducedPom>false</createDependencyReducedPom>
122123
<transformers>
123124
<transformer
124125
implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>

examples/powertools-examples-core-utilities/cdk/app/src/test/java/helloworld/AppTest.java

-59
This file was deleted.

examples/powertools-examples-core-utilities/gradle/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ dependencies {
3030
aspect 'software.amazon.lambda:powertools-tracing:1.17.0'
3131
aspect 'software.amazon.lambda:powertools-logging:1.17.0'
3232
aspect 'software.amazon.lambda:powertools-metrics:1.17.0'
33-
testImplementation 'junit:junit:4.13.2'
3433
}
3534

0 commit comments

Comments
 (0)