Skip to content

chore(v2): Merge main #1492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
labels:
- "maven"
- "dependencies"
ignore:
# Ignore Mockito 5.X.X as it does not support Java 8
- dependency-name: "org.mockito:mockito-*"
update-types: ["version-update:semver-major"]
update-types: ["version-update:semver-major"]
72 changes: 53 additions & 19 deletions .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ on:
- main
- v2
paths:
- 'powertools-batch/**'
- 'powertools-cloudformation/**'
- 'powertools-core/**'
- 'powertools-serialization/**'
- 'powertools-core/**' # not in v2
- 'powertools-common/**' # v2 only
- 'powertools-e2e-tests/**'
- 'powertools-idempotency/**'
- 'powertools-large-messages/**'
- 'powertools-logging/**'
- 'powertools-sqs/**'
- 'powertools-metrics/**'
- 'powertools-parameters/**'
- 'powertools-serialization/**'
- 'powertools-tracing/**'
- 'powertools-validation/**'
- 'powertools-idempotency/**'
- 'powertools-parameters/**'
- 'powertools-metrics/**'
- 'powertools-test-suite/**'
- 'powertools-e2e-tests/**'
- 'examples/**'
- 'pom.xml'
- 'examples/pom.xml'
Expand All @@ -26,18 +27,18 @@ on:
branches:
- main
paths:
- 'powertools-batch/**'
- 'powertools-cloudformation/**'
- 'powertools-core/**'
- 'powertools-e2e-tests/**'
- 'powertools-idempotency/**'
- 'powertools-large-messages/**'
- 'powertools-metrics/**'
- 'powertools-parameters/**'
- 'powertools-serialization/**'
- 'powertools-logging/**'
- 'powertools-sqs/**'
- 'powertools-tracing/**'
- 'powertools-validation/**'
- 'powertools-idempotency/**'
- 'powertools-parameters/**'
- 'powertools-metrics/**'
- 'powertools-test-suite/**'
- 'powertools-e2e-tests/**'
- 'examples/**'
- 'pom.xml'
- 'examples/pom.xml'
Expand All @@ -48,11 +49,14 @@ jobs:
strategy:
max-parallel: 5
matrix:
java: [8, 11, 15, 16, 17, 18, 19, 20 ]
java: [8, 11, 17, 21, 15, 16, 18, 19, 20]
name: Java ${{ matrix.java }}
env:
JAVA: ${{ matrix.java }}
AWS_REGION: eu-west-1
permissions:
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
contents: read
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup java
Expand All @@ -63,16 +67,46 @@ jobs:
cache: 'maven'
- name: Build with Maven
run: mvn -B install --file pom.xml
- name: Build Gradle Example
- name: Build Gradle Example - Java
if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8
working-directory: examples/powertools-examples-core-utilities/gradle
run: ./gradlew build
- name: Build Gradle Example - Kotlin
if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8
working-directory: examples/powertools-examples-core-utilities/kotlin
run: ./gradlew build
- name: Setup Terraform
if: ${{ matrix.java == '11' }}
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 #v2.0.3
- name: Setup AWS credentials
if: ${{ matrix.java == '11' }}
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
aws-region: ${{ env.AWS_REGION }}
- name: Terraform validate
working-directory: examples/powertools-examples-core-utilities/terraform
if: ${{ matrix.java == '11' }}
run: |
terraform -version
terraform init -backend=false
terraform validate
terraform plan
- name: Setup Terraform lint
if: ${{ matrix.java == '11' }}
uses: terraform-linters/setup-tflint@a5a1af8c6551fb10c53f1cd4ba62359f1973746f # v3.1.1
- name: Terraform lint
working-directory: examples/powertools-examples-core-utilities/terraform
if: ${{ matrix.java == '11' }}
run: |
cd examples/powertools-examples-core-utilities/gradle
./gradlew build
tflint --version
tflint --init
tflint -f compact
- name: Upload coverage to Codecov
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
if: ${{ matrix.java == '11' }} # publish results once
with:
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
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
savepr:
runs-on: ubuntu-latest
name: Save PR number if running on PR by dependabot
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/run-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ on:
- v2
paths: # add other modules when there are under e2e tests
- 'powertools-e2e-tests/**'
- 'powertools-batch/**'
- 'powertools-core/**'
- 'powertools-serialization/**'
- 'powertools-logging/**'
- 'powertools-tracing/**'
- 'powertools-common/**'
- 'powertools-idempotency/**'
- 'powertools-parameters/**'
- 'powertools-large-message/**'
- 'powertools-logging/**'
- 'powertools-metrics/**'
- 'powertools-large-messages/**'
- 'powertools-parameters/**'
- 'powertools-serialization/**'
- 'powertools-tracing/**'
- 'pom.xml'
- '.github/workflows/**'

Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,6 @@ example/HelloWorldFunction/build
/example/.gradle/
/example/.java-version
.gradle
build/
build/
.terraform*
terraform.tfstate*
10 changes: 6 additions & 4 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ Each example can be copied from its subdirectory and used independently of the r

## Examples

* [powertools-examples-core](powertools-examples-core) - Demonstrates the core logging, tracing, and metrics modules with different build tools
* [SAM](./powertools-examples-core/sam)
* [CDK](./powertools-examples-core/cdk)
* [Serverless](./powertools-examples-core/serverless)
* [powertools-examples-core-utilities](powertools-examples-core-utilities) - Demonstrates the core logging, tracing, and metrics modules with different build tools and languages
* [CDK](./powertools-examples-core-utilities/cdk)
* [Gradle](./powertools-examples-core-utilities/gradle)
* [SAM](./powertools-examples-core-utilities/sam)
* [Serverless](./powertools-examples-core-utilities/serverless)
* [Kotlin](./powertools-examples-core-utilities/kotlin)
* [powertools-examples-idempotency](powertools-examples-idempotency) - An idempotent HTTP API
* [powertools-examples-parameters](powertools-examples-parameters) - Uses the parameters module to provide runtime parameters to a function
* [powertools-examples-serialization](powertools-examples-serialization) - Uses the serialization module to serialize and deserialize API Gateway & SQS payloads
Expand Down
1 change: 1 addition & 0 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<module>powertools-examples-core-utilities/cdk/app</module>
<module>powertools-examples-core-utilities/cdk/infra</module>
<module>powertools-examples-core-utilities/serverless</module>
<module>powertools-examples-core-utilities/terraform</module>
<module>powertools-examples-idempotency</module>
<module>powertools-examples-parameters</module>
<module>powertools-examples-serialization</module>
Expand Down
4 changes: 2 additions & 2 deletions examples/powertools-examples-batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
<log4j.version>2.20.0</log4j.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<sdk.version>2.20.162</sdk.version>
<aspectj.version>1.9.20</aspectj.version>

<sdk.version>2.21.1</sdk.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -119,6 +118,7 @@
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
</transformers>
Expand Down
6 changes: 5 additions & 1 deletion examples/powertools-examples-cloudformation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<lambda.core.version>1.2.3</lambda.core.version>
<lambda.events.version>3.11.3</lambda.events.version>
<aws.sdk.version>2.20.162</aws.sdk.version>
<aws.sdk.version>2.21.0</aws.sdk.version>
<aspectj.version>1.9.20</aspectj.version>

</properties>
Expand Down Expand Up @@ -96,6 +96,9 @@
<artifactId>log4j-jcl</artifactId>
<version>${log4j.version}</version>
</dependency>



</dependencies>

<build>
Expand Down Expand Up @@ -141,6 +144,7 @@
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
</transformers>
Expand Down
37 changes: 24 additions & 13 deletions examples/powertools-examples-core-utilities/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
# Powertools for AWS Lambda (Java) - Core Utilities Example
# Powertools for AWS Lambda (Java) - Core Utilities Example

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

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

## Java
* [AWS SAM](sam/)
* [AWS CDK](cdk/)
* [Serverless framework](serverless/)
* [Terraform](terraform/)

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

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

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

- [App.java](sam/src/main/java/helloworld/App.java) - Code for the application's Lambda function.
- [AppTests.java](sam/src/test/java/helloworld/AppTest.java) - Unit tests for the application code.
- [events](sam/events/event.json) - Invocation events that you can use to invoke the function.
Configuration files and deployment process for each tool are described in corresponding README files.

## Kotlin

- [Gradle](kotlin/)

Example application consists of the following files:

- App.kt - Code for the application's Lambda function.
- AppTests.kt - Unit tests for the application code.
- events - Invocation events that you can use to invoke the function.

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

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

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

* **View X-Ray traces** - Display the traces captured by the traces module. These include subsegments for the
different function calls within the example
* **View Cloudwatch logs** - Display the structured logging output of the example
- **View X-Ray traces** - Display the traces captured by the traces module. These include subsegments for the
different function calls within the example
- **View Cloudwatch logs** - Display the structured logging output of the example

Likewise, from the CloudWatch dashboard, under **Metrics**, **all metrics**, you will find the namespaces `Another`
and `ServerlessAirline`. The values in each of these are published by the code in
[App.java](sam/src/main/java/helloworld/App.java).
Likewise, from the CloudWatch dashboard, under **Metrics**, **all metrics**, you will find the namespaces `Another`
and `ServerlessAirline`. The values in each of these are published by the code in the respective application's Lambda function.
6 changes: 3 additions & 3 deletions examples/powertools-examples-core-utilities/cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ For general information on the deployed example itself, you can refer to the par

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer
implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ dependencies {
aspect 'software.amazon.lambda:powertools-tracing:1.17.0'
aspect 'software.amazon.lambda:powertools-logging:1.17.0'
aspect 'software.amazon.lambda:powertools-metrics:1.17.0'
testImplementation 'junit:junit:4.13.2'
}

Loading