From 68c702bc807df6ae2647aa56c5eba65a08f6c086 Mon Sep 17 00:00:00 2001 From: Goumain Date: Fri, 7 Apr 2023 11:26:53 +0100 Subject: [PATCH] template and readme files --- apigw-http-api-lambda-python/README.md | 33 ++++++++++----- .../example-pattern.json | 42 +++++++++---------- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/apigw-http-api-lambda-python/README.md b/apigw-http-api-lambda-python/README.md index fe374e35c..f924bbb28 100644 --- a/apigw-http-api-lambda-python/README.md +++ b/apigw-http-api-lambda-python/README.md @@ -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 >> @@ -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 diff --git a/apigw-http-api-lambda-python/example-pattern.json b/apigw-http-api-lambda-python/example-pattern.json index a8ee9f16b..96926195e 100644 --- a/apigw-http-api-lambda-python/example-pattern.json +++ b/apigw-http-api-lambda-python/example-pattern.json @@ -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" } ] }, @@ -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": { @@ -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/" } ] }