Skip to content

Commit

Permalink
Clean up and address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bb245 committed Jan 10, 2024
1 parent 2dd7273 commit 54d03eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 8 additions & 3 deletions alb-lambda-rest-api-sam-py/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# AWS Lambda RESTful API with Amazon ALB and Path Based Listener Rules

This configuration employs Python 3.9 and the Serverless Application Model (SAM) CLI to establish an Application Load
Balancer with path-based listener rules, paired with an AWS Lambda RESTful API function as the target.
This configuration pattern creates an Application Load
Balancer with path-based listener rules, paired with an AWS Lambda RESTful API function as the target. It uses Python 3.9 and the Serverless Application Model (SAM) CLI.

Learn more about this pattern
at [Serverless Land Patterns](https://serverlessland.com/patterns/alb-lambda-rest-api-sam-py).
Expand All @@ -20,6 +20,7 @@ AWS costs incurred. No warranty is implied in this example.
* [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (
AWS SAM) installed
* [Python 3 installed](https://www.python.org/downloads/)
* [AWS Lambda Powertools for Python](https://docs.powertools.aws.dev/lambda/python/latest/)
* [Docker](https://www.docker.com/products/docker-desktop/)

## Deployment Instructions
Expand All @@ -43,6 +44,8 @@ AWS costs incurred. No warranty is implied in this example.
5. During the prompts:
* Enter a stack name
* Enter the desired AWS Region
* Enter VPC ID
* Enter comma seperated Subnet IDs for e.g, subnet-1,subnet-2
* Allow SAM CLI to create IAM roles with the required permissions.

6. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for
Expand All @@ -52,10 +55,12 @@ AWS costs incurred. No warranty is implied in this example.

This setup orchestrates the deployment of an Application Load Balancer, configures path-based routes directing traffic
to a Python-based AWS Lambda function, and leverages
the [AWS Lambda Powertools for Python](https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/api_gateway/)
the [AWS Lambda Powertools for Python](https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/api_gateway/#application-load-balancer)
library. The Lambda function, serving as the target, records details of the incoming ALB event, along with the API and
context objects, logging them to an Amazon CloudWatch Logs log group and Amazon X-Ray.

Note: ALB has no authentication or authorization and should only be used for demo purposes.

## Testing

### SAM CLI for Local API Testing
Expand Down
6 changes: 5 additions & 1 deletion alb-lambda-rest-api-sam-py/example-pattern.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "AWS Lambda REST API and Amazon ALB with Listener Rules",
"description": "This configuration employs Python 3.9 and the Serverless Application Model (SAM) CLI to establish an Application Load Balancer with route-based listener rules, paired with an AWS Lambda RESTful API function as the target.",
"description": "This pattern creates an Application Load Balancer with route-based listener rules, paired with an AWS Lambda RESTful API function as the target. It uses Python 3.9 and the Serverless Application Model (SAM) CLI.",
"language": "Python",
"level": "200",
"framework": "SAM",
Expand Down Expand Up @@ -43,6 +43,10 @@
{
"text": "Using AWS Lambda with an Application Load Balancer",
"Link": "https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html"
},
{
"text": "Powertools for AWS Lambda (Python)",
"Link": "https://docs.powertools.aws.dev/lambda/python/latest/"
}
]
},
Expand Down

0 comments on commit 54d03eb

Please sign in to comment.