-
Notifications
You must be signed in to change notification settings - Fork 90
docs: Started cleaning up example doc #1291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a5e5fe5
Started cleaning up example doc
scottgerring b97d5b7
More work
scottgerring 169030f
More docs
scottgerring 86766c8
More docs
scottgerring 97c6dea
More docs
scottgerring 42ae2f6
Merge remote-tracking branch 'origin/main' into example-docs
scottgerring d8d3380
Clean up SQS
scottgerring ca51238
Did validationg
scottgerring 9fc7dc9
Consistency
scottgerring 47d98e1
Add CF
scottgerring 9663ac9
More cleanp
scottgerring 603ca6d
Merge branch 'main' into example-docs
scottgerring 609b2c5
Add magic back
scottgerring f709a53
Merge remote-tracking branch 'refs/remotes/origin/example-docs' into …
scottgerring b89594d
Merge branch 'main' into example-docs
jeromevdl c7a86d1
Update examples/README.md
scottgerring 6bb28d0
Fix naming
scottgerring cb8b9a4
Merge
scottgerring 7beebfe
fix syntax
scottgerring File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! | ||
scottgerring marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
To build and deploy your application for the first time, run the following in your shell: | ||
## Deploy the sample application | ||
scottgerring marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.