Skip to content

Latest commit

 

History

History
74 lines (54 loc) · 5.73 KB

README.md

File metadata and controls

74 lines (54 loc) · 5.73 KB

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.

Examples

Working with AWS Serverless Application Model (SAM) Examples

Many of the examples use AWS Serverless Application Model (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.

To learn more about SAM, check out the developer guide. You can use the CLI to test events locally, and run the application locally, amongst other things.

To build and deploy an example application for the first time, run the following in your shell:

# 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.

External examples

You can find more examples in the https://github.com/aws/aws-sam-cli-app-templates project:

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.