AWS Lambda — serverless compute: pay only for execution time.
Example (Node.js):
1exports.handler = async (event) => {2 return {3 statusCode: 200,4 body: JSON.stringify({ message: "Hello from Lambda!" }),5 };6};
CLI:
1aws lambda create-function \2 --function-name my-function \3 --runtime nodejs18.x \4 --handler index.handler \5 --role arn:aws:iam::xxx:role/lambda-role \6 --zip-file fileb://function.zip78aws lambda invoke --function-name my-function output.json
Use cases: API Gateway + Lambda, S3 → Lambda, SQS → Lambda, Cron.
Limits: 15 min timeout, 10GB memory, cold start.
Serverless Framework:
1service: my-api2provider:3 name: aws4 runtime: nodejs18.x5functions:6 hello:7 handler: handler.hello8 events:9 - http:10 path: /hello11 method: get