Skip to content

Commit

Permalink
merge v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromevdl committed Oct 18, 2023
2 parents 5a80c0c + c739383 commit 07c4381
Show file tree
Hide file tree
Showing 43 changed files with 809 additions and 1,045 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/pr_artifacts_size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Artifacts Size

on:
pull_request:
branches:
- master
paths:
- 'powertools-cloudformation/**'
- 'powertools-core/**'
- 'powertools-serialization/**'
- 'powertools-logging/**'
- 'powertools-sqs/**'
- 'powertools-tracing/**'
- 'powertools-validation/**'
- 'powertools-parameters/**'
- 'powertools-idempotency/**'
- 'powertools-metrics/**'
- 'pom.xml'
jobs:
codecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup java JDK 11
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
with:
distribution: 'corretto'
java-version: 11
- name: Build with Maven
run: mvn clean package --file pom.xml -DskipTests
- name: Get artifacts size & build report
id: artifacts-size-report
run: |
echo '## :floppy_disk: Artifacts Size Report' > report.md
echo '| Module | Version | Size (KB) |' >> report.md
echo '| --- | --- | --- |' >> report.md
artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
for artifact in $(cat target/powertools-parent-*.buildinfo | grep 'outputs.*.jar' | grep -v 'sources.jar'); do
artifact_name=$(echo "$artifact" | cut -d '=' -f2)
artifact_name=${artifact_name%-$artifact_version.jar}
artifact_size=$(grep "${artifact%%.filename*}.length" target/powertools-parent-*.buildinfo | cut -d '=' -f2)
printf "| %s | %s | %.2f |\n" "$artifact_name" "$artifact_version" "$(bc <<< "scale=2; $artifact_size/1000")" >> report.md
done
- name: Find potential existing report
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # 2.4.0
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Artifacts Size Report
- name: Write artifacts size report in comment
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # 3.0.2
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: 'report.md'
edit-mode: replace
File renamed without changes.
8 changes: 4 additions & 4 deletions docs/core/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ You can set a Correlation ID using `correlationIdPath` attribute by passing a [J
"function_name": "test",
"function_memory_size": 128,
"function_arn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
"correlation_id": "correlation_id_value"
}
```
Expand Down Expand Up @@ -397,7 +397,7 @@ for known event sources, where either a request ID or X-Ray Trace ID are present
"function_name": "test",
"function_memory_size": 128,
"function_arn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
"correlation_id": "correlation_id_value"
}
```
Expand Down Expand Up @@ -510,7 +510,7 @@ this means that custom keys can be persisted across invocations. If you want all
"function_name": "test",
"function_memory_size": 128,
"function_arn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
"specialKey": "value"
}
```
Expand All @@ -527,7 +527,7 @@ this means that custom keys can be persisted across invocations. If you want all
"function_name": "test",
"function_memory_size": 128,
"function_arn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72"
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72"
}
```

Expand Down
4 changes: 3 additions & 1 deletion docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
}

.highlight .hll {
background-color: lavender
[data-md-color-scheme="default"] {
background-color: lavender;
}
}

.md-typeset table:not([class]) {
Expand Down
9 changes: 5 additions & 4 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ Each example can be copied from its subdirectory and used independently of the r

## Examples

* [powertools-examples-core-utilities](powertools-examples-core-utilities) - Demonstrates the core logging, tracing, and metrics modules with different build tools
* [SAM](powertools-examples-core-utilities/sam)
* [CDK](powertools-examples-core-utilities/cdk)
* [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-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 Expand Up @@ -54,7 +55,7 @@ The first command will build the source of your application. The second command

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

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

### External examples

Expand Down
5 changes: 3 additions & 2 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@

<modules>
<module>powertools-examples-core-utilities/sam</module>
<!-- <module>powertools-examples-core-utilities/cdk/app</module>-->
<!-- <module>powertools-examples-core-utilities/cdk/infra</module>-->
<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-idempotency</module>
<module>powertools-examples-parameters</module>
<module>powertools-examples-serialization</module>
Expand Down
3 changes: 2 additions & 1 deletion examples/powertools-examples-batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
<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.133</sdk.version>
<sdk.version>2.20.162</sdk.version>
<aspectj.version>1.9.20</aspectj.version>

</properties>

<dependencies>
Expand Down
5 changes: 3 additions & 2 deletions examples/powertools-examples-cloudformation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<lambda.core.version>1.2.3</lambda.core.version>
<lambda.events.version>3.11.2</lambda.events.version>
<aws.sdk.version>2.20.136</aws.sdk.version>
<lambda.events.version>3.11.3</lambda.events.version>
<aws.sdk.version>2.20.162</aws.sdk.version>
<aspectj.version>1.9.20</aspectj.version>

</properties>
<dependencyManagement>
<dependencies>
Expand Down
3 changes: 2 additions & 1 deletion examples/powertools-examples-core-utilities/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ We provide examples for the following infrastructure-as-code tools:

* [AWS SAM](sam/)
* [AWS CDK](cdk/)
* [Serverless framework](serverless/)

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

* [AWS SAM with a Gradle build](../powertools-examples-core-utilities/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:

Expand Down
10 changes: 5 additions & 5 deletions examples/powertools-examples-core-utilities/cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ 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
- [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.
- [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.

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.

Expand Down
10 changes: 6 additions & 4 deletions examples/powertools-examples-core-utilities/cdk/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
<modelVersion>4.0.0</modelVersion>

<groupId>software.amazon.lambda.examples</groupId>
<!-- TODO TODO TODO this should build from SNAPSHOT, but it doesn't, because the snapshots
don't appear in the docker environment CDK builds it in in our CDK tests. How to procede? V2 blocker -->
<version>1.17.0</version>
<artifactId>powertools-examples-core-utilities-cdk</artifactId>
<packaging>jar</packaging>

<name>Powertools for AWS Lambda (Java) library Examples - Core Utilities (logging, tracing, metrics) with CDK</name>
<name>Powertools for AWS Lambda (Java) library Examples - Core</name>

<properties>
<log4j.version>2.20.0</log4j.version>
Expand Down Expand Up @@ -40,7 +41,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.11.2</version>
<version>3.11.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down Expand Up @@ -119,7 +120,8 @@
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
<transformer
implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
</transformers>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can also use `sam init` to create a new Gradle-powered Powertools applicatio
and then **Hello World Example with Powertools for AWS Lambda**, **Java 17** runtime, and finally **gradle**.


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

## Configuration
SAM uses [template.yaml](template.yaml) to define the application's AWS resources.
Expand Down
7 changes: 3 additions & 4 deletions examples/powertools-examples-core-utilities/sam/pom.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

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

<name>Powertools for AWS Lambda (Java) library Examples - Core Utilities (logging, tracing, metrics) with SAM</name>

<properties>
<log4j.version>2.20.0</log4j.version>
Expand Down Expand Up @@ -50,7 +49,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.11.2</version>
<version>3.11.3</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
Expand Down
26 changes: 26 additions & 0 deletions examples/powertools-examples-core-utilities/serverless/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Powertools for AWS Lambda (Java) - Core Utilities Example with Serverless Framework

This project demonstrates the Lambda for Powertools Java module deployed using [Serverless Framework](https://www.serverless.com/framework).
For general information on the deployed example itself, you can refer to the parent [README](../README.md).
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).

## Configuration
Serverless Framework uses [serverless.yml](./serverless.yml) to define the application's AWS resources.
This file defines the Lambda function to be deployed as well as API Gateway for it.

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.


## Deploy the sample application

To deploy the app, simply run the following commands:
```bash
mvn package && sls deploy
```

## Useful commands

Deploy a single function
```bash
sls deploy function -f hello
```
Loading

0 comments on commit 07c4381

Please sign in to comment.