
Cloud
Learning Level
AWS Lambda lets you run code without provisioning servers. Pay only for compute time consumed.
By the end of this lesson, you'll understand:
# 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.zipindex.js:
exports.handler = async (event) => {
console.log('Event:', JSON.stringify(event));
return {
statusCode: 200,
body: JSON.stringify({
message: 'Hello from Lambda!',
input: event
})
};
};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.comS3 Trigger:
# Configure S3 to trigger Lambda
aws s3api put-bucket-notification-configuration \
--bucket my-bucket \
--notification-configuration file://notification.json# 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}# Invoke function
aws lambda invoke \
--function-name HelloWorld \
--payload '{"name":"World"}' \
response.json
# View response
cat response.jsonLearn about S3 for static hosting, or explore DynamoDB for databases.
Resources
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