<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zahid Rasool</title>
    <description>The latest articles on DEV Community by Zahid Rasool (@zahid_rasool_1792a8e2628b).</description>
    <link>https://dev.to/zahid_rasool_1792a8e2628b</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4248847%2Ffce0f53a-7a3c-4a49-ac72-a2e0ebd1131b.png</url>
      <title>DEV Community: Zahid Rasool</title>
      <link>https://dev.to/zahid_rasool_1792a8e2628b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zahid_rasool_1792a8e2628b"/>
    <language>en</language>
    <item>
      <title>AWS Serverless GET &amp; POST API Project</title>
      <dc:creator>Zahid Rasool</dc:creator>
      <pubDate>Tue, 17 Nov 2026 04:54:02 +0000</pubDate>
      <link>https://dev.to/zahid_rasool_1792a8e2628b/aws-serverless-get-post-api-project-26jd</link>
      <guid>https://dev.to/zahid_rasool_1792a8e2628b/aws-serverless-get-post-api-project-26jd</guid>
      <description>&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;p&gt;Serverless computing allows developers to build and deploy applications without managing traditional servers. AWS provides several services that work together to create scalable, cost-effective and highly available applications.&lt;/p&gt;

&lt;p&gt;In this hands-on project, I built an AWS Serverless GET &amp;amp; POST API using Amazon S3, Amazon API Gateway, AWS Lambda and Amazon DynamoDB.&lt;/p&gt;

&lt;p&gt;The application allows users to submit data through a web interface, store records in DynamoDB using a POST request, and retrieve stored records using a GET request.&lt;/p&gt;

&lt;p&gt;The main objective was to understand how AWS serverless services integrate to build a complete API-based application.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Project Architecture
&lt;/h2&gt;

&lt;p&gt;The application follows a serverless architecture in which the frontend, API layer, compute layer and database work together.&lt;/p&gt;

&lt;p&gt;Architecture Flow&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         USER / WEB BROWSER
                 |
                 v
           AMAZON S3
        (Static Website)
                 |
                 | API Requests
                 v
          API GATEWAY
            /users
                 |
          +------+------+
          |             |
          v             v
      GET Request   POST Request
          |             |
          v             v
   AWS Lambda       AWS Lambda
 GetStudentData   PostStudentData
          |             |
          +------+------+
                 |
                 v
          AMAZON DYNAMODB
            StudentData
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Request workflow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Amazon S3 hosts the frontend website.&lt;/li&gt;
&lt;li&gt;The browser sends GET and POST requests directly to API Gateway.&lt;/li&gt;
&lt;li&gt;API Gateway routes requests to the appropriate Lambda function.&lt;/li&gt;
&lt;li&gt;Lambda functions read or write records in DynamoDB.&lt;/li&gt;
&lt;li&gt;API Gateway returns the response to the browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. AWS Services and Their Responsibilities
&lt;/h2&gt;

&lt;p&gt;AWS Service| Purpose&lt;br&gt;
Amazon S3| Hosts the static website&lt;br&gt;
Amazon API Gateway| Creates and manages GET and POST API endpoints&lt;br&gt;
AWS Lambda| Executes backend Python code&lt;br&gt;
Amazon DynamoDB| Stores and retrieves application records&lt;br&gt;
AWS IAM| Controls permissions between AWS services&lt;/p&gt;

&lt;h2&gt;
  
  
  4. DynamoDB Database Configuration
&lt;/h2&gt;

&lt;p&gt;The first step was creating a DynamoDB table to store application records.&lt;/p&gt;

&lt;p&gt;Table configuration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Table Name: "StudentData"&lt;/li&gt;
&lt;li&gt;Partition Key: "Studentid"&lt;/li&gt;
&lt;li&gt;Key Type: String&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The application stores the following attributes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Studentid&lt;/li&gt;
&lt;li&gt;name&lt;/li&gt;
&lt;li&gt;phone_number&lt;/li&gt;
&lt;li&gt;city&lt;/li&gt;
&lt;li&gt;state&lt;/li&gt;
&lt;li&gt;country&lt;/li&gt;
&lt;li&gt;email&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The partition key uniquely identifies each record.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Creating the AWS Lambda Functions
&lt;/h2&gt;

&lt;p&gt;Two separate Lambda functions were created to handle different HTTP methods.&lt;/p&gt;

&lt;p&gt;5.1 GET Lambda Function&lt;/p&gt;

&lt;p&gt;Function Name: "GetStudentData"&lt;/p&gt;

&lt;p&gt;Runtime: Python 3.12&lt;/p&gt;

&lt;p&gt;The GET function retrieves records from DynamoDB.&lt;/p&gt;

&lt;p&gt;It supports two operations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Retrieve all available records.&lt;/li&gt;
&lt;li&gt;Retrieve a specific record using its Student ID.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example endpoint:&lt;/p&gt;

&lt;p&gt;GET /users&lt;br&gt;
GET /users?id=101&lt;/p&gt;

&lt;p&gt;Python implementation:&lt;/p&gt;

&lt;p&gt;import json&lt;br&gt;
import boto3&lt;br&gt;
import os&lt;/p&gt;

&lt;p&gt;dynamodb = boto3.resource("dynamodb")&lt;br&gt;
table = dynamodb.Table("StudentData")&lt;/p&gt;

&lt;p&gt;def lambda_handler(event, context):&lt;br&gt;
    try:&lt;br&gt;
        params = event.get("queryStringParameters") or {}&lt;br&gt;
        student_id = params.get("id")&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if student_id:
        response = table.get_item(
            Key={"Studentid": str(student_id)}
        )
        data = response.get("Item")

        if not data:
            return {
                "statusCode": 404,
                "headers": {
                    "Access-Control-Allow-Origin": "*"
                },
                "body": json.dumps({
                    "message": "Student not found"
                })
            }

        result = data

    else:
        response = table.scan()
        items = response.get("Items", [])

        while "LastEvaluatedKey" in response:
            response = table.scan(
                ExclusiveStartKey=response["LastEvaluatedKey"]
            )
            items.extend(response.get("Items", []))

        result = items

    return {
        "statusCode": 200,
        "headers": {
            "Access-Control-Allow-Origin": "*",
            "Content-Type": "application/json"
        },
        "body": json.dumps(result, default=str)
    }

except Exception as e:
    return {
        "statusCode": 500,
        "headers": {
            "Access-Control-Allow-Origin": "*"
        },
        "body": json.dumps({"error": str(e)})
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;How it works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reads the query parameter from the API request.&lt;/li&gt;
&lt;li&gt;Uses "get_item()" when a Student ID is provided.&lt;/li&gt;
&lt;li&gt;Uses "scan()" to retrieve all records when no ID is provided.&lt;/li&gt;
&lt;li&gt;Returns the result in JSON format.&lt;/li&gt;
&lt;li&gt;Returns HTTP status 200 when successful.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5.2 POST Lambda Function&lt;/p&gt;

&lt;p&gt;Function Name: "PostStudentData"&lt;/p&gt;

&lt;p&gt;Runtime: Python 3.12&lt;/p&gt;

&lt;p&gt;The POST function receives JSON data and saves a new record in DynamoDB.&lt;/p&gt;

&lt;p&gt;Example request body:&lt;/p&gt;

&lt;p&gt;{&lt;br&gt;
  "Studentid": "101",&lt;br&gt;
  "name": "Ali",&lt;br&gt;
  "phone_number": "03001234567",&lt;br&gt;
  "city": "Sahiwal",&lt;br&gt;
  "state": "Punjab",&lt;br&gt;
  "country": "Pakistan",&lt;br&gt;
  "email": "&lt;a href="mailto:ali@example.com"&gt;ali@example.com&lt;/a&gt;"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Python implementation:&lt;/p&gt;

&lt;p&gt;import json&lt;br&gt;
import boto3&lt;/p&gt;

&lt;p&gt;dynamodb = boto3.resource("dynamodb")&lt;br&gt;
table = dynamodb.Table("StudentData")&lt;/p&gt;

&lt;p&gt;def lambda_handler(event, context):&lt;br&gt;
    try:&lt;br&gt;
        body = event.get("body")&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if isinstance(body, str):
        body = json.loads(body)
    elif body is None:
        body = {}

    required_fields = [
        "Studentid",
        "name",
        "phone_number",
        "city",
        "state",
        "country",
        "email"
    ]

    for field in required_fields:
        if not body.get(field):
            return {
                "statusCode": 400,
                "headers": {
                    "Access-Control-Allow-Origin": "*"
                },
                "body": json.dumps({
                    "error": f"{field} is required"
                })
            }

    item = {
        field: str(body[field])
        for field in required_fields
    }

    table.put_item(
        Item=item,
        ConditionExpression="attribute_not_exists(Studentid)"
    )

    return {
        "statusCode": 201,
        "headers": {
            "Access-Control-Allow-Origin": "*",
            "Content-Type": "application/json"
        },
        "body": json.dumps({
            "message": "Record created successfully",
            "data": item
        })
    }

except Exception as e:
    if "ConditionalCheckFailedException" in str(e):
        return {
            "statusCode": 409,
            "headers": {
                "Access-Control-Allow-Origin": "*"
            },
            "body": json.dumps({
                "error": "Student ID already exists"
            })
        }

    return {
        "statusCode": 500,
        "headers": {
            "Access-Control-Allow-Origin": "*"
        },
        "body": json.dumps({"error": str(e)})
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;How it works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Receives JSON data from API Gateway.&lt;/li&gt;
&lt;li&gt;Validates the required fields.&lt;/li&gt;
&lt;li&gt;Creates a DynamoDB item.&lt;/li&gt;
&lt;li&gt;Prevents an existing Student ID from being overwritten.&lt;/li&gt;
&lt;li&gt;Returns HTTP status 201 after successful creation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. IAM Permissions Configuration
&lt;/h2&gt;

&lt;p&gt;Lambda requires permission to access the DynamoDB table.&lt;/p&gt;

&lt;p&gt;An IAM execution role was assigned to the Lambda functions.&lt;/p&gt;

&lt;p&gt;Required DynamoDB permissions include:&lt;/p&gt;

&lt;p&gt;GET function:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dynamodb:GetItem&lt;/li&gt;
&lt;li&gt;dynamodb:Scan&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;POST function:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dynamodb:PutItem&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The permissions should be restricted to the required DynamoDB table instead of granting unnecessary access.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. API Gateway Configuration
&lt;/h2&gt;

&lt;p&gt;Amazon API Gateway was used to expose the Lambda functions through HTTP endpoints.&lt;/p&gt;

&lt;p&gt;API Configuration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API Type: REST API&lt;/li&gt;
&lt;li&gt;API Name: "StudentManagementAPI"&lt;/li&gt;
&lt;li&gt;Resource: "/users"&lt;/li&gt;
&lt;li&gt;Methods: GET and POST&lt;/li&gt;
&lt;li&gt;Integration: AWS Lambda Proxy Integration&lt;/li&gt;
&lt;li&gt;Deployment Stage: "prod"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;GET Method&lt;/p&gt;

&lt;p&gt;The GET method was integrated with:&lt;/p&gt;

&lt;p&gt;"GetStudentData"&lt;/p&gt;

&lt;p&gt;POST Method&lt;/p&gt;

&lt;p&gt;The POST method was integrated with:&lt;/p&gt;

&lt;p&gt;"PostStudentData"&lt;/p&gt;

&lt;p&gt;CORS was configured to allow frontend requests, including GET, POST and OPTIONS.&lt;/p&gt;

&lt;p&gt;After configuring the methods and integrations, the API was deployed to the "prod" stage.&lt;/p&gt;

&lt;p&gt;API Endpoint:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://API-ID.execute-api.REGION.amazonaws.com/prod/users" rel="noopener noreferrer"&gt;https://API-ID.execute-api.REGION.amazonaws.com/prod/users&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Frontend Development and S3 Hosting
&lt;/h2&gt;

&lt;p&gt;A frontend website was developed using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML&lt;/li&gt;
&lt;li&gt;CSS&lt;/li&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The website provides the following functionality:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter a Student ID and other record details.&lt;/li&gt;
&lt;li&gt;Submit data using the POST API.&lt;/li&gt;
&lt;li&gt;Retrieve all records using the GET API.&lt;/li&gt;
&lt;li&gt;Search for a specific record using Student ID.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The frontend JavaScript connects to the API Gateway endpoint.&lt;/p&gt;

&lt;p&gt;const API_URL =&lt;br&gt;
"&lt;a href="https://API-ID.execute-api.REGION.amazonaws.com/prod/users" rel="noopener noreferrer"&gt;https://API-ID.execute-api.REGION.amazonaws.com/prod/users&lt;/a&gt;";&lt;/p&gt;

&lt;p&gt;The website files were uploaded to an Amazon S3 bucket, and Static Website Hosting was enabled.&lt;/p&gt;

&lt;p&gt;The API endpoint was configured in the frontend code to connect the website with the backend services.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. API Testing and Results
&lt;/h2&gt;

&lt;p&gt;Both API methods were tested to verify that the application was working correctly.&lt;/p&gt;

&lt;p&gt;POST API Testing&lt;/p&gt;

&lt;p&gt;Request:&lt;/p&gt;

&lt;p&gt;POST /users&lt;/p&gt;

&lt;p&gt;A JSON record was submitted through the frontend/API request.&lt;/p&gt;

&lt;p&gt;Expected successful response:&lt;/p&gt;

&lt;p&gt;{&lt;br&gt;
  "message": "Record created successfully"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Actual project test result:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTP Status Code: "201"&lt;/li&gt;
&lt;li&gt;Result: Record created successfully.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;GET API Testing&lt;/p&gt;

&lt;p&gt;Request:&lt;/p&gt;

&lt;p&gt;GET /users&lt;/p&gt;

&lt;p&gt;The API retrieved records stored in the DynamoDB table.&lt;/p&gt;

&lt;p&gt;Actual project test result:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTP Status Code: "200"&lt;/li&gt;
&lt;li&gt;Result: Data retrieved successfully.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Testing Summary&lt;/p&gt;

&lt;p&gt;Test| HTTP Status| Result&lt;br&gt;
POST API| 201| Successful&lt;br&gt;
GET API| 200| Successful&lt;br&gt;
Website Hosting| —| Successful&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Challenges and Solutions
&lt;/h2&gt;

&lt;p&gt;During implementation, several configuration and integration steps required attention.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Lambda and DynamoDB permissions&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Challenge: Lambda requires permission to access DynamoDB.&lt;/li&gt;
&lt;li&gt;Solution: Configured the appropriate IAM execution role and database permissions.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;API and frontend integration&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Challenge: The frontend must communicate with the correct API endpoint.&lt;/li&gt;
&lt;li&gt;Solution: Configured the deployed API URL in JavaScript.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;CORS configuration&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Challenge: Browser-based API requests require correct cross-origin configuration.&lt;/li&gt;
&lt;li&gt;Solution: Configured CORS for the required API methods and response headers.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;API deployment&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Challenge: Changes to API configuration must be deployed before they become available through the stage.&lt;/li&gt;
&lt;li&gt;Solution: Deployed the API to the "prod" stage after configuration changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  11. Key Learnings
&lt;/h2&gt;

&lt;p&gt;Through this project, I gained practical experience with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building a serverless application on AWS.&lt;/li&gt;
&lt;li&gt;Creating and configuring DynamoDB tables.&lt;/li&gt;
&lt;li&gt;Developing Python-based AWS Lambda functions.&lt;/li&gt;
&lt;li&gt;Implementing GET and POST API methods.&lt;/li&gt;
&lt;li&gt;Integrating API Gateway with Lambda.&lt;/li&gt;
&lt;li&gt;Configuring IAM permissions.&lt;/li&gt;
&lt;li&gt;Hosting static websites using Amazon S3.&lt;/li&gt;
&lt;li&gt;Connecting frontend applications with backend APIs.&lt;/li&gt;
&lt;li&gt;Testing HTTP responses and troubleshooting integration issues.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  12. Security and Production Considerations
&lt;/h2&gt;

&lt;p&gt;This project demonstrates the basic serverless workflow. Before using it in production:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add authentication and authorization.&lt;/li&gt;
&lt;li&gt;Apply least-privilege IAM policies.&lt;/li&gt;
&lt;li&gt;Validate and sanitize incoming data.&lt;/li&gt;
&lt;li&gt;Restrict CORS to trusted website origins.&lt;/li&gt;
&lt;li&gt;Avoid exposing personal or sensitive records through a public website.&lt;/li&gt;
&lt;li&gt;Consider using Amazon CloudFront and HTTPS for production website delivery.&lt;/li&gt;
&lt;li&gt;Enable appropriate logging and monitoring.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  13. Conclusion
&lt;/h2&gt;

&lt;p&gt;The AWS Serverless GET &amp;amp; POST API Project demonstrates how multiple AWS services can work together to build a functional serverless application.&lt;/p&gt;

&lt;p&gt;Amazon S3 provides frontend hosting, API Gateway manages API requests, AWS Lambda handles backend processing, and Amazon DynamoDB stores application data.&lt;/p&gt;

&lt;p&gt;The successful GET and POST tests confirmed that the frontend, API and database were integrated correctly.&lt;/p&gt;

&lt;p&gt;This project provided valuable hands-on experience in serverless application development and strengthened my understanding of AWS cloud architecture.&lt;/p&gt;

&lt;p&gt;Technologies Used: Amazon S3 | Amazon API Gateway | AWS Lambda | Amazon DynamoDB | AWS IAM | Python 3.12 | HTML | CSS | JavaScript&lt;/p&gt;




&lt;p&gt;Tags: "#AWS" "#Serverless" "#AmazonLambda" "#APIGateway" "#DynamoDB" "#CloudComputing"&lt;/p&gt;

</description>
      <category>api</category>
      <category>aws</category>
      <category>cloud</category>
      <category>serverless</category>
    </item>
  </channel>
</rss>
