API Gateway with DynamoDB Integration
23rd August 2024
23rd August 2024
This documentation outlines the steps to create an API Gateway with GET and POST methods to interact with DynamoDB, serving as the database for movie details. It provides a seamless way to push and fetch movie data using API Gateway and DynamoDB integration.
Log in to your AWS Management Console and navigate to the DynamoDB service. Click on "Create table" and provide necessary details such as table name and primary key. For example, you can use "Movies" as the table name with "movie_id" as the primary key. Configure additional settings as per your requirements and click on "Create table".
Navigate to the IAM service in the AWS Management Console. Click on "Roles" and then "Create role". Select "AWS service" and choose "Lambda" or "API Gateway" depending on your integration method.
Navigate to the API Gateway service in the AWS Management Console. Click on "Create API" and choose "REST API". Select "New API" and give your API a name. Click on "Create API".
Under your newly created API, click on "Actions" and choose "Create Resource". Define a resource name, for example, "movies". Once created, click on the resource and choose "Create Method". Select "GET" for fetching data and "POST" for adding data.
For GET method, choose "Integration type" as "AWS Service" and select "DynamoDB" as the integration point. Configure the integration to interact with your DynamoDB table.
For POST method, choose "Integration type" as "Lambda Function" (or "AWS Service" if you prefer using DynamoDB directly), and configure it to interact with your DynamoDB table to add new movie details.
After configuring resources and methods, click on "Actions" and choose "Deploy API". Select a deployment stage (e.g., "Prod") and click on "Deploy". Make note of the provided API endpoint URL, which will be used to access your API.
Use tools like Postman or cURL to test your API endpoints. For GET method, send a request to the endpoint URL to fetch movie details. For POST method, send a request with JSON payload containing movie details to add new entries to the DynamoDB table.
By following the above steps, you have successfully created an API Gateway integrated with DynamoDB to manage movie details. This setup provides a scalable and efficient way to push and fetch data, allowing seamless interaction between your application and the database.