Skip to content

03 Aws Lambda Setup

DodaTech 1 min read

title: AWS Lambda Setup for Serverless APIs weight: 13 date: 2026-06-28 lastmod: 2026-06-28 description: Set up AWS Lambda for serverless APIs including IAM roles, function creation, environment variables, CloudWatch logging, and AWS CLI configuration for deployment. tags: [api-development, serverless]


AWS Lambda setup requires IAM roles with appropriate permissions, function configuration for runtime and memory, environment variables for configuration, CloudWatch Logs for monitoring, and the AWS CLI for deployment automation.

```bash
# Create IAM role for Lambda
aws iam create-role \
  --role-name lambda-basic-execution \
  --assume-role-policy-document file://trust-policy.json

# Attach basic execution policy
aws iam attach-role-policy \
  --role-name lambda-basic-execution \
  --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole

# Create Lambda function
aws lambda create-function \
  --function-name my-api-function \
  --runtime python3.11 \
  --role arn:aws:iam::123456789012:role/lambda-basic-execution \
  --handler handler.lambda_handler \
  --zip-file fileb://function.zip \
  --memory-size 256 \
  --timeout 30 \
  --environment Variables={ENV=production,LOG_LEVEL=info}

What's Next

Now learn about Lambda functions in Building Serverless APIs.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro