From a5e5fe5cb749be72069b875291e98370839c3b2c Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Mon, 17 Jul 2023 16:33:18 +0200 Subject: [PATCH 01/14] Started cleaning up example doc --- examples/README.md | 34 ++++++++++++++++++- examples/powertools-examples-core/README.md | 27 ++------------- .../powertools-examples-idempotency/README.md | 25 +++++++------- .../src/main/java/helloworld/App.java | 23 ++++++++++--- 4 files changed, 66 insertions(+), 43 deletions(-) diff --git a/examples/README.md b/examples/README.md index f7e6fc620..bfce2d3df 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,4 +1,36 @@ ## aws-lambda-powertools-examples This directory holds example projects demoing different components of the Powertools for AWS Lambda (Java). -Each example can be copied from its subdirectory and used independently of the rest of this repository. \ No newline at end of file +Each example can be copied from its subdirectory and used independently of the rest of this repository. + +### Working with AWS Serverless Application Model (SAM) Examples +Many of the examples use [AWS Serverless Application Model](https://aws.amazon.com/serverless/sam/) (SAM). To get started +with them, you can use the SAM Command Line Interface (SAM CLI) to build it and deploy an example to AWS. + +To use the SAM CLI, you need the following tools. + +* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) +* Java11 - [Install the Java 11](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html) +* Maven - [Install Maven](https://maven.apache.org/install.html) +* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) + +To build and deploy an example application for the first time, run the following in your shell: + +```bash +# Switch to the directory containing an example for the powertools-core module +$ cd powertools-examples-core + +# Build and deploy the example +$ sam build +$ sam deploy --guided +``` + +The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts: + +* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. +* **AWS Region**: The AWS region you want to deploy your app to. +* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. +* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modified IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. +* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. + +You can find your API Gateway Endpoint URL in the output values displayed after deployment. diff --git a/examples/powertools-examples-core/README.md b/examples/powertools-examples-core/README.md index ba8859027..b887a29d4 100644 --- a/examples/powertools-examples-core/README.md +++ b/examples/powertools-examples-core/README.md @@ -19,31 +19,8 @@ The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI ## Deploy the sample application -The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. - -To use the SAM CLI, you need the following tools. - -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Java11 - [Install the Java 11](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html) -* Maven - [Install Maven](https://maven.apache.org/install.html) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) - -To build and deploy your application for the first time, run the following in your shell: - -```bash -Coreutilities$ sam build -Coreutilities$ sam deploy --guided -``` - -The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts: - -* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. -* **AWS Region**: The AWS region you want to deploy your app to. -* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. -* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modified IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. -* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. - -You can find your API Gateway Endpoint URL in the output values displayed after deployment. +This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting +started with SAM in [the examples directory](../README.md) ## Use the SAM CLI to build and test locally diff --git a/examples/powertools-examples-idempotency/README.md b/examples/powertools-examples-idempotency/README.md index 278484a92..fe7e379e8 100644 --- a/examples/powertools-examples-idempotency/README.md +++ b/examples/powertools-examples-idempotency/README.md @@ -1,21 +1,20 @@ # Idempotency This project contains an example of Lambda function using the idempotency module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/idempotency/). +The example exposes a HTTP POST endpoint. When the user sends the address of a webpage to it, the endpoint fetches the contents of the URL and returns them to the user: -## Deploy the sample application - -This sample is based on Serverless Application Model (SAM) and you can use the SAM Command Line Interface (SAM CLI) to build it and deploy it to AWS. +```bash + curl -X POST https://[REST-API-ID].execute-api.[REGION].amazonaws.com/Prod/helloidem/ -H "Content-Type: application/json" -d '{"address": "https://checkip.amazonaws.com"}' +``` -To use the SAM CLI, you need the following tools. +this should return the contents of the webpage, for instance: +```json +{ "message": "hello world", "location": "123.123.123.1" } +``` -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Java11 - [Install the Java 11](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html) -* Maven - [Install Maven](https://maven.apache.org/install.html) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) +Check out [App.java](src/main/java/helloworld/App.java) to see how it works! -To build and deploy your application for the first time, run the following in your shell: +## Deploy the sample application -```bash -Coreutilities$ sam build -Coreutilities$ sam deploy --guided -``` +This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting +started with SAM in [the examples directory](../README.md) \ No newline at end of file diff --git a/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java b/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java index f26877c34..eb7c31584 100644 --- a/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java +++ b/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java @@ -43,7 +43,11 @@ public App(DynamoDbClient client) { } /** - * Try with: + * This is our Lambda event handler. It accepts HTTP POST requests from API gateway and returns the contents of the given URL. Requests are made idempotent + * by the idempotency library, and results are cached for the default 1h expiry time. + * + * You can test the endpoint like this: + * *
      *     curl -X POST https://[REST-API-ID].execute-api.[REGION].amazonaws.com/Prod/helloidem/ -H "Content-Type: application/json" -d '{"address": "https://checkip.amazonaws.com"}'
      * 
@@ -52,7 +56,7 @@ public App(DynamoDbClient client) { *
  • Second call (and next ones) will retrieve from the cache (if cache is enabled, which is by default) or from the store, the handler won't be called. Until the expiration happens (by default 1 hour).
  • * */ - @Idempotent // *** THE MAGIC IS HERE *** + @Idempotent @Logging(logEvent = true) public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) { Map headers = new HashMap<>(); @@ -65,6 +69,7 @@ public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEv APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent() .withHeaders(headers); try { + // Read the 'address' field from the JSON post body String address = JsonConfig.get().getObjectMapper().readTree(input.getBody()).get("address").asText(); final String pageContents = this.getPageContents(address); String output = String.format("{ \"message\": \"hello world\", \"location\": \"%s\" }", pageContents); @@ -81,8 +86,18 @@ public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEv } } - // we could also put the @Idempotent annotation here, but using it on the handler avoids executing the handler (cost reduction). - // Use it on other methods to handle multiple items (with SQS batch processing for example) + + /** + * Helper to retrieve the contents of the given URL and return them as a string. + * + * We could also put the @Idempotent annotation here if we only wanted this sub-operation to be idempotent. Putting + * it on the handler, however, reduces total execution time and saves us time! + * + * @param address The URL to fetch + * @return The contents of the given URL + * + * @throws IOException + */ private String getPageContents(String address) throws IOException { URL url = new URL(address); try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"))) { From b97d5b75c3fdc945cb23b6bf9c958d25c356e176 Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Tue, 18 Jul 2023 15:00:53 +0200 Subject: [PATCH 02/14] More work --- examples/README.md | 31 ++++- examples/powertools-examples-core/README.md | 124 ++++-------------- .../powertools-examples-idempotency/README.md | 12 +- .../powertools-examples-parameters/README.md | 20 ++- .../template.yaml | 3 + 5 files changed, 74 insertions(+), 116 deletions(-) diff --git a/examples/README.md b/examples/README.md index bfce2d3df..48ee9edd7 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,11 +1,20 @@ -## aws-lambda-powertools-examples +# Lambda Powertools for Java Examples This directory holds example projects demoing different components of the Powertools for AWS Lambda (Java). Each example can be copied from its subdirectory and used independently of the rest of this repository. -### Working with AWS Serverless Application Model (SAM) Examples +## The Examples + +* [powertools-examples-core](powertools-examples-core) - Demonstrates the core logging, tracing, and metrics modules +* [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 +* [powertools-examples-sqs](powertools-examples-sqs) - Processes SQS batch requests +* [powertools-examples-validation](powertools-examples-validation) - Uses the validation module to validate user requests received via API Gateway + +## Working with AWS Serverless Application Model (SAM) Examples Many of the examples use [AWS Serverless Application Model](https://aws.amazon.com/serverless/sam/) (SAM). To get started -with them, you can use the SAM Command Line Interface (SAM CLI) to build it and deploy an example to AWS. +with them, you can use the SAM Command Line Interface (SAM CLI) to build it and deploy an example to AWS. To use the SAM CLI, you need the following tools. @@ -14,6 +23,12 @@ To use the SAM CLI, you need the following tools. * Maven - [Install Maven](https://maven.apache.org/install.html) * Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) +To learn more about SAM, +[check out the developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/using-sam-cli.html). +You can use the CLI to [test events locally](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/using-sam-cli-local-invoke.html), +and [run the application locally](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/using-sam-cli-local-start-api.html), +amongst other things. + To build and deploy an example application for the first time, run the following in your shell: ```bash @@ -34,3 +49,13 @@ The first command will build the source of your application. The second command * **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. You can find your API Gateway Endpoint URL in the output values displayed after deployment. + +### SAM - Other Tools + +If you prefer to use an integrated development environment (IDE) to build and test your application, you can use the AWS Toolkit. +The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI to build and deploy serverless applications on AWS. The AWS Toolkit also adds a simplified step-through debugging experience for Lambda function code. See the following links to get started. + +* [PyCharm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) +* [IntelliJ](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) +* [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html) +* [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html) \ No newline at end of file diff --git a/examples/powertools-examples-core/README.md b/examples/powertools-examples-core/README.md index b887a29d4..525122f74 100644 --- a/examples/powertools-examples-core/README.md +++ b/examples/powertools-examples-core/README.md @@ -1,115 +1,47 @@ -# CoreUtilities +# Lambda Powertools for Java - Core Utilities Example -This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes [Powertools for AWS Lambda (Java) for operational best practices](https://github.com/aws-powertools/powertools-lambda-java), and the following files and folders. +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/). -- HelloWorldFunction/src/main - Code for the application's Lambda function. -- events - Invocation events that you can use to invoke the function. -- HelloWorldFunction/src/test - Unit tests for the application code. -- template.yaml - A template that defines the application's AWS resources. +It is made up of the following: -The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. - -If you prefer to use an integrated development environment (IDE) to build and test your application, you can use the AWS Toolkit. -The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI to build and deploy serverless applications on AWS. The AWS Toolkit also adds a simplified step-through debugging experience for Lambda function code. See the following links to get started. - -* [PyCharm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [IntelliJ](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html) -* [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html) +- [App.java](src/main/java/helloworld/App.java) - Code for the application's Lambda function. +- [events](events) - Invocation events that you can use to invoke the function. +- [AppTests.java](src/test/java/helloworld/AppTest.java) - Unit tests for the application code. +- [template.yaml](template.yaml) - A template that defines the application's AWS resources. ## Deploy the sample application This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting started with SAM in [the examples directory](../README.md) -## Use the SAM CLI to build and test locally - -Build your application with the `sam build` command. - -```bash -Coreutilities$ sam build -``` - -The SAM CLI installs dependencies defined in `HelloWorldFunction/pom.xml`, creates a deployment package, and saves it in the `.aws-sam/build` folder. - -Test a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the `events` folder in this project. - -Run functions locally and invoke them with the `sam local invoke` command. - -```bash -Coreutilities$ sam local invoke HelloWorldFunction --event events/event.json -``` +## Test the application -The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000. +Once the app is deployed, you can invoke the endpoint like this: ```bash -Coreutilities$ sam local start-api -Coreutilities$ curl http://localhost:3000/ -``` - -The SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The `Events` property on each function's definition includes the route and method for each path. - -```yaml - Events: - HelloWorld: - Type: Api - Properties: - Path: /hello - Method: get + curl https://[REST-API-ID].execute-api.[REGION].amazonaws.com/Prod/hello/ ``` -## Add a resource to your application -The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. +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: -## Fetch, tail, and filter Lambda function logs +* **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 -To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. - -`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. +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](src/main/java/helloworld/App.java). +You can also watch the trace information or log information using the SAM CLI: ```bash -Coreutilities$ sam logs -n HelloWorldFunction --stack-name --tail -``` - -You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). - -## Unit tests - -Tests are defined in the `HelloWorldFunction/src/test` folder in this project. - -```bash -Coreutilities$ cd HelloWorldFunction -HelloWorldFunction$ mvn test -``` - -## Cleanup - -To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: - -```bash -aws cloudformation delete-stack --stack-name -``` - -# Appendix - -## Powertools - -**Tracing** - -[Tracing utility](https://docs.powertools.aws.dev/lambda-java/core/tracing/) provides functionality to reduce the overhead of performing common tracing tasks. It traces the execution of this sample code including the response and exceptions as tracing metadata - You can visualize them in AWS X-Ray. - -**Logger** - -[Logging utility](https://docs.powertools.aws.dev/lambda-java/core/logging/) creates an opinionated application Logger with structured logging as the output, dynamically samples a percentage (samplingRate) of your logs in DEBUG mode for concurrent invocations, log incoming events as your function is invoked, and injects key information from Lambda context object into your Logger - You can visualize them in Amazon CloudWatch Logs. - -**Metrics** - -[Metrics utility](https://docs.powertools.aws.dev/lambda-java/core/metrics/) captures cold start metric of your Lambda invocation, and could add additional metrics to help you understand your application KPIs - You can visualize them in Amazon CloudWatch. - -## Resources - -See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts. - -Check the [Powertools for AWS Lambda (Java)](https://docs.powertools.aws.dev/lambda-java/) for more information on how to use and configure such tools +# Tail the logs +sam logs --tail $MY_STACK_NAME -Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) +# Tail the traces +sam traces --tail +``` \ No newline at end of file diff --git a/examples/powertools-examples-idempotency/README.md b/examples/powertools-examples-idempotency/README.md index fe7e379e8..082027df9 100644 --- a/examples/powertools-examples-idempotency/README.md +++ b/examples/powertools-examples-idempotency/README.md @@ -3,6 +3,13 @@ This project contains an example of Lambda function using the idempotency module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/idempotency/). The example exposes a HTTP POST endpoint. When the user sends the address of a webpage to it, the endpoint fetches the contents of the URL and returns them to the user: +## Deploy the sample application + +This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting +started with SAM in [the examples directory](../README.md) + +## Test the application + ```bash curl -X POST https://[REST-API-ID].execute-api.[REGION].amazonaws.com/Prod/helloidem/ -H "Content-Type: application/json" -d '{"address": "https://checkip.amazonaws.com"}' ``` @@ -13,8 +20,3 @@ this should return the contents of the webpage, for instance: ``` Check out [App.java](src/main/java/helloworld/App.java) to see how it works! - -## Deploy the sample application - -This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting -started with SAM in [the examples directory](../README.md) \ No newline at end of file diff --git a/examples/powertools-examples-parameters/README.md b/examples/powertools-examples-parameters/README.md index 0f843d455..cdc5af118 100644 --- a/examples/powertools-examples-parameters/README.md +++ b/examples/powertools-examples-parameters/README.md @@ -2,20 +2,16 @@ This project contains an example of Lambda function using the parameters module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/parameters/). -## Deploy the sample application +The example uses the [SSM Parameter Store](https://docs.powertools.aws.dev/lambda/java/utilities/parameters/#ssm-parameter-store) +and the [Secrets Manager](https://docs.powertools.aws.dev/lambda/java/utilities/parameters/#secrets-manager) to inject +runtime parameters into the application. -This sample is based on Serverless Application Model (SAM) and you can use the SAM Command Line Interface (SAM CLI) to build it and deploy it to AWS. +Have a look at [ParametersFunction.java](src/main/java/org/demo/parameters/ParametersFunction.java) for the full details. -To use the SAM CLI, you need the following tools. +## Deploy the sample application -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Java11 - [Install the Java 11](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html) -* Maven - [Install Maven](https://maven.apache.org/install.html) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) +This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting +started with SAM in [the examples directory](../README.md) -To build and deploy your application for the first time, run the following in your shell: +## Test the application -```bash -sam build -sam deploy --guided -``` diff --git a/examples/powertools-examples-parameters/template.yaml b/examples/powertools-examples-parameters/template.yaml index 052cfcdc7..48d504e8a 100644 --- a/examples/powertools-examples-parameters/template.yaml +++ b/examples/powertools-examples-parameters/template.yaml @@ -19,6 +19,9 @@ Resources: Handler: org.demo.parameters.ParametersFunction::handleRequest MemorySize: 512 Tracing: Active +# Environment: +# Variables: +# LOG_LEVEL: INFO Policies: - AWSSecretsManagerGetSecretValuePolicy: SecretArn: !Ref UserPwd From 169030f536d8965fc894006d6e0d60ebf9964b80 Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Tue, 18 Jul 2023 15:36:44 +0200 Subject: [PATCH 03/14] More docs --- .../powertools-examples-parameters/README.md | 25 ++++++++++++++-- .../template.yaml | 6 ++-- .../README.md | 30 +++++++++++-------- 3 files changed, 44 insertions(+), 17 deletions(-) diff --git a/examples/powertools-examples-parameters/README.md b/examples/powertools-examples-parameters/README.md index cdc5af118..156ae5d6b 100644 --- a/examples/powertools-examples-parameters/README.md +++ b/examples/powertools-examples-parameters/README.md @@ -4,8 +4,7 @@ This project contains an example of Lambda function using the parameters module The example uses the [SSM Parameter Store](https://docs.powertools.aws.dev/lambda/java/utilities/parameters/#ssm-parameter-store) and the [Secrets Manager](https://docs.powertools.aws.dev/lambda/java/utilities/parameters/#secrets-manager) to inject -runtime parameters into the application. - +runtime parameters into the application. Have a look at [ParametersFunction.java](src/main/java/org/demo/parameters/ParametersFunction.java) for the full details. ## Deploy the sample application @@ -15,3 +14,25 @@ started with SAM in [the examples directory](../README.md) ## Test the application +First, hit the URL of the application. You can do this with curl or your browser: + +```bash + curl https://[REST-API-ID].execute-api.[REGION].amazonaws.com/Prod/params/ +``` +You will get your IP address back. The contents of the logs will be more interesting, and show you the values +of the parameters injected into the handler: + +```bash +sam logs --stack-name $MY_STACK_NAME --tail +``` + +```json +{ + ... + "thread": "main", + "level": "INFO", + "loggerName": "org.demo.parameters.ParametersFunction", + "message": "secretjsonobj=MyObject{id=23443, code='hk38543oj24kn796kp67bkb234gkj679l68'}\n", + ... +} +``` diff --git a/examples/powertools-examples-parameters/template.yaml b/examples/powertools-examples-parameters/template.yaml index 48d504e8a..9d3bf8b0e 100644 --- a/examples/powertools-examples-parameters/template.yaml +++ b/examples/powertools-examples-parameters/template.yaml @@ -19,9 +19,9 @@ Resources: Handler: org.demo.parameters.ParametersFunction::handleRequest MemorySize: 512 Tracing: Active -# Environment: -# Variables: -# LOG_LEVEL: INFO + Environment: + Variables: + LOG_LEVEL: INFO Policies: - AWSSecretsManagerGetSecretValuePolicy: SecretArn: !Ref UserPwd diff --git a/examples/powertools-examples-serialization/README.md b/examples/powertools-examples-serialization/README.md index 7f70da1f2..bbac33ae5 100644 --- a/examples/powertools-examples-serialization/README.md +++ b/examples/powertools-examples-serialization/README.md @@ -2,20 +2,26 @@ This project contains an example of Lambda function using the serialization utilities module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/serialization/). -## Deploy the sample application +The project contains two `RequestHandler`s - + +* [APIGatewayRequestDeserializationFunction](src/main/java/org/demo/serialization/APIGatewayRequestDeserializationFunction.java) - Uses the serialization library to deserialize an API Gateway request body +* [SQSEventDeserializationFunction](src/main/java/org/demo/serialization/SQSEventDeserializationFunction.java) - Uses the serialization library to deserialize an SQS message body + +In both cases, the output of the serialized message will be printed to the function logs. The message format +in JSON looks like this: -This sample is based on Serverless Application Model (SAM) and you can use the SAM Command Line Interface (SAM CLI) to build it and deploy it to AWS. +```json +{ + "id":1234, + "name":"product", + "price":42 +} +``` -To use the SAM CLI, you need the following tools. +## Deploy the sample application -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Java11 - [Install the Java 11](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html) -* Maven - [Install Maven](https://maven.apache.org/install.html) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) +This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting +started with SAM in [the examples directory](../README.md) -To build and deploy your application for the first time, run the following in your shell: +## Test the application -```bash -sam build -sam deploy --guided -``` From 86766c8ccd30db6bff55028322f878dcef7fcb5a Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Tue, 18 Jul 2023 16:10:36 +0200 Subject: [PATCH 04/14] More docs --- .../README.md | 50 +++++++++++++++++++ .../template.yaml | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/examples/powertools-examples-serialization/README.md b/examples/powertools-examples-serialization/README.md index bbac33ae5..595cbd1e4 100644 --- a/examples/powertools-examples-serialization/README.md +++ b/examples/powertools-examples-serialization/README.md @@ -25,3 +25,53 @@ started with SAM in [the examples directory](../README.md) ## Test the application +### 1. API Gateway Endpoint + +To test the HTTP endpoint, we can post a product to the test URL: + +```bash +curl -X POST https://[REST-API-ID].execute-api.[REGION].amazonaws.com/Prod/product/ -H "Content-Type: application/json" -d '{"id": 1234, "name": "product", "price": 42}' +``` + +The result will indicate that the handler has successfully deserialized the request body: + +``` +Received request for productId: 1234 +``` + +If we look at the logs using `sam logs --tail --stack-name $MY_STACK`, we will see the full deserialized request: + +```json +{ + ... + "level": "INFO", + "loggerName": "org.demo.serialization.APIGatewayRequestDeserializationFunction", + "message": "product=Product{id=1234, name='product', price=42.0}\n", + ... +} +``` + +### 2. SQS Queue +For the SQS handler, we have to send a request to our queue. We can either construct the Queue URL (see below), or +find it from the SQS section of the AWS console. + +```bash + aws sqs send-message --queue-url "https://sqs.[REGION].amazonaws.com/[ACCOUNT-ID]/sqs-event-deserialization-queue" --message-body '{"id": 1234, "name": "product", "price" +``` + +Here we can find the message by filtering through the logs for messages that have come back from our SQS handler: + +```bash +sam logs --tail --stack-name $MY_STACK --filter SQS +``` + +```bash + { + ... + "level": "INFO", + "loggerName": "org.demo.serialization.SQSEventDeserializationFunction", + "message": "products=[Product{id=1234, name='product', price=42.0}]\n", + ... +} + +``` diff --git a/examples/powertools-examples-serialization/template.yaml b/examples/powertools-examples-serialization/template.yaml index 539d2d615..f330ec146 100644 --- a/examples/powertools-examples-serialization/template.yaml +++ b/examples/powertools-examples-serialization/template.yaml @@ -32,7 +32,7 @@ Resources: SQSEventDeserializationFunction: Type: AWS::Serverless::Function Properties: - CodeUri: Function + CodeUri: . Handler: org.demo.serialization.SQSEventDeserializationFunction::handleRequest Policies: - Statement: From 97c6dea443b3df16ea52f4798e46888e51e7cd92 Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Tue, 18 Jul 2023 16:18:53 +0200 Subject: [PATCH 05/14] More docs --- examples/powertools-examples-idempotency/README.md | 2 +- examples/powertools-examples-parameters/README.md | 2 +- examples/powertools-examples-serialization/README.md | 2 +- examples/powertools-examples-sqs/README.md | 2 +- examples/powertools-examples-validation/README.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/powertools-examples-idempotency/README.md b/examples/powertools-examples-idempotency/README.md index 082027df9..4b1e72f72 100644 --- a/examples/powertools-examples-idempotency/README.md +++ b/examples/powertools-examples-idempotency/README.md @@ -1,4 +1,4 @@ -# Idempotency +# Lambda Powertools for Java - Idempotency Example This project contains an example of Lambda function using the idempotency module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/idempotency/). The example exposes a HTTP POST endpoint. When the user sends the address of a webpage to it, the endpoint fetches the contents of the URL and returns them to the user: diff --git a/examples/powertools-examples-parameters/README.md b/examples/powertools-examples-parameters/README.md index 156ae5d6b..a94a4010f 100644 --- a/examples/powertools-examples-parameters/README.md +++ b/examples/powertools-examples-parameters/README.md @@ -1,4 +1,4 @@ -# Parameters +# Lambda Powertools for Java - Parameters Example This project contains an example of Lambda function using the parameters module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/parameters/). diff --git a/examples/powertools-examples-serialization/README.md b/examples/powertools-examples-serialization/README.md index 595cbd1e4..5097a7485 100644 --- a/examples/powertools-examples-serialization/README.md +++ b/examples/powertools-examples-serialization/README.md @@ -1,4 +1,4 @@ -# Deserialization +# Lambda Powertools for Java - Serialization Example This project contains an example of Lambda function using the serialization utilities module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/serialization/). diff --git a/examples/powertools-examples-sqs/README.md b/examples/powertools-examples-sqs/README.md index 2b6da65b5..8b97af9fd 100644 --- a/examples/powertools-examples-sqs/README.md +++ b/examples/powertools-examples-sqs/README.md @@ -1,3 +1,3 @@ -## SqsBatchProcessingDemo +## Lambda Powertools for Java - SQS Batch Processing Example Demos setup of SQS Batch processing via Powertools diff --git a/examples/powertools-examples-validation/README.md b/examples/powertools-examples-validation/README.md index 39afc48b9..7e69f4d3b 100644 --- a/examples/powertools-examples-validation/README.md +++ b/examples/powertools-examples-validation/README.md @@ -1,4 +1,4 @@ -# Validation +# Lambda Powertools for Java - Validation Example This project contains an example of Lambda function using the validation module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/validation/). From d8d3380265e1b63ddff702887e0fd8505d8d2c56 Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Wed, 19 Jul 2023 13:10:20 +0200 Subject: [PATCH 06/14] Clean up SQS --- examples/powertools-examples-sqs/README.md | 55 ++++++++++++++++++- .../powertools-examples-validation/README.md | 19 ++----- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/examples/powertools-examples-sqs/README.md b/examples/powertools-examples-sqs/README.md index 8b97af9fd..cb705d50f 100644 --- a/examples/powertools-examples-sqs/README.md +++ b/examples/powertools-examples-sqs/README.md @@ -1,3 +1,56 @@ ## Lambda Powertools for Java - SQS Batch Processing Example -Demos setup of SQS Batch processing via Powertools +This project contains an example of Lambda function using the batch processing utilities module of Powertools for AWS Lambda (Java). +For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda/java/utilities/batch/). + +The project contains two functions: + +* [SqsMessageSender](src/main/java/org/demo/sqs/SqsMessageSender.java) - Sends a set of messages to an SQS queue. +This function is triggered every 5 minutes by an EventBridge schedule rule. +* [SqsPoller](src/main/java/org/demo/sqs/SqsPoller.java) - Listens to the same queue, processing items off in batches + +The poller intentionally fails intermittently processing messages to demonstrate the replay behaviour of the batch +module: + +
    + +SqsPoller.java + +[SqsPoller.java:43](src/main/java/org/demo/sqs/SqsPoller.java) + +```java + public String process(SQSMessage message) { + log.info("Processing message with id {}", message.getMessageId()); + + int nextInt = random.nextInt(100); + + if(nextInt <= 10) { + log.info("Randomly picked message with id {} as business validation failure.", message.getMessageId()); + throw new IllegalArgumentException("Failed business validation. No point of retrying. Move me to DLQ." + message.getMessageId()); + } + + if(nextInt > 90) { + log.info("Randomly picked message with id {} as intermittent failure.", message.getMessageId()); + throw new RuntimeException("Failed due to intermittent issue. Will be sent back for retry." + message.getMessageId()); + } + + return "Success"; + } +``` + +
    + +## Deploy the sample application + +This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting +started with SAM in [the examples directory](../README.md) + +## Test the application + +As the test is pushing through a batch every 5 minutes, we can simply watch the logs to see the batches being processed: + +```bash + sam logs --tail --stack-name $MY_STACK +``` + +As the handler intentionally introduces intermittent failures, we should expect to see error messages too! diff --git a/examples/powertools-examples-validation/README.md b/examples/powertools-examples-validation/README.md index 7e69f4d3b..8d9503ff7 100644 --- a/examples/powertools-examples-validation/README.md +++ b/examples/powertools-examples-validation/README.md @@ -1,21 +1,12 @@ # Lambda Powertools for Java - Validation Example -This project contains an example of Lambda function using the validation module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/validation/). +This project contains an example of Lambda function using the validation module of Powertools for AWS Lambda (Java). +For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/validation/). ## Deploy the sample application -This sample is based on Serverless Application Model (SAM) and you can use the SAM Command Line Interface (SAM CLI) to build it and deploy it to AWS. +This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting +started with SAM in [the examples directory](../README.md) -To use the SAM CLI, you need the following tools. +## Test the application -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Java11 - [Install the Java 11](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html) -* Maven - [Install Maven](https://maven.apache.org/install.html) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) - -To build and deploy your application for the first time, run the following in your shell: - -```bash -sam build -sam deploy --guided -``` From ca51238dfe2b6294818f0ad8e4c9be84d4664432 Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Wed, 19 Jul 2023 13:33:59 +0200 Subject: [PATCH 07/14] Did validationg --- examples/powertools-examples-validation/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/powertools-examples-validation/README.md b/examples/powertools-examples-validation/README.md index 8d9503ff7..b0f23251e 100644 --- a/examples/powertools-examples-validation/README.md +++ b/examples/powertools-examples-validation/README.md @@ -3,6 +3,9 @@ This project contains an example of Lambda function using the validation module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/validation/). +The handler [InboundValidation](src/main/java/org/demo/validation/InboundValidation.java) validates incoming HTTP requests +received from the API gateway against [schema.json](src/main/resources/schema.json). + ## Deploy the sample application This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting @@ -10,3 +13,14 @@ started with SAM in [the examples directory](../README.md) ## Test the application +To test the validation, we can POST a JSON object shaped like our schema: +```bash + curl -X POST https://[REST-API-ID].execute-api.[REGION].amazonaws.com/Prod/hello/ -H "Content-Type: application/json" -d '{"address": "https://checkip.amazonaws.com"}' +``` + +If we break the schema - for instance, by removing one of the compulsory fields, +we will get an error back from our API and will see a `ValidationException` in the logs: + +```bash + sam logs --tail --stack-name $MY_STACK +``` From 9fc7dc9ad69c48900afc45331adfa79a95f993ca Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Wed, 19 Jul 2023 13:56:39 +0200 Subject: [PATCH 08/14] Consistency --- examples/powertools-examples-core/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/powertools-examples-core/README.md b/examples/powertools-examples-core/README.md index 525122f74..393d0795d 100644 --- a/examples/powertools-examples-core/README.md +++ b/examples/powertools-examples-core/README.md @@ -40,7 +40,7 @@ and `ServerlessAirline`. The values in each of these are published by the code i You can also watch the trace information or log information using the SAM CLI: ```bash # Tail the logs -sam logs --tail $MY_STACK_NAME +sam logs --tail $MY_STACK # Tail the traces sam traces --tail From 47d98e1f2f8aa213dcfcf80e496ad25119504f97 Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Wed, 19 Jul 2023 14:46:50 +0200 Subject: [PATCH 09/14] Add CF --- examples/README.md | 1 + examples/powertools-examples-cloudformation/README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/README.md b/examples/README.md index 48ee9edd7..acbbe90df 100644 --- a/examples/README.md +++ b/examples/README.md @@ -11,6 +11,7 @@ Each example can be copied from its subdirectory and used independently of the r * [powertools-examples-serialization](powertools-examples-serialization) - Uses the serialization module to serialize and deserialize API Gateway & SQS payloads * [powertools-examples-sqs](powertools-examples-sqs) - Processes SQS batch requests * [powertools-examples-validation](powertools-examples-validation) - Uses the validation module to validate user requests received via API Gateway +* [powertools-examples-cloudformation](powertools-examples-cloudformation) - Deploys a Cloudformation custom resource ## Working with AWS Serverless Application Model (SAM) Examples Many of the examples use [AWS Serverless Application Model](https://aws.amazon.com/serverless/sam/) (SAM). To get started diff --git a/examples/powertools-examples-cloudformation/README.md b/examples/powertools-examples-cloudformation/README.md index 6dbffcf37..558033c8b 100644 --- a/examples/powertools-examples-cloudformation/README.md +++ b/examples/powertools-examples-cloudformation/README.md @@ -1,4 +1,4 @@ -# Cloudformation Custom Resource Example +# Lambda Powertools for Java - Cloudformation Custom Resource Example This project contains an example of Lambda function using the CloudFormation module of Powertools for AWS Lambda in Java. For more information on this module, please refer to the [documentation](https://awslabs.github.io/aws-lambda-powertools-java/utilities/custom_resources/). From 9663ac9fd5ab5c08ab0fef52e033a9db4c5cc27f Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Wed, 19 Jul 2023 14:49:00 +0200 Subject: [PATCH 10/14] More cleanp --- .../powertools-examples-cloudformation/README.md | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/examples/powertools-examples-cloudformation/README.md b/examples/powertools-examples-cloudformation/README.md index 558033c8b..76baeafb9 100644 --- a/examples/powertools-examples-cloudformation/README.md +++ b/examples/powertools-examples-cloudformation/README.md @@ -7,20 +7,7 @@ This project contains an example of Lambda function using the CloudFormation mod This sample can be used either with the Serverless Application Model (SAM) or with CDK. ### Deploy with SAM CLI -To use the SAM CLI, you need the following tools. - -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Java 8 - [Install Java 8](https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/downloads-list.html) -* Maven - [Install Maven](https://maven.apache.org/install.html) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) - -To build and deploy this application for the first time, run the following in your shell: - -```bash -cd infra/sam -sam build -sam deploy --guided --parameter-overrides BucketNameParam=my-unique-bucket-20230717 -``` +To deploy it using the SAM CLI, check out the instructions for getting started in [the examples directory](../README.md) ### Deploy with CDK To use CDK you need the following tools. From 609b2c5566ed8617f10cb1cb04fa74d91a87086d Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Wed, 19 Jul 2023 14:55:02 +0200 Subject: [PATCH 11/14] Add magic back --- .../src/main/java/helloworld/App.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java b/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java index eb7c31584..0a20aa3a4 100644 --- a/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java +++ b/examples/powertools-examples-idempotency/src/main/java/helloworld/App.java @@ -56,7 +56,7 @@ public App(DynamoDbClient client) { *
  • Second call (and next ones) will retrieve from the cache (if cache is enabled, which is by default) or from the store, the handler won't be called. Until the expiration happens (by default 1 hour).
  • * */ - @Idempotent + @Idempotent // The magic is here! @Logging(logEvent = true) public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) { Map headers = new HashMap<>(); From c7a86d1120b9a704b431a6443e810e3affbb7a26 Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Thu, 20 Jul 2023 11:07:41 +0200 Subject: [PATCH 12/14] Update examples/README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérôme Van Der Linden <117538+jeromevdl@users.noreply.github.com> --- examples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/README.md b/examples/README.md index acbbe90df..3b09fdde0 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,4 +1,4 @@ -# Lambda Powertools for Java Examples +# Powertools for AWS Lambda Java Examples This directory holds example projects demoing different components of the Powertools for AWS Lambda (Java). Each example can be copied from its subdirectory and used independently of the rest of this repository. From 6bb28d0577bceb35cbde71efc3c1f88cdfe8fff3 Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Thu, 20 Jul 2023 11:12:40 +0200 Subject: [PATCH 13/14] Fix naming --- docs/index.md | 2 +- examples/README.md | 2 +- examples/powertools-examples-cloudformation/README.md | 2 +- examples/powertools-examples-core/README.md | 2 +- examples/powertools-examples-idempotency/README.md | 2 +- examples/powertools-examples-parameters/README.md | 2 +- examples/powertools-examples-serialization/README.md | 2 +- examples/powertools-examples-sqs/README.md | 2 +- examples/powertools-examples-validation/README.md | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/index.md b/docs/index.md index f00e0314d..d3e487174 100644 --- a/docs/index.md +++ b/docs/index.md @@ -253,7 +253,7 @@ Depending on your version of Java (either Java 1.8 or 11+), the configuration sl ``` ???+ tip "Why a different configuration?" - Lambda Powertools for Java is using [AspectJ](https://eclipse.dev/aspectj/doc/released/progguide/starting.html) internally + Powertools for AWS Lambda (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, diff --git a/examples/README.md b/examples/README.md index acbbe90df..1869b4e8f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,4 +1,4 @@ -# Lambda Powertools for Java Examples +# Powertools for AWS Lambda (Java) Examples This directory holds example projects demoing different components of the Powertools for AWS Lambda (Java). Each example can be copied from its subdirectory and used independently of the rest of this repository. diff --git a/examples/powertools-examples-cloudformation/README.md b/examples/powertools-examples-cloudformation/README.md index 76baeafb9..4b53ff0aa 100644 --- a/examples/powertools-examples-cloudformation/README.md +++ b/examples/powertools-examples-cloudformation/README.md @@ -1,4 +1,4 @@ -# Lambda Powertools for Java - Cloudformation Custom Resource Example +# Powertools for AWS Lambda (Java) - Cloudformation Custom Resource Example This project contains an example of Lambda function using the CloudFormation module of Powertools for AWS Lambda in Java. For more information on this module, please refer to the [documentation](https://awslabs.github.io/aws-lambda-powertools-java/utilities/custom_resources/). diff --git a/examples/powertools-examples-core/README.md b/examples/powertools-examples-core/README.md index 393d0795d..a47d0d26c 100644 --- a/examples/powertools-examples-core/README.md +++ b/examples/powertools-examples-core/README.md @@ -1,4 +1,4 @@ -# Lambda Powertools for 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/), diff --git a/examples/powertools-examples-idempotency/README.md b/examples/powertools-examples-idempotency/README.md index 4b1e72f72..6f6022054 100644 --- a/examples/powertools-examples-idempotency/README.md +++ b/examples/powertools-examples-idempotency/README.md @@ -1,4 +1,4 @@ -# Lambda Powertools for Java - Idempotency Example +# Powertools for AWS Lambda (Java) - Idempotency Example This project contains an example of Lambda function using the idempotency module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/idempotency/). The example exposes a HTTP POST endpoint. When the user sends the address of a webpage to it, the endpoint fetches the contents of the URL and returns them to the user: diff --git a/examples/powertools-examples-parameters/README.md b/examples/powertools-examples-parameters/README.md index a94a4010f..a65307f69 100644 --- a/examples/powertools-examples-parameters/README.md +++ b/examples/powertools-examples-parameters/README.md @@ -1,4 +1,4 @@ -# Lambda Powertools for Java - Parameters Example +# Powertools for AWS Lambda (Java) - Parameters Example This project contains an example of Lambda function using the parameters module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/parameters/). diff --git a/examples/powertools-examples-serialization/README.md b/examples/powertools-examples-serialization/README.md index 5097a7485..60c5d3a35 100644 --- a/examples/powertools-examples-serialization/README.md +++ b/examples/powertools-examples-serialization/README.md @@ -1,4 +1,4 @@ -# Lambda Powertools for Java - Serialization Example +# Powertools for AWS Lambda (Java) - Serialization Example This project contains an example of Lambda function using the serialization utilities module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/serialization/). diff --git a/examples/powertools-examples-sqs/README.md b/examples/powertools-examples-sqs/README.md index cb705d50f..45f4a4a74 100644 --- a/examples/powertools-examples-sqs/README.md +++ b/examples/powertools-examples-sqs/README.md @@ -1,4 +1,4 @@ -## Lambda Powertools for Java - SQS Batch Processing Example +# Powertools for AWS Lambda (Java) - SQS Batch Processing Example This project contains an example of Lambda function using the batch processing utilities module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda/java/utilities/batch/). diff --git a/examples/powertools-examples-validation/README.md b/examples/powertools-examples-validation/README.md index b0f23251e..3f6790b0c 100644 --- a/examples/powertools-examples-validation/README.md +++ b/examples/powertools-examples-validation/README.md @@ -1,4 +1,4 @@ -# Lambda Powertools for Java - Validation Example +# Powertools for AWS Lambda (Java) - Validation Example This project contains an example of Lambda function using the validation module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/validation/). From 7beebfe6f3a8186ece92467e6a3c619c16a2cac9 Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Thu, 20 Jul 2023 11:33:43 +0200 Subject: [PATCH 14/14] fix syntax --- examples/powertools-examples-serialization/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/powertools-examples-serialization/README.md b/examples/powertools-examples-serialization/README.md index 60c5d3a35..4e3f66eb0 100644 --- a/examples/powertools-examples-serialization/README.md +++ b/examples/powertools-examples-serialization/README.md @@ -56,7 +56,7 @@ For the SQS handler, we have to send a request to our queue. We can either const find it from the SQS section of the AWS console. ```bash - aws sqs send-message --queue-url "https://sqs.[REGION].amazonaws.com/[ACCOUNT-ID]/sqs-event-deserialization-queue" --message-body '{"id": 1234, "name": "product", "price" + aws sqs send-message --queue-url "https://sqs.[REGION].amazonaws.com/[ACCOUNT-ID]/sqs-event-deserialization-queue" --message-body '{"id": 1234, "name": "product", "price": 123}' ``` Here we can find the message by filtering through the logs for messages that have come back from our SQS handler: