Thuta Learning
AdvancedDevOpsbeginner

Lambda & Serverless

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Understand Lambda & Serverless without any of the intimidation
  • Get comfortable running things yourself in the AWS CLI/Console
  • Be ready to apply this concept in a real project right away

Let's think about this for a second

An EC2 instance running 24/7 costs you hourly whether or not it's getting traffic. A Lambda function, on the other hand, only runs when triggered by an event (an HTTP request, a file upload, a schedule) — you pay by the millisecond it actually runs, and there's zero cost while idle (you never manage servers at all, which is why it's called 'serverless'). Each Lambda function has a timeout limit (max 15 min) and a memory limit (128MB-10GB), which makes it a poor fit for long-running tasks (heavy batch processing) — but it's ideal for short, event-driven tasks (image resizing, API endpoints, notifications).

Let's connect this to a real scenario

If you set up a Lambda function to auto-trigger every time an image is uploaded to an S3 bucket — with an image-resize/thumbnail-creation script written in Lambda — it'll run automatically the moment an upload happens and instantly generate a thumbnail. You never have to keep a server running, and on days with no uploads, it costs nothing at all.

Let's look at this together

python
# lambda_function.py — triggered by an S3 upload event
import json

def lambda_handler(event, context):
    bucket = event['Records'][0]['s3']['bucket']['name']
    key = event['Records'][0]['s3']['object']['key']
    print(f"New file uploaded: {key} in {bucket}")
    # ... resize image, create thumbnail, etc.
    return {
        'statusCode': 200,
        'body': json.dumps(f'Processed {key}')
    }
You should see
$ aws logs tail /aws/lambda/resize-image-function
New file uploaded: photo.jpg in my-tutorial-bucket-2026
Processed photo.jpg

Try it in 5 minutes

Create a 'Hello World' Lambda function (Python or Node.js) and try invoking it manually via the Test button in the AWS Console — check the output in CloudWatch Logs.

A quick word of caution

If you've connected a Lambda function to a trigger source (S3, API Gateway, EventBridge), unexpected trigger frequency can suddenly spike your costs — keep an eye on trigger volume.

Easy traps

  • Writing a long-running batch job (30+ minutes of analytics processing) inside Lambda — you can blow past the 15-minute timeout limit (you should use EC2/Batch instead)
  • Setting a Lambda function's memory allocation to the minimum without matching it to the actual workload — this can cause timeouts or slow execution

Now try it yourself

Create a 'Hello World' Lambda function (Python or Node.js) and try invoking it manually via the Test button in the AWS Console — check the output in CloudWatch Logs.

You'll know it worked when: $ aws logs tail /aws/lambda/resize-image-function New file uploaded: photo.jpg in my-tutorial-bucket-2026 Processed photo.jpg