Create Lambda Function to Handle DynamoDB Requests

Objective

Create a new Lambda Function to process requests to DynamoDB through API Gateway.


Steps

Download the backend file from here.


Step 1: Create IAM Role

  1. Open IAM Console → Roles → Create role

IAM_1

IAM_2

  1. Select
    Trusted entity: AWS Service → Lambda

IAM_3

  1. Attach the following permissions:

    • AmazonDynamoDBFullAccess
    • CloudWatchLogsFullAccess
  2. Set the role name: LambdaAPIAccessRole

IAM_4 IAM_5


Step 2: Create Lambda Function

  1. Go to AWS Lambda → Create function
  2. Select Author from scratch
  3. Function name: DynamoDB_API_Handler
  4. Runtime: Java 17
  5. Choose IAM Role: LambdaAPIAccessRole

LAMBDA_4


Step 3: Deploy the JAR File

  1. Go to S3 → Upload → Add files
    Upload the jar file, then copy the Object URL

LAMBDA_5

  1. Go to AWS Lambda → Upload from S3
    Paste the object URL you copied

LAMBDA_6

  1. Go to AWS Lambda → Code → Runtime settings → Edit
  2. Set Handler:
    org.example.flyora_backend.handler.StreamLambdaHandler::handleRequest

LAMBDA_7


Step 4: Configure Lambda Function

  1. Go to AWS Lambda → Configuration → General configuration → Edit
  2. Set Timeout: 1 min

LAMBDA_8

  1. Go to AWS Lambda → Configuration → Environment variables → Edit
  2. Add:
    • Key: APP_JWT_SECRET
    • Value: huntrotflyorateam!@ky5group5member

LAMBDA_9

  1. Key: GHN_TOKEN; Value: 445c659d-5586-11f0-8c19-5aba781b9b65