Amazon API Gateway is a serverless service that allows you to create and manage RESTful or WebSocket APIs. It acts as a gateway between the frontend (React/Vite) and backend (Lambda functions), handling HTTP requests and forwarding them to AWS services.
In this section, we will:
Create a REST API to handle HTTP requests.
Create a /posts
resource to support endpoints for posts.
Ensure the API integrates with the Lambda functions (getPosts
, createPost
) in the next step.
Serverless: No need to manage servers, automatically scales with traffic.
Easy integration: Connects directly to Lambda and supports HTTP requests.
Low cost: Free Tier offers 1 million free requests per month.
Find and select API Gateway.
Select APIs in the navigation menu.
Select Create API.
Select REST API and click Build.
BlogAPI
./posts
:posts
./posts
.Make sure CORS is enabled so that the React/Vite frontend can make requests to the API.
Save the API name (BlogAPI
) and resource (/posts
) for use in the next step.
/posts
resource, ready to configure the GET/POST method.