AWS has saved a lot of money for their customers who were looking for a simple proxy to expose serverless application by releasing HTTP API Gateway. If you are NOT looking for features like request/response transformation, Lambda authorizer, request parameters/body validation, request forwarding to other AWS services and such other advanced features then HTTP API is the best choice instead of REST API. A detailed comparison between HTTP and REST API can be found here.
Before diving into the implementation part you will need Lambda code to successfully test our deployment.
Let’s start with the implementation part by creating our lambda functions.
Lambda Function 1
Once you click on Create Function button an IAM role with basic required permissions will be created along with your function.
Replace the default code with the following:
mport json
def lambda_handler(event, context):
return {
'statusCode': 200,
'body': json.dumps('Hello from api 1')
}
Make sure to click the Save button available on the top right side before navigating away from the page.
Lambda Code (Function 1)
Lambda Function 2
Replace the default code with the following for the second function:
Don’t forget to save your code.
Lambda Code (Function 2)
It’s now time to create our API Gateway so let’s do it.
#aws-api-gateway #cloudfront #http-api #lambda #aws