diff --git a/README.md b/README.md index fe6e9afba..d1f635a9c 100644 --- a/README.md +++ b/README.md @@ -13,24 +13,24 @@ Powertools for AWS Lambda (Java) is a developer toolkit to implement Serverless Powertools for AWS Lambda (Java) is available in Maven Central. You can use your favourite dependency management tool to install it -* [maven](https://maven.apache.org/): +#### Maven: ```xml ... software.amazon.lambda powertools-tracing - 1.17.0-SNAPSHOT + 1.16.0 software.amazon.lambda powertools-logging - 1.17.0-SNAPSHOT + 1.16.0 software.amazon.lambda powertools-metrics - 1.17.0-SNAPSHOT + 1.16.0 ... @@ -38,6 +38,7 @@ Powertools for AWS Lambda (Java) is available in Maven Central. You can use your And configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambda-powertools-java aspects into your project: +For Java 11+, use the following: ```xml @@ -78,6 +79,93 @@ And configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambd ``` +For Java 8, use the following: +```xml + + + ... + + org.codehaus.mojo + aspectj-maven-plugin + 1.14.0 + + 1.8 + 1.8 + 1.8 + + + software.amazon.lambda + powertools-logging + + + software.amazon.lambda + powertools-tracing + + + software.amazon.lambda + powertools-metrics + + + + + + + compile + + + + + ... + + +``` +#### gradle + +For Java 11+: + + ```groovy + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}' + aspect 'software.amazon.lambda:powertools-tracing:{{ powertools.version }}' + aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}' + } + + sourceCompatibility = 11 + targetCompatibility = 11 + ``` + +For Java8: + + ```groovy + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}' + aspect 'software.amazon.lambda:powertools-tracing:{{ powertools.version }}' + aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}' + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + ``` + + ## Example See the **[examples](examples)** directory for example projects showcasing usage of different utilities. diff --git a/docs/core/logging.md b/docs/core/logging.md index 1af206314..bf5fb6767 100644 --- a/docs/core/logging.md +++ b/docs/core/logging.md @@ -11,6 +11,141 @@ Logging provides an opinionated logger with output structured as JSON. * Log Lambda event when instructed, disabled by default, can be enabled explicitly via annotation param * Append additional keys to structured log at any point in time +## Install + +Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes. + +=== "Maven Java 11+" + + ```xml hl_lines="3-7 16 18 24-27" + + ... + + software.amazon.lambda + powertools-logging + {{ powertools.version }} + + ... + + ... + + + + ... + + dev.aspectj + aspectj-maven-plugin + 1.13.1 + + 11 + 11 + 11 + + + software.amazon.lambda + powertools-logging + + + + + + + compile + + + + + ... + + + ``` + +=== "Maven Java 1.8" + + ```xml hl_lines="3-7 16 18 24-27" + + ... + + software.amazon.lambda + powertools-logging + {{ powertools.version }} + + ... + + ... + + + + ... + + org.codehaus.mojo + aspectj-maven-plugin + 1.14.0 + + 1.8 + 1.8 + 1.8 + + + software.amazon.lambda + powertools-logging + + + + + + + compile + + + + + ... + + + ``` + +=== "Gradle Java 11+" + + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}' + } + + sourceCompatibility = 11 + targetCompatibility = 11 + ``` + +=== "Gradle Java 1.8" + + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}' + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + ``` + + ## Initialization Powertools for AWS Lambda (Java) extends the functionality of Log4J. Below is an example `#!xml log4j2.xml` file, with the `JsonTemplateLayout` using `#!json LambdaJsonLayout.json` configured. diff --git a/docs/core/metrics.md b/docs/core/metrics.md index f84508669..e06ab6d10 100644 --- a/docs/core/metrics.md +++ b/docs/core/metrics.md @@ -26,6 +26,139 @@ If you're new to Amazon CloudWatch, there are two terminologies you must be awar
Metric terminology, visually explained
+## Install + + Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes. + +=== "Maven Java 11+" + + ```xml hl_lines="3-7 16 18 24-27" + + ... + + software.amazon.lambda + powertools-metrics + {{ powertools.version }} + + ... + + ... + + + + ... + + dev.aspectj + aspectj-maven-plugin + 1.13.1 + + 11 + 11 + 11 + + + software.amazon.lambda + powertools-metrics + + + + + + + compile + + + + + ... + + + ``` + +=== "Maven Java 1.8" + + ```xml hl_lines="3-7 16 18 24-27" + + ... + + software.amazon.lambda + powertools-metrics + {{ powertools.version }} + + ... + + ... + + + + ... + + org.codehaus.mojo + aspectj-maven-plugin + 1.14.0 + + 1.8 + 1.8 + 1.8 + + + software.amazon.lambda + powertools-metrics + + + + + + + compile + + + + + ... + + + ``` + +=== "Gradle Java 11+" + + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}' + } + + sourceCompatibility = 11 + targetCompatibility = 11 + ``` + +=== "Gradle Java 1.8" + + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}' + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + ``` ## Getting started diff --git a/docs/core/tracing.md b/docs/core/tracing.md index 13d0be292..17e81b867 100644 --- a/docs/core/tracing.md +++ b/docs/core/tracing.md @@ -15,7 +15,142 @@ a provides functionality to reduce the overhead of performing common tracing tas * Better developer experience when developing with multiple threads. * Auto patch supported modules by AWS X-Ray -Initialization +## Install + +Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes. + +=== "Maven Java 11+" + + ```xml hl_lines="3-7 16 18 24-27" + + ... + + software.amazon.lambda + powertools-tracing + {{ powertools.version }} + + ... + + ... + + + + ... + + dev.aspectj + aspectj-maven-plugin + 1.13.1 + + 11 + 11 + 11 + + + software.amazon.lambda + powertools-tracing + + + + + + + compile + + + + + ... + + + ``` + +=== "Maven Java 1.8" + + ```xml hl_lines="3-7 16 18 24-27" + + ... + + software.amazon.lambda + powertools-tracing + {{ powertools.version }} + + ... + + ... + + + + ... + + org.codehaus.mojo + aspectj-maven-plugin + 1.14.0 + + 1.8 + 1.8 + 1.8 + + + software.amazon.lambda + powertools-tracing + + + + + + + compile + + + + + ... + + + ``` + +=== "Gradle Java 11+" + + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-tracing:{{ powertools.version }}' + } + + sourceCompatibility = 11 + targetCompatibility = 11 + ``` + +=== "Gradle Java 1.8" + + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-tracing:{{ powertools.version }}' + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + ``` + + +## Initialization Before your use this utility, your AWS Lambda function [must have permissions](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html#services-xray-permissions) to send traces to AWS X-Ray. diff --git a/docs/index.md b/docs/index.md index 4358b08f4..f00e0314d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -28,24 +28,63 @@ This project separates core utilities that will be available in other runtimes v ## Install -Powertools for AWS Lambda (Java) dependencies are available in Maven Central. You can use your favourite dependency management tool to install it - -* [Maven](https://maven.apache.org/) -* [Gradle](https://gradle.org) - -**Quick hello world examples using SAM CLI** +**Quick hello world example using SAM CLI** You can use [SAM](https://aws.amazon.com/serverless/sam/) to quickly setup a serverless project including Powertools for AWS Lambda (Java). ```bash - sam init --location gh:aws-samples/cookiecutter-aws-sam-powertools-java +sam init + +Which template source would you like to use? + 1 - AWS Quick Start Templates + 2 - Custom Template Location +Choice: 1 + +Choose an AWS Quick Start application template + 1 - Hello World Example + 2 - Data processing + 3 - Hello World Example with Powertools for AWS Lambda + 4 - Multi-step workflow + 5 - Scheduled task + 6 - Standalone function + 7 - Serverless API + 8 - Infrastructure event management + 9 - Lambda Response Streaming + 10 - Serverless Connector Hello World Example + 11 - Multi-step workflow with Connectors + 12 - Full Stack + 13 - Lambda EFS example + 14 - DynamoDB Example + 15 - Machine Learning +Template: 3 + +Which runtime would you like to use? + 1 - dotnet6 + 2 - java17 + 3 - java11 + 4 - java8.al2 + 5 - java8 + 6 - nodejs18.x + 7 - nodejs16.x + 8 - nodejs14.x + 9 - python3.9 + 10 - python3.8 + 11 - python3.7 + 12 - python3.10 +Runtime: 2, 3, 4 or 5 ``` -For more information about the project and available options refer to this [repository](https://github.com/aws-samples/cookiecutter-aws-sam-powertools-java/blob/main/README.md) +**Manual installation** +Powertools for AWS Lambda (Java) dependencies are available in Maven Central. You can use your favourite dependency management tool to install it -=== "Maven" +* [Maven](https://maven.apache.org/) +* [Gradle](https://gradle.org) - ```xml hl_lines="3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55" +Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes. + +=== "Maven Java 11+" + + ```xml ... @@ -74,6 +113,69 @@ For more information about the project and available options refer to this [repo dev.aspectj aspectj-maven-plugin 1.13.1 + + 11 + 11 + 11 + + + software.amazon.lambda + powertools-tracing + + + software.amazon.lambda + powertools-logging + + + software.amazon.lambda + powertools-metrics + + + + + + + compile + + + + + ... + + + ``` + +=== "Maven Java 1.8" + + ```xml + + ... + + software.amazon.lambda + powertools-tracing + {{ powertools.version }} + + + software.amazon.lambda + powertools-logging + {{ powertools.version }} + + + software.amazon.lambda + powertools-metrics + {{ powertools.version }} + + ... + + ... + + + + ... + + org.codehaus.mojo + aspectj-maven-plugin + 1.14.0 1.8 1.8 @@ -106,30 +208,57 @@ For more information about the project and available options refer to this [repo ``` -=== "Gradle" +=== "Gradle Java 11+" ```groovy - plugins{ - id 'java' - id 'io.freefair.aspectj.post-compile-weaving' version '6.3.0' - } - - repositories { - mavenCentral() - } - - dependencies { - aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}' - aspect 'software.amazon.lambda:powertools-tracing:{{ powertools.version }}' - aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}' -// This dependency is needed for Java17+, please uncomment it if you are using Java17+ -// implementation 'org.aspectj:aspectjrt:1.9.19' - } - - sourceCompatibility = 11 - targetCompatibility = 11 + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}' + aspect 'software.amazon.lambda:powertools-tracing:{{ powertools.version }}' + aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}' + } + + sourceCompatibility = 11 + targetCompatibility = 11 ``` +=== "Gradle Java 1.8" + + ```groovy + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}' + aspect 'software.amazon.lambda:powertools-tracing:{{ powertools.version }}' + aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}' + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + ``` + +???+ tip "Why a different configuration?" + Lambda Powertools for Java is using [AspectJ](https://eclipse.dev/aspectj/doc/released/progguide/starting.html) internally + to handle annotations. Recently, in order to support Java 17 we had to move to `dev.aspectj:aspectj-maven-plugin` because + `org.codehaus.mojo:aspectj-maven-plugin` does not support Java 17. + Under the hood, `org.codehaus.mojo:aspectj-maven-plugin` is based on AspectJ 1.9.7, + while `dev.aspectj:aspectj-maven-plugin` is based on AspectJ 1.9.8, compiled for Java 11+. + ## Environment variables !!! info diff --git a/docs/utilities/batch.md b/docs/utilities/batch.md index 0a2add081..c2072105d 100644 --- a/docs/utilities/batch.md +++ b/docs/utilities/batch.md @@ -23,10 +23,11 @@ are returned to the queue. ## Install -To install this utility, add the following dependency to your project. +Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes. -=== "Maven" - ```xml hl_lines="3 4 5 6 7 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36" +=== "Maven Java 11+" + + ```xml hl_lines="3-7 16 18 24-27"" ... @@ -36,6 +37,7 @@ To install this utility, add the following dependency to your project. ... + ... @@ -44,6 +46,51 @@ To install this utility, add the following dependency to your project. dev.aspectj aspectj-maven-plugin 1.13.1 + + 11 + 11 + 11 + + + software.amazon.lambda + powertools-sqs + + + + + + + compile + + + + + ... + + + ``` + +=== "Maven Java 1.8" + + ```xml hl_lines="3-7 16 18 24-27" + + ... + + software.amazon.lambda + powertools-sqs + {{ powertools.version }} + + ... + + ... + + + + ... + + org.codehaus.mojo + aspectj-maven-plugin + 1.14.0 1.8 1.8 @@ -68,24 +115,44 @@ To install this utility, add the following dependency to your project. ``` -=== "Gradle" +=== "Gradle Java 11+" - ```groovy - plugins{ - id 'java' - id 'io.freefair.aspectj.post-compile-weaving' version '6.3.0' - } + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-sqs:{{ powertools.version }}' + } + + sourceCompatibility = 11 // or higher + targetCompatibility = 11 // or higher + ``` - repositories { - mavenCentral() - } +=== "Gradle Java 1.8" - dependencies { - ... - aspect 'software.amazon.lambda:powertools-sqs:{{ powertools.version }}' -// This dependency is needed for Java17+, please uncomment it if you are using Java17+ -// implementation 'org.aspectj:aspectjrt:1.9.19' - } + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-sqs:{{ powertools.version }}' + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 ``` ## IAM Permissions diff --git a/docs/utilities/idempotency.md b/docs/utilities/idempotency.md index 2f4774c94..5392b8d4c 100644 --- a/docs/utilities/idempotency.md +++ b/docs/utilities/idempotency.md @@ -26,8 +26,11 @@ times with the same parameters**. This makes idempotent operations safe to retry ## Getting started ### Installation -=== "Maven" - ```xml hl_lines="3-7 24-27" +Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes. + +=== "Maven Java 11+" + + ```xml hl_lines="3-7 16 18 24-27" ... @@ -37,7 +40,7 @@ times with the same parameters**. This makes idempotent operations safe to retry ... - + ... @@ -46,6 +49,51 @@ times with the same parameters**. This makes idempotent operations safe to retry dev.aspectj aspectj-maven-plugin 1.13.1 + + 11 + 11 + 11 + + + software.amazon.lambda + powertools-idempotency + + + + + + + compile + + + + + ... + + + ``` + +=== "Maven Java 1.8" + + ```xml hl_lines="3-7 16 18 24-27" + + ... + + software.amazon.lambda + powertools-idempotency + {{ powertools.version }} + + ... + + ... + + + + ... + + org.codehaus.mojo + aspectj-maven-plugin + 1.14.0 1.8 1.8 @@ -55,7 +103,6 @@ times with the same parameters**. This makes idempotent operations safe to retry software.amazon.lambda powertools-idempotency - ... @@ -71,6 +118,46 @@ times with the same parameters**. This makes idempotent operations safe to retry ``` +=== "Gradle Java 11+" + + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-idempotency:{{ powertools.version }}' + } + + sourceCompatibility = 11 // or higher + targetCompatibility = 11 // or higher + ``` + +=== "Gradle Java 1.8" + + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-idempotency:{{ powertools.version }}' + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + ``` + ### Required resources Before getting started, you need to create a persistent storage layer where the idempotency utility can store its state - your Lambda functions will need read and write access to it. @@ -273,7 +360,7 @@ Imagine the function executes successfully, but the client never receives the re !!! warning "Warning: Idempotency for JSON payloads" The payload extracted by the `EventKeyJMESPath` is treated as a string by default, so will be sensitive to differences in whitespace even when the JSON payload itself is identical. - To alter this behaviour, you can use the [JMESPath built-in function](utilities.md#powertools_json-function) `powertools_json()` to treat the payload as a JSON object rather than a string. + To alter this behaviour, you can use the [JMESPath built-in function](serialization.md#jmespath-functions) `powertools_json()` to treat the payload as a JSON object rather than a string. === "PaymentFunction.java" diff --git a/docs/utilities/parameters.md b/docs/utilities/parameters.md index 7e70248d4..85d30d77e 100644 --- a/docs/utilities/parameters.md +++ b/docs/utilities/parameters.md @@ -16,27 +16,136 @@ It also provides a base class to create your parameter provider implementation. * Transform parameter values from JSON or base 64 encoded strings ## Install +Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes. -To install this utility, add the following dependency to your project. +=== "Maven Java 11+" -=== "Maven" - - ```xml - - software.amazon.lambda - powertools-parameters - {{ powertools.version }} - + ```xml hl_lines="3-7 16 18 24-27" + + ... + + software.amazon.lambda + powertools-parameters + {{ powertools.version }} + + ... + + ... + + + + ... + + dev.aspectj + aspectj-maven-plugin + 1.13.1 + + 11 + 11 + 11 + + + software.amazon.lambda + powertools-parameters + + + + + + + compile + + + + + ... + + ``` -=== "Gradle" - ```groovy - dependencies { +=== "Maven Java 1.8" + + ```xml hl_lines="3-7 16 18 24-27" + ... - aspect 'software.amazon.lambda:powertools-parameters:{{ powertools.version }}' -// This dependency is needed for Java17+, please uncomment it if you are using Java17+ -// implementation 'org.aspectj:aspectjrt:1.9.19' - } + + software.amazon.lambda + powertools-parameters + {{ powertools.version }} + + ... + + ... + + + + ... + + org.codehaus.mojo + aspectj-maven-plugin + 1.14.0 + + 1.8 + 1.8 + 1.8 + + + software.amazon.lambda + powertools-parameters + + + + + + + compile + + + + + ... + + + ``` + +=== "Gradle Java 11+" + + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-parameters:{{ powertools.version }}' + } + + sourceCompatibility = 11 // or higher + targetCompatibility = 11 // or higher + ``` + +=== "Gradle Java 1.8" + + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-parameters:{{ powertools.version }}' + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 ``` **IAM Permissions** diff --git a/docs/utilities/serialization.md b/docs/utilities/serialization.md index bd654393f..b47bdbd91 100644 --- a/docs/utilities/serialization.md +++ b/docs/utilities/serialization.md @@ -234,14 +234,14 @@ It can also handle a collection of elements like the records of an SQS event: | `APIGatewayV2HTTPEvent` | `body` | | | `SNSEvent` | `Records[0].Sns.Message` | | | `SQSEvent` | `Records[*].body` | x | - | `ScheduledEvent` | `detail` | | - | `ApplicationLoadBalancerRequestEvent` | `body` | | - | `CloudWatchLogsEvent` | `powertools_base64_gzip(data)` | | - | `CloudFormationCustomResourceEvent` | `resourceProperties` | | - | `KinesisEvent` | `Records[*].kinesis.powertools_base64(data)` | x | - | `KinesisFirehoseEvent` | `Records[*].powertools_base64(data)` | x | - | `KafkaEvent` | `records[*].values[*].powertools_base64(value)` | x | - | `ActiveMQEvent` | `messages[*].powertools_base64(data)` | x | +| `ScheduledEvent` | `detail` | | +| `ApplicationLoadBalancerRequestEvent` | `body` | | +| `CloudWatchLogsEvent` | `powertools_base64_gzip(data)` | | +| `CloudFormationCustomResourceEvent` | `resourceProperties` | | +| `KinesisEvent` | `Records[*].kinesis.powertools_base64(data)` | x | +| `KinesisFirehoseEvent` | `Records[*].powertools_base64(data)` | x | +| `KafkaEvent` | `records[*].values[*].powertools_base64(value)` | x | +| `ActiveMQEvent` | `messages[*].powertools_base64(data)` | x | | `RabbitMQEvent` | `rmqMessagesByQueue[*].values[*].powertools_base64(data)` | x | | `KinesisAnalyticsFirehoseInputPreprocessingEvent` | `Records[*].kinesis.powertools_base64(data)` | x | | `KinesisAnalyticsStreamsInputPreprocessingEvent` | `Records[*].kinesis.powertools_base64(data)` | x | diff --git a/docs/utilities/sqs_large_message_handling.md b/docs/utilities/sqs_large_message_handling.md index 5f7ede095..82e1afef4 100644 --- a/docs/utilities/sqs_large_message_handling.md +++ b/docs/utilities/sqs_large_message_handling.md @@ -30,11 +30,10 @@ This utility is compatible with versions *[1.1.0+](https://github.com/awslabs/am ``` ## Install +Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes. -To install this utility, add the following dependency to your project. - -=== "Maven" - ```xml hl_lines="3 4 5 6 7 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36" +=== "Maven Java 11+" + ```xml hl_lines="3-7 16 18 24-27" ... @@ -44,6 +43,7 @@ To install this utility, add the following dependency to your project. ... + ... @@ -52,6 +52,51 @@ To install this utility, add the following dependency to your project. dev.aspectj aspectj-maven-plugin 1.13.1 + + 11 + 11 + 11 + + + software.amazon.lambda + powertools-sqs + + + + + + + compile + + + + + ... + + + ``` + +=== "Maven Java 1.8" + + ```xml hl_lines="3-7 16 18 24-27" + + ... + + software.amazon.lambda + powertools-sqs + {{ powertools.version }} + + ... + + ... + + + + ... + + org.codehaus.mojo + aspectj-maven-plugin + 1.14.0 1.8 1.8 @@ -76,24 +121,44 @@ To install this utility, add the following dependency to your project. ``` -=== "Gradle" +=== "Gradle Java 11+" - ```groovy - plugins{ - id 'java' - id 'io.freefair.aspectj.post-compile-weaving' version '6.3.0' - } + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-sqs:{{ powertools.version }}' + } + + sourceCompatibility = 11 // or higher + targetCompatibility = 11 // or higher + ``` - repositories { - mavenCentral() - } +=== "Gradle Java 1.8" - dependencies { - ... - aspect 'software.amazon.lambda:powertools-sqs:{{ powertools.version }}' -// This dependency is needed for Java17+, please uncomment it if you are using Java17+ -// implementation 'org.aspectj:aspectjrt:1.9.19' - } + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-sqs:{{ powertools.version }}' + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 ``` ## Lambda handler diff --git a/docs/utilities/validation.md b/docs/utilities/validation.md index 8733c0e77..928ffb6c8 100644 --- a/docs/utilities/validation.md +++ b/docs/utilities/validation.md @@ -12,20 +12,20 @@ This utility provides JSON Schema validation for payloads held within events and * JMESPath support validate only a sub part of the event ## Install +Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes. -To install this utility, add the following dependency to your project. - -=== "Maven" - ```xml hl_lines="3 4 5 6 7 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36" +=== "Maven Java 11+" + ```xml hl_lines="3-7 16 18 24-27" - ... - - software.amazon.lambda - powertools-validation - {{ powertools.version }} - - ... + ... + + software.amazon.lambda + powertools-validation + {{ powertools.version }} + + ... + ... @@ -34,6 +34,51 @@ To install this utility, add the following dependency to your project. dev.aspectj aspectj-maven-plugin 1.13.1 + + 11 + 11 + 11 + + + software.amazon.lambda + powertools-validation + + + + + + + compile + + + + + ... + + + ``` + +=== "Maven Java 1.8" + + ```xml hl_lines="3-7 16 18 24-27" + + ... + + software.amazon.lambda + powertools-validation + {{ powertools.version }} + + ... + + ... + + + + ... + + org.codehaus.mojo + aspectj-maven-plugin + 1.14.0 1.8 1.8 @@ -58,25 +103,47 @@ To install this utility, add the following dependency to your project. ``` -=== "Gradle" +=== "Gradle Java 11+" - ```groovy - plugins{ - id 'java' - id 'io.freefair.aspectj.post-compile-weaving' version '6.3.0' - } + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-validation:{{ powertools.version }}' + } + + sourceCompatibility = 11 // or higher + targetCompatibility = 11 // or higher + ``` - repositories { - mavenCentral() - } +=== "Gradle Java 1.8" - dependencies { - aspect 'software.amazon.lambda:powertools-validation:{{ powertools.version }}' -// This dependency is needed for Java17+, please uncomment it if you are using Java17+ -// implementation 'org.aspectj:aspectjrt:1.9.19' - } + ```groovy hl_lines="3 11" + plugins { + id 'java' + id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3' + } + + repositories { + mavenCentral() + } + + dependencies { + aspect 'software.amazon.lambda:powertools-validation:{{ powertools.version }}' + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 ``` + ## Validating events You can validate inbound and outbound events using `@Validation` annotation. diff --git a/mkdocs.yml b/mkdocs.yml index b758239de..5fd3206b0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -83,7 +83,7 @@ extra_javascript: extra: powertools: - version: 1.17.0-SNAPSHOT + version: 1.16.0 # to update after each release (we do not want snapshot version here) repo_url: https://github.com/aws-powertools/powertools-lambda-java edit_uri: edit/main/docs