Python Flask + AWS DynamoDB: Full CRUD API with Postman Testing
This guide walks you through setting up AWS DynamoDB, creating a Flask API with CRUD operations, and testing it with Postman.
1. Configuring AWS Credentials
Before interacting with DynamoDB, configure AWS credentials.
Step 1: Generate AWS Access & Secret Keys
- Sign in to AWS Console
- Go to IAM → Users → Select User → Security credentials
- Create and copy the Access Key ID & Secret Access Key
Step 2: Configure AWS CLI
Run the following command in your terminal:
Enter:
2. Creating a DynamoDB Table
Before building our Flask app, we need a DynamoDB table.
Step 1: Install Boto3 (AWS SDK for Python)
Step 2: Create a Python Script create_table.py
Step 3: Run the Script to Create the Table
3. Setting Up Flask Project
Step 1: Create and Activate a Virtual Environment
Step 2: Install Required Packages
4. Creating Flask App with CRUD Operations
Create a file named app.py
and add the following code:
Step 3: Run the Flask App
Check if the API is running: http://127.0.0.1:5000/
5. Testing with Postman
Step 1: Install Postman
Download Postman if not installed.
Step 2: Perform API Requests
✅ Create User (POST)
- URL:
http://127.0.0.1:5000/users
- Body (JSON):
- Response:
✅ Get User (GET)
- URL:
http://127.0.0.1:5000/users/{user_id}
- Response (if found):
✅ Update User (PUT)
- URL:
http://127.0.0.1:5000/users/{user_id}
- Body (JSON):
- Response:
✅ Delete User (DELETE)
- URL:
http://127.0.0.1:5000/users/{user_id}
- Response: