This post is the first of a series on deploying a server less infrastructure on AWS cloud.
What is an API Gateway?
An API Gateway is a managed service that sits between frontend clients and backend services, acting as an entry point for API requests.
How To Provision API Gateway
For this series the serverless application I will be building is a restaurant reservation web app, hosted on Amazon S3 which collects clients reservation information through the frontend, passes it through the gateway endpoint which triggers a Lambda function to process the data and store it in AWS DynamoDB. For this use case my gateway endpoint will be a REST API with a POST method. To provision this,
First you head to your AWS Management Console, navigate to the API console, then you click on "Create API". In the choose an API type page click on build on the REST API option, give the API a name, API endpoint type will be set to regional, IP address type will be IPv4 then create the api
After creating the API you must then configure it to your use case, for my use case I want an API that can carry out a POST request to my DynamoDB table by triggering Lambda. As a result you must create a resource, the path should be set to "/", resource name should be set to your choice of name and remember to enable CORS since our request will be coming from another frontend site hosted on Amazon S3. Hosting a static website on S3.
For the next step will be selecting a method type, but first we need a Lambda function (Creating a Lambda Function).
Head to the create method page, set the Method Type to "POST", integration type to Lambda Function, then select the Lambda Function provisioned earlier, and create the method.
Next you must deploy the API, while deploying you would be prompted for a stage name, give a name of your choice. Navigate to the stage you just created and copy the invoke url.
Top comments (0)