Ojasa Mirai

Ojasa Mirai

Cloud

Loading...

Learning Level

🟢 Beginner🔵 Advanced
🔧 AWS Account Setup⚙️ AWS Compute Overview🖥️ EC2 Deployment🎯 Elastic Beanstalk⚡ Lambda Serverless📁 S3 Static Hosting🗄️ RDS Relational Database📊 DynamoDB NoSQL💾 ElastiCache Caching📊 AWS Monitoring🔑 AWS Authentication📈 AWS Scaling & Load Balancing🐳 AWS ECS Containers💰 AWS Cost Optimization
Cloud/Aws Deployment/Lambda Serverless

⚡ Lambda Serverless

Introduction

AWS Lambda lets you run code without provisioning servers. Pay only for compute time consumed.

Key Learning Outcomes

By the end of this lesson, you'll understand:

  • Creating Lambda functions
  • Event sources and triggers
  • Function configuration
  • Testing and debugging
  • Monitoring and logging
  • Cost optimization

Creating a Function

# Create function
aws lambda create-function \
  --function-name HelloWorld \
  --runtime nodejs18.x \
  --role arn:aws:iam::ACCOUNT:role/lambda-role \
  --handler index.handler \
  --zip-file fileb://function.zip

Function Code

index.js:

exports.handler = async (event) => {
  console.log('Event:', JSON.stringify(event));
  
  return {
    statusCode: 200,
    body: JSON.stringify({
      message: 'Hello from Lambda!',
      input: event
    })
  };
};

Event Sources

API Gateway Trigger:

# Create API endpoint
aws apigateway create-rest-api --name my-api

# Create Lambda permission
aws lambda add-permission \
  --function-name HelloWorld \
  --statement-id AllowAPIGateway \
  --action lambda:InvokeFunction \
  --principal apigateway.amazonaws.com

S3 Trigger:

# Configure S3 to trigger Lambda
aws s3api put-bucket-notification-configuration \
  --bucket my-bucket \
  --notification-configuration file://notification.json

Function Configuration

# Set memory
aws lambda update-function-configuration \
  --function-name HelloWorld \
  --memory-size 512 \
  --timeout 30

# Set environment variables
aws lambda update-function-configuration \
  --function-name HelloWorld \
  --environment Variables={KEY=value}

Testing

# Invoke function
aws lambda invoke \
  --function-name HelloWorld \
  --payload '{"name":"World"}' \
  response.json

# View response
cat response.json

Key Takeaways

  • **Serverless** - no infrastructure management
  • **Event-driven** - respond to various triggers
  • **Pay per execution** - cost efficient
  • **Auto-scaling** - handles any load
  • **Monitoring** included with CloudWatch

Next Steps

Learn about S3 for static hosting, or explore DynamoDB for databases.


Resources

Python Docs

Ojasa Mirai

Master AI-powered development skills through structured learning, real projects, and verified credentials. Whether you're upskilling your team or launching your career, we deliver the skills companies actually need.

Learn Deep • Build Real • Verify Skills • Launch Forward

Courses

PythonFastapiReactJSCloud

© 2026 Ojasa Mirai. All rights reserved.

TwitterGitHubLinkedIn