Skip to content

Commit

Permalink
template and readme files
Browse files Browse the repository at this point in the history
  • Loading branch information
Goumain committed Apr 7, 2023
1 parent 5f14e47 commit 68c702b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
33 changes: 23 additions & 10 deletions apigw-http-api-lambda-python/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AWS Service 1 to AWS Service 2
# AWS API Gateway HTTP API to AWS Lambda

This pattern << explain usage >>
This pattern creates an Amazon API Gateway HTTP API with an AWS Lambda function integration.

Learn more about this pattern at Serverless Land Patterns: << Add the live URL here >>

Expand All @@ -19,30 +19,43 @@ Important: this application uses various AWS services and there are costs associ
```
git clone https://github.com/aws-samples/serverless-patterns
```
1. Change directory to the pattern directory:
2. Change directory to the pattern directory:
```
cd _patterns-model
cd apigw-http-api-lambda-python
```
1. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:
3. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:
```
sam deploy --guided
```
1. During the prompts:
4. During the prompts:
* Enter a stack name
* Enter the desired AWS Region
* Allow SAM CLI to create IAM roles with the required permissions.
Once you have run `sam deploy --guided` mode once and saved arguments to a configuration file (samconfig.toml), you can use `sam deploy` in future to use these defaults.
1. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for testing.
5. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for testing.
## How it works
Explain how the service interaction works.
This pattern deploys an Amazon API Gateway HTTP API with a Lambda integration. The AWS Lambda function is written in Python3.9. The function returns a small message and a status code to the caller.
## Testing
Provide steps to trigger the integration and show what should be observed if successful.
Once the application is deployed, retrieve the API ID provided as output and go to API Gateway console. Click on the newly created API, in the stages window, click on the link under 'invoke URL'. You can also make the request from Postman. The URL should look like this : https://[api-id].execute-api.[api-region].amazonaws.com/
Example
```
https://aabbccddee.execute-api.eu-west-1.amazonaws.com/
```
OR open a terminal and execute the curl command
Example
```
curl https://aabbccddee.execute-api.eu-west-1.amazonaws.com/
```
The expected response is : 'Hello World! This is the HTTP API'
## Cleanup
Expand Down
42 changes: 19 additions & 23 deletions apigw-http-api-lambda-python/example-pattern.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
{
"title": "Step Functions to Athena",
"description": "Create a Step Functions workflow to query Amazon Athena.",
"title": "AWS API Gateway HTTP API to AWS Lambda",
"description": "Create an HTTP API and a Lambda function",
"language": "Python",
"level": "200",
"framework": "CDK",
"level": "100",
"framework": "SAM",
"introBox": {
"headline": "How it works",
"text": [
"This sample project demonstrates how to use an AWS Step Functions state machine to query Athena and get the results. This pattern is leveraging the native integration between these 2 services which means only JSON-based, structured language is used to define the implementation.",
"With Amazon Athena you can get up to 1000 results per invocation of the GetQueryResults method and this is the reason why the Step Function has a loop to get more results. The results are sent to a Map which can be configured to handle (the DoSomething state) the items in parallel or one by one by modifying the max_concurrency parameter.",
"This pattern deploys one Step Functions, two S3 Buckets, one Glue table and one Glue database."
"This pattern deploys an Amazon API Gateway HTTP API with a Lambda integration.",
"The AWS Lambda function is written in Python3.9. The function returns a small message and a status code to the caller."
]
},
"gitHub": {
"template": {
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/sfn-athena-cdk-python",
"templateURL": "serverless-patterns/sfn-athena-cdk-python",
"projectFolder": "sfn-athena-cdk-python",
"templateFile": "sfn_athena_cdk_python/sfn_athena_cdk_python_stack.py"
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/apigw-http-api-lambda-python",
"templateURL": "serverless-patterns/apigw-http-api-lambda-python",
"projectFolder": "apigw-http-api-lambda-python",
"templateFile": "apigw-http-api-lambda-python/template.yml"
}
},
"resources": {
"bullets": [
{
"text": "Call Athena with Step Functions",
"link": "https://docs.aws.amazon.com/step-functions/latest/dg/connect-athena.html"
},
{
"text": "Amazon Athena - Serverless Interactive Query Service",
"link": "https://aws.amazon.com/athena/"
"text": "Working with HTTP API",
"link": "https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html"
}
]
},
Expand All @@ -39,7 +34,9 @@
},
"testing": {
"text": [
"See the Github repo for detailed testing instructions."
"Once the application is deployed, retrieve the API ID provided as output and go to API Gateway console.",
"Click on the newly created API, in the stages window, click on the link under 'invoke URL'.",
"You can also make the request from Postman or from a terminal using the curl command."
]
},
"cleanup": {
Expand All @@ -49,11 +46,10 @@
},
"authors": [
{
"name": "Your name",
"image": "link-to-your-photo.jpg",
"bio": "Your bio.",
"linkedin": "linked-in-ID",
"twitter": "twitter-handle"
"name": "Alice Goumain",
"image": "https://media.licdn.com/dms/image/C4E03AQFu1xnGt76xzg/profile-displayphoto-shrink_800_800/0/1662636936708?e=1686182400&v=beta&t=9RZra4EtrGWhcWVYZZtP_W9yrUR_XZ9ued70sTnkCgg",
"bio": "Cloud Support Engineer at AWS",
"linkedin": "https://www.linkedin.com/in/alice-goumain/"
}
]
}

0 comments on commit 68c702b

Please sign in to comment.