AWS Cloud & DevOps Tutorial 0/70 lessons ~6 min read Lesson 14

    AWS Lambda and Serverless Fundamentals

    Not every TechLearningPro workload deserves a long-lived fleet. When a teacher uploads a diagram, when a webhook arrives from a payments partner, when a nightly export must transfo

    Course progress0%
    Focus
    15 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    AWS Lambda and Serverless Fundamentals

    AWS Cloud & DevOps Engineering · Lesson 14 · AWS Application Platform

    Lesson Overview

    Not every TechLearningPro workload deserves a long-lived fleet. When a teacher uploads a diagram, when a webhook arrives from a payments partner, when a nightly export must transform progress snapshots, the platform needs short-lived compute that scales with events—not another Auto Scaling group to patch. AWS Lambda runs your function code in managed execution environments: you package a handler, set memory and timeout, attach a role, and connect event sources. You pay for invocations and duration (per current pricing dimensions), not for idle instance hours—though idle integrations and forgotten functions still create operational and sometimes cost surprises.

    Module 1 taught cattle EC2. Lessons 12–13 taught edge entry and byte delivery. This lesson adds serverless compute for asynchronous and event-driven work on the progress platform. You will understand runtimes, handlers, execution roles, concurrency, cold starts at a practical level, layers, timeouts, VPC connectivity trade-offs, and failure handling—without inventing APIs or quoting memorized GB-second folklore. API Gateway and Serverless APIs places HTTP façades in front of Lambda next; here you build solid functions first.

    Learning Objectives

    By the end of this lesson you will be able to:

    1. Explain when Lambda fits TechLearningPro versus EC2/ECS.
    2. Describe the handler contract for common runtimes at a conceptual level.
    3. Package deployment artifacts (zip or container image) without secrets inside.
    4. Configure memory, timeout, ephemeral storage, and architecture (x86/arm) deliberately.
    5. Attach least-privilege execution roles for S3/DynamoDB/etc.
    6. Connect event sources such as S3 and understand permission models for invoke.
    7. Reason about concurrency, reserved concurrency, and throttling behavior.
    8. Explain cold starts practically without myth; mitigate with design, not folklore.
    9. Use layers for shared libraries cautiously; prefer thin functions.
    10. Handle failures with retries, destinations, and idempotent writes.
    11. Decide when VPC-attached Lambda is required and what it costs operationally.
    12. Observe functions with logs and basic metrics; prepare for deeper observability modules.
    13. Build an image-processing style workflow with explicit failure paths.
    14. Budget, tag, and delete lab functions, logs, and roles.
    15. Cross-link upcoming API Gateway without implementing it yet.

    Prerequisites

    • IAM lesson for roles and policies; CLI lesson for deploys.
    • S3 lesson for buckets used as event sources.
    • Budget alert before creating functions and generating invocations.
    • Optional Docker familiarity for container-based Lambda packaging—deep container work is lesson 16 and /learn/docker.
    • Progress data model awareness from lesson 10: do not write progress with unchecked retries.

    Detailed Core Concepts

    What Lambda is

    Lambda is event-driven compute: AWS runs your code when an event arrives or when you invoke the function directly. You do not manage guest OS patching for the execution environment in the EC2 sense. You still manage code quality, permissions, timeouts, dependency vulnerabilities, and data-plane correctness. “Serverless” means less undifferentiated server toil—not zero operations.

    Runtimes and handlers

    AWS provides managed runtimes (for example, current Node.js and Python versions—verify which versions are supported today). A handler is the entry function receiving an event and context. The event schema depends on the source (S3, API Gateway, SQS, EventBridge). Treat events as untrusted input: validate, do not log secrets, reject unexpected shapes.

    Custom runtimes and container images exist for specialized needs. Prefer managed runtimes until you have a reason. Container image Lambda must follow AWS’s base image and packaging contracts—verify current documentation.

    Deployment packages

    Zip packages upload code and dependencies (within size limits—check quotas). For larger dependencies, use container images or layers carefully. CI should build artifacts reproducibly. Never bake AWS access keys into packages. Configuration via environment variables is fine for non-secrets; secrets belong in Secrets Manager/SSM Parameter Store (lesson 21) with IAM-gated retrieval at runtime.

    Memory, CPU, timeout, ephemeral storage

    Memory setting influences available CPU for the execution environment (relationship documented by AWS). Timeout caps maximum duration—billable duration stops when the invocation ends, but a too-high timeout can hold concurrency during hangs. Ephemeral /tmp storage size is configurable within documented limits—clean it; do not treat it as durable storage. Choose architecture (arm64/x86_64) based on dependency compatibility and cost/performance after measurement.

    Execution role and resource policy

    The execution role grants the function permission to call AWS APIs. The resource-based policy on the function grants services or principals permission to invoke it. S3 bucket notifications need both: Lambda permission for S3 to invoke, and execution role for the function to read the object. Missing either side produces confusing failures.

    Concurrency

    Account and function concurrency limits throttle scale. Reserved concurrency caps a function and guarantees a portion of account concurrency. Provisioned concurrency keeps execution environments initialized to reduce cold starts for latency-sensitive paths—at additional cost dimensions. Progress webhooks that must not starve Monday board functions may need reserved concurrency isolation—design explicitly.

    Exact default quotas vary by account/Region and may be adjustable—check Service Quotas; do not invent numbers.

    Cold starts

    A cold start occurs when Lambda assigns a new execution environment. Impact varies by runtime, package size, VPC ENI attachment patterns, and memory. Mitigations: smaller packages, avoid unnecessary VPC, provisioned concurrency for critical interactive paths, prefer async where latency allows. Do not “fix” cold starts by running busy loops. Measure with your runtime.

    Layers

    Layers share libraries across functions. They complicate versioning and can bloat cold starts if misused. Prefer packaging dependencies with the function for small teams unless a clear shared platform layer exists with ownership.

    Event sources for this lesson’s narrative

    S3 event notifications trigger on object created—classic image/document processing. EventBridge, SNS, SQS, and API Gateway appear across Module 2; understand that each has different retry and failure semantics. SQS + Lambda provides partial batch failure handling patterns—verify current reportBatchItemFailures behavior in docs when you use it.

    VPC access

    Attach Lambda to private subnets to reach RDS or private endpoints. This introduces ENI management and potentially longer cold starts historically improved by AWS over time—still plan subnets and idle IP capacity. Prefer not placing Lambda in VPC unless needed. Access AWS APIs via VPC endpoints when in VPC without hairpinning NAT when possible.

    Observability basics

    Each invocation can write to CloudWatch Logs. Metrics include invocations, errors, throttles, duration. Structured logging beats print chaos. Do not log personally identifiable learner answers at debug level in production. X-Ray and OpenTelemetry arrive in Module 4.

    Architecture and Design Diagrams

    Image processing workflow:

    mermaid
    flowchart LR
    Teacher["Teacher upload"]
    S3raw["S3 raw bucket"]
    L["Lambda processor"]
    S3cdn["S3 CDN origin bucket"]
    DLQ["Failure destination / DLQ pattern"]
    Teacher --> S3raw --> L --> S3cdn
    L --> DLQ

    Identity boundaries:

    text
    S3 --resource policy--> invoke Lambda
    Lambda execution role --> s3:GetObject raw, s3:PutObject cdn prefix
    Lambda execution role --> optional KMS decrypt/encrypt
    No long-lived keys in code

    Concurrency isolation:

    mermaid
    flowchart TB
    Acc["Account concurrency pool"]
    Board["Reserved: progress-critical functions"]
    Batch["Unreserved: bulk image transforms"]
    Acc --> Board
    Acc --> Batch

    Technical Explanation

    Invoke path

    Event source or caller invokes Lambda service API. Lambda schedules an execution environment, injects credentials from the execution role, runs the handler, captures logs, returns result for synchronous invokes or acknowledges async processing. Failures follow the event source’s retry rules—S3 async invoke retries differ from SQS, which differ from synchronous API Gateway. Read the event source mapping documentation for the source you use.

    Idempotency for S3 events

    S3 may deliver duplicate notifications. If your function stamps a DynamoDB item “processed,” use conditional writes. If it writes an output object key derived deterministically from input key + version, retries become safe. Never charge a learner twice because a webhook retried—same discipline.

    Partial failure and destinations

    For async invokes, configure failure destinations (SNS/SQS/Lambda/EventBridge as supported) so failures leave a breadcrumb. For SQS, prefer bounded retries and a dead-letter queue. Silent failure is the enemy of Monday trust.

    Runtime lifecycle hooks and global state

    Reuse TCP connections and SDK clients across warm invocations via global initialization, carefully. Do not assume global mutable state is exclusive—concurrency means multiple environments. Do not store secrets in globals from previous tenants—environments are reused for the same function, not across random customers, but still avoid caching per-learner sensitive data in globals without care.

    Versions and aliases

    Publish versions for immutable deploy artifacts; aliases (live, canary) point to versions for traffic shifting. Useful before full CI/CD modules. Avoid $LATEST as production mental model when you need rollback.

    Container image functions

    Image must implement the Lambda Runtime API contract via AWS base images or custom runtime. Size affects pull times. Vulnerability scanning belongs with ECR in lesson 19. For this lesson’s zip-based lab, mention images as an option.

    Practical Implementation or Design Walkthrough

    Problem

    Build a Lambda function triggered by S3 uploads that validates an image content type, writes a processed/copied object to a destination prefix/bucket, handles failure without silent loss, and cleans up.

    Steps

    1. Budget alert on. Tags Project=tlp-lesson14.
    2. Create raw and destination buckets (or prefixes) with BPA on; block public access.
    3. Create execution role with least privilege GetObject on raw prefix, PutObject on destination prefix, and CloudWatch Logs permissions.
    4. Write handler (Python or Node) that validates key suffix/content type, processes (even if “process” is copy + metadata for the lab), writes output, and throws on poison files.
    5. Deploy zip; set memory/timeout modestly; architecture matching your deps.
    6. Add permission for S3 to invoke; configure event notification on ObjectCreated for a prefix.
    7. Success test: upload valid small PNG; see destination object; check logs.
    8. Failure tests: (a) upload non-image → function errors → verify retry/destination behavior you configured; (b) deny PutObject temporarily → observe failure; restore.
    9. Optional: set reserved concurrency low in lab to observe throttling under parallel uploads.
    10. Cleanup: delete notifications, function versions, log groups if appropriate, roles, buckets/objects, free lab KMS aliases if any.

    Illustrative handler shape (not production-hardened)

    python
    # Illustrative only — validate against current boto3 and runtime docs
    import json
    import urllib.parse
    import boto3
    s3 = boto3.client("s3")
    DEST_BUCKET = None # set via env var non-secret name
    def handler(event, context):
    for record in event.get("Records", []):
    bucket = record["s3"]["bucket"]["name"]
    key = urllib.parse.unquote_plus(record["s3"]["object"]["key"])
    if not key.lower().endswith((".png", ".jpg", ".jpeg", ".webp")):
    raise ValueError("unsupported object key")
    # deterministic destination key supports idempotent retries
    dest_key = f"processed/{key}"
    s3.copy_object(
    Bucket=DEST_BUCKET,
    CopySource={"Bucket": bucket, "Key": key},
    Key=dest_key,
    MetadataDirective="REPLACE",
    Metadata={"tlp-processed": "true"},
    )
    return {"ok": True}

    Do not hardcode credentials. Set DEST_BUCKET via encrypted environment configuration as appropriate; prefer SSM/Secrets for sensitive values later.

    Enterprise Real-World Scenarios

    TechLearningPro: thumbnail storm

    A viral free lesson caused thousands of uploads. Unreserved concurrency starved a synchronous Lambda behind a critical path. Fix: reserved concurrency for critical functions; queue buffering for bulk transforms; backlog alerts.

    Secrets in environment variables

    An API key in plain env vars appeared in console screenshots and CloudFormation exports. Fix: Secrets Manager + IAM; rotate; scrub logs; train reviewers.

    VPC Lambda for S3 only

    Team attached VPC “for security” though the function only talked to S3. They paid NAT and complexity. Fix: no VPC for AWS public API-only functions; use bucket policies and private buckets instead.

    Silent S3 failures

    Missing failure destination; poison PDF retried until ignored; teachers thought uploads worked. Fix: DLQ/destination + alarm on DLQ depth.

    Giant deployment package

    Bundled unused ML libraries; cold starts painful; deploys slow. Fix: slim package; move heavy work to container batch or ECS jobs.

    Best Practices

    • Least-privilege execution roles and explicit invoke permissions.
    • Idempotent handlers for at-least-once sources.
    • Tight timeouts with intentional async redesign for long work.
    • Structured logs without secrets or full PII.
    • Separate critical concurrency from batch.
    • Prefer managed runtimes; pin versions deliberately.
    • Tag functions and related log groups.
    • Budget before load tests.
    • Avoid VPC unless required.
    • Use versions/aliases for rollback stories.
    • Validate event schemas.
    • Clean /tmp.
    • Monitor throttles and errors, not only happy invocations.
    • Delete lab functions and notifications promptly.
    • Document retry semantics per event source.

    Common Mistakes and Anti-Patterns

    Admin-equivalent execution role. Blast radius = account.
    Non-idempotent payment or progress writes. Duplicate events corrupt state.
    Timeout equal to max with hanging outbound calls. Concurrency exhaustion.
    Logging entire events including tokens. Data leak.
    VPC attachment without endpoints/NAT plan. Mysterious timeouts.
    Catching all exceptions and returning success. Silent data loss.
    Unbounded recursive invokes. Cost and runaway.
    Invented runtime APIs or deprecated runtimes. Broken deploys.
    Storing durable state only in /tmp. Loss on recycle.
    Leaving event sources pointing at deleted functions. Noise and failed invokes.

    Troubleshooting and Design Review

    Permission errors. Distinguish execution role vs resource policy.
    No invokes. Event notification misconfigured; wrong prefix; permission missing.
    Timeouts. Downstream latency; too-low timeout; VPC routing.
    Throttles. Concurrency caps; burst; reserved settings.
    Intermittent failures. Size limits; ephemeral storage; dependency DNS.

    Design review exit: role scoped; idempotency story; failure destination; tags; budget; cleanup; no secrets in package.

    Interview Questions and Answers

    Q1. When is Lambda better than EC2 for TechLearningPro?
    Event-driven, spiky, short tasks: uploads, webhooks, transforms—not always for steady WebSocket boards.

    Q2. Execution role vs resource policy?
    Role: what Lambda can call. Resource policy: who can invoke Lambda.

    Q3. How do you handle S3 duplicate events?
    Idempotent outputs/conditional writes.

    Q4. What is reserved concurrency?
    Per-function cap that also reserves capacity from the account pool.

    Q5. Cold start mitigations?
    Smaller packages, avoid needless VPC, provisioned concurrency when justified, async where OK.

    Q6. Why not put secrets in deployment packages?
    Extractable; leaked in artifacts; hard to rotate.

    Q7. How does memory setting affect performance?
    Influences CPU allocation per AWS’s documented relationship; measure.

    Q8. What metrics matter first?
    Errors, throttles, duration, concurrent executions.

    Q9. Lambda in VPC for RDS—what to plan?
    Subnets, IPs, SG, endpoints/NAT, timeouts.

    Q10. Versions and aliases purpose?
    Immutable releases and traffic shifting/rollback.

    Q11. Can Lambda replace the progress API ASG entirely?
    Sometimes with API Gateway; trade cold starts, timeouts, connection patterns—decision, not slogan.

    Q12. Pricing dimensions?
    Invocations, GB-seconds, provisioned concurrency, data transfer, etc.—check current pricing page.

    Hands-On Exercises

    Budget + cleanup required

    Enable budget. After lab delete notifications, functions, log groups you created for the lab, roles, objects/buckets. Confirm tagged inventory empty.

    Exercise: Image-processing workflow with failure handling

    Implement walkthrough with success + two failures + DLQ/destination evidence.

    Challenge

    ADR: zip vs container image for a future OCR pipeline with large native deps; include cold start and CVE scanning ownership. No production data.

    Worked narrative

    Platform receives teacher PNG uploads to raw/. Lambda validates and writes processed/ keys consumed by a promotion job to the CloudFront origin bucket from lesson 13. Failures land on an SQS DLQ with alarm. Reserved concurrency protects a separate entitlement-check function used at signed URL mint time. Cost Explorer filtered by Project=tlp-lesson14 shows only lab-period invoke costs after cleanup.

    Deep dive: timeout vs downstream

    If the function calls a slow OCR API, raising timeout may increase billable duration and hold concurrency. Better: accept S3 event, enqueue work, return quickly, process with a worker that can run longer on ECS/Batch, or use asynchronous patterns with Step Functions later. Lambda max timeout is documented by AWS—do not invent it; look it up when designing.

    Deep dive: power tuning mindset

    Increasing memory can decrease duration enough to reduce cost for CPU-bound work—or increase cost if duration does not fall. Empirically test a few memory sizes. Record results. Do not copy a blog’s “always 3008 MB” advice.

    Extended platform narrative: TechLearningPro and AWS Lambda

    TechLearningPro’s Monday board remains the reliability north star. Every service introduced in Module 2 must explain how it protects or threatens that board. Event-driven pieces should fail without corrupting progress records. Asynchronous pipelines should surface failures to operators through measurable alarms later in Module 4, even when this lesson only configures foundational metrics. Cost tags must continue the dictionary from lesson 11. Security groups, IAM roles, and secret handling must continue least privilege from Module 1. When a design conflicts with those constraints, the design loses unless product explicitly accepts a written risk with expiry.

    The teaching team uses sandbox accounts with budgets. Students who leave billable resources overnight fail the cleanup portion of the rubric even if the happy path worked. That rule mirrors production: the unfinished cleanup is an operational incident waiting for a calendar.

    Extended technical deepener: identity boundaries

    Every compute unit—instance, function, task—needs an identity. Prefer roles over long-lived access keys. Scope resource ARNs to prefixes and tags when policies support it. Deny * on sensitive actions in student labs when possible. Never embed credentials in images, environment variables committed to git, or screenshots in tickets. Rotation stories belong with Secrets Manager in a later lesson; until then, do not invent a secret store—use IAM roles and temporary credentials.

    Cross-account patterns appear in Module 5. For now, keep labs in one account unless your instructor provides a second. Do not invent trust policies that reference accounts you do not control.

    Extended technical deepener: networking choices

    Public reachability should be intentional. Functions and containers that only talk to AWS APIs and VPC resources should not receive public IPs by habit. When VPC connectivity is enabled for serverless or containers, plan ENI capacity, subnet IP free space, and routing to endpoints or NAT. NAT hours remain a Cost Explorer villain from Module 1. Prefer interface/gateway endpoints for AWS APIs where they fit. Document the trade-off if a lab uses default outbound networking without VPC for simplicity, and state what production would add.

    Extended reliability deepener: retries and idempotency

    Distributed platforms retry. Progress writes must be idempotent where at-least-once delivery exists. Use idempotency keys for submission posts, conditional writes, or upsert patterns appropriate to your data store. Blind retries without backoff amplify outages. Dead-letter queues appear with SQS and Lambda destinations in later lessons—preview the idea now: poison messages need a parking lot, not infinite retry storms.

    Extended performance deepener: measure before scaling theater

    Change one variable at a time. Record p50/p95 latency and error rate before and after. Warm capacity, cold starts, cache hit ratios, and database RCU/WCU or connection pools present different bottlenecks. Do not raise memory, concurrency, replica count, and timeout simultaneously and call it science.

    Extended cost deepener: dimensions checklist

    List pricing dimensions from the official pricing page for each service you touch: hours, requests, duration, memory-GB-seconds, data transfer, storage, and idle managed resources. Mark every number in homework as “looked up on DATE” or “illustrative only.” This course fails invented tariffs.

    Extended security deepener: threat sketch for the lab

    Who can invoke? Who can change code or images? Who can read data? What is logged? What is encrypted? What happens if a dependency is compromised? Answer in bullets in the deliverable. Perfect STRIDE papers are unnecessary; silence is unacceptable.

    Extended operations deepener: evidence packet

    Architecture diagram, IAM role summaries, network notes, success test, two failure tests, budget proof, cleanup proof, ADR for one controversial choice. Redact account IDs if publishing outside the org. Store evidence in the student’s learning progress system metaphorically—the same care you want for learner data.

    Extended interview practice block

    Practice a two-minute story: problem, constraints, decision, evidence, cleanup. Interviewers hire judgment. Mention Well-Architected pillars by behavior, not by buzzword shower. Admit what you would verify in current docs rather than bluffing quotas.

    Extended anti-pattern gallery

    Snowflake consoles without IaC notes; copy-paste policies with Action: *; public access “for debugging”; disabling authentication in staging that shares data with production shapes; infinite retention on debug buckets; ignoring blast radius of account-level wildcards; assuming free tier covers forgotten ALBs and NAT; treating success of a single curl as production readiness.

    Extended game-day suggestions

    Break health checks; revoke a permission; fill a subnet; expire a credential; block an outbound path; inject latency. Observe alarms and user impact. Restore via runbook. Write what the runbook missed. Game days turn Module 2 from tourism into operations.

    Extended cleanup ritual

    List resources by tag. Delete in dependency order. Confirm console empty for those tags across Regions you used. Recheck Cost Explorer later for residual storage. Leave budgets enabled. Thank your future self.

    Continuity anchors across Module 2

    Lesson 12 edge for HTTP fleets. Lesson 13 edge for bytes. Lesson 14 functions for events. Lesson 15 managed API façade. Lesson 16 packaging discipline. Lesson 17 orchestrated containers. Each builds on IAM, VPC, and cost habits rather than replacing them.

    Additional design note 1 for AWS Lambda

    When implementing AWS Lambda for TechLearningPro, write the user-visible failure mode first. If Monday’s board cannot accept progress writes, the feature is not “eventually fine”—it is an incident. Define timeouts, partial-failure behavior, and operator visibility before enabling traffic. Prefer small blast radius rollouts. Keep personal data out of logs. Keep secrets out of images and source. Verify service behavior against AWS documentation current as of your lab date, including regional availability of any optional feature you hope to use. If a feature is preview or Region-limited, say so explicitly in the ADR rather than assuming global GA. Connect tags to Cost Explorer filters so this lab’s spend can be isolated from other Module 2 experiments. Schedule cleanup immediately after evidence capture; do not wait for a weekly hygiene day that never comes.

    Additional design note 2 for AWS Lambda

    When implementing AWS Lambda for TechLearningPro, write the user-visible failure mode first. If Monday’s board cannot accept progress writes, the feature is not “eventually fine”—it is an incident. Define timeouts, partial-failure behavior, and operator visibility before enabling traffic. Prefer small blast radius rollouts. Keep personal data out of logs. Keep secrets out of images and source. Verify service behavior against AWS documentation current as of your lab date, including regional availability of any optional feature you hope to use. If a feature is preview or Region-limited, say so explicitly in the ADR rather than assuming global GA. Connect tags to Cost Explorer filters so this lab’s spend can be isolated from other Module 2 experiments. Schedule cleanup immediately after evidence capture; do not wait for a weekly hygiene day that never comes.

    Additional design note 3 for AWS Lambda

    When implementing AWS Lambda for TechLearningPro, write the user-visible failure mode first. If Monday’s board cannot accept progress writes, the feature is not “eventually fine”—it is an incident. Define timeouts, partial-failure behavior, and operator visibility before enabling traffic. Prefer small blast radius rollouts. Keep personal data out of logs. Keep secrets out of images and source. Verify service behavior against AWS documentation current as of your lab date, including regional availability of any optional feature you hope to use. If a feature is preview or Region-limited, say so explicitly in the ADR rather than assuming global GA. Connect tags to Cost Explorer filters so this lab’s spend can be isolated from other Module 2 experiments. Schedule cleanup immediately after evidence capture; do not wait for a weekly hygiene day that never comes.

    Additional design note 4 for AWS Lambda

    When implementing AWS Lambda for TechLearningPro, write the user-visible failure mode first. If Monday’s board cannot accept progress writes, the feature is not “eventually fine”—it is an incident. Define timeouts, partial-failure behavior, and operator visibility before enabling traffic. Prefer small blast radius rollouts. Keep personal data out of logs. Keep secrets out of images and source. Verify service behavior against AWS documentation current as of your lab date, including regional availability of any optional feature you hope to use. If a feature is preview or Region-limited, say so explicitly in the ADR rather than assuming global GA. Connect tags to Cost Explorer filters so this lab’s spend can be isolated from other Module 2 experiments. Schedule cleanup immediately after evidence capture; do not wait for a weekly hygiene day that never comes.

    Additional design note 5 for AWS Lambda

    When implementing AWS Lambda for TechLearningPro, write the user-visible failure mode first. If Monday’s board cannot accept progress writes, the feature is not “eventually fine”—it is an incident. Define timeouts, partial-failure behavior, and operator visibility before enabling traffic. Prefer small blast radius rollouts. Keep personal data out of logs. Keep secrets out of images and source. Verify service behavior against AWS documentation current as of your lab date, including regional availability of any optional feature you hope to use. If a feature is preview or Region-limited, say so explicitly in the ADR rather than assuming global GA. Connect tags to Cost Explorer filters so this lab’s spend can be isolated from other Module 2 experiments. Schedule cleanup immediately after evidence capture; do not wait for a weekly hygiene day that never comes.

    Additional design note 6 for AWS Lambda

    When implementing AWS Lambda for TechLearningPro, write the user-visible failure mode first. If Monday’s board cannot accept progress writes, the feature is not “eventually fine”—it is an incident. Define timeouts, partial-failure behavior, and operator visibility before enabling traffic. Prefer small blast radius rollouts. Keep personal data out of logs. Keep secrets out of images and source. Verify service behavior against AWS documentation current as of your lab date, including regional availability of any optional feature you hope to use. If a feature is preview or Region-limited, say so explicitly in the ADR rather than assuming global GA. Connect tags to Cost Explorer filters so this lab’s spend can be isolated from other Module 2 experiments. Schedule cleanup immediately after evidence capture; do not wait for a weekly hygiene day that never comes.

    Additional design note 7 for AWS Lambda

    When implementing AWS Lambda for TechLearningPro, write the user-visible failure mode first. If Monday’s board cannot accept progress writes, the feature is not “eventually fine”—it is an incident. Define timeouts, partial-failure behavior, and operator visibility before enabling traffic. Prefer small blast radius rollouts. Keep personal data out of logs. Keep secrets out of images and source. Verify service behavior against AWS documentation current as of your lab date, including regional availability of any optional feature you hope to use. If a feature is preview or Region-limited, say so explicitly in the ADR rather than assuming global GA. Connect tags to Cost Explorer filters so this lab’s spend can be isolated from other Module 2 experiments. Schedule cleanup immediately after evidence capture; do not wait for a weekly hygiene day that never comes.

    Student reflection prompts

    What did you delete? What would you automate next? Which permission was hardest to scope? Which failure test surprised you? What would you refuse to run in production from this lab’s shortcuts?

    Expansion block 1: AWS Lambda in the TechLearningPro progress platform

    Operators responsible for Monday’s board treat AWS Lambda as part of a larger reliability story rather than a standalone lab toy. Before enabling traffic, they write the failure mode in one sentence: what the learner sees, what the teacher sees, and what the on-call engineer sees. They define which metrics prove health and which logs are permitted to contain curriculum metadata versus forbidden raw assessment answers. They confirm IAM roles follow least privilege with resource ARNs scoped to tlp-* prefixes where possible. They confirm network exposure is intentional: no public open management ports, no world-writable buckets, no secrets in deployment artifacts. They confirm a budget alert is active and that Cost Explorer can filter this workload by tags after billing delay. They schedule cleanup or transfer ownership with an expiry tag.

    Design discussions for AWS Lambda should compare alternatives honestly. Sometimes EC2 or ECS is clearer for long-lived WebSocket lesson rooms; sometimes Lambda is clearer for bursty upload processing; sometimes API Gateway is unnecessary if ALB already exposes the fleet; sometimes CloudFront should serve bytes that developers mistakenly wanted to stream from compute. Choosing the smaller blast radius usually beats choosing the newest service name. When unsure, prototype in sandbox with budgets, measure, then write an ADR.

    Implementation hygiene for AWS Lambda includes reproducible builds, pinned runtime or base image versions that are currently supported, automated tests for the success path and at least two failure paths, and evidence captured for homework or change tickets. Avoid relying on click-ops alone for anything you will need to recreate after an account scrub. Module 3 will industrialize IaC; Module 2 still expects you to document every console click you cannot yet express as code.

    Security reviews ask whether authorization happens before expensive work, whether tenancy isolation holds under retries, whether signing keys or tokens can leak via logs, and whether destructive IAM actions are constrained. Reliability reviews ask about timeouts, retries, idempotency, multi-AZ dependencies, and dead-letter paths. Performance reviews ask what the bottleneck is after a simple load test. Cost reviews ask which pricing dimensions dominate and whether idle resources remain. Sustainability reviews ask whether idle capacity or duplicate storage can be removed. These questions are the Well-Architected habit from lesson 11 applied to AWS Lambda.

    If documentation and this lesson ever appear to disagree on a flag name, quota, or regional feature, trust current AWS documentation and note the access date in your deliverable. This course explicitly forbids inventing features to sound advanced. Interview answers that include “I would verify the current quota in Service Quotas” score higher than fabricated precision.

    Expansion block 2: AWS Lambda in the TechLearningPro progress platform

    Operators responsible for Monday’s board treat AWS Lambda as part of a larger reliability story rather than a standalone lab toy. Before enabling traffic, they write the failure mode in one sentence: what the learner sees, what the teacher sees, and what the on-call engineer sees. They define which metrics prove health and which logs are permitted to contain curriculum metadata versus forbidden raw assessment answers. They confirm IAM roles follow least privilege with resource ARNs scoped to tlp-* prefixes where possible. They confirm network exposure is intentional: no public open management ports, no world-writable buckets, no secrets in deployment artifacts. They confirm a budget alert is active and that Cost Explorer can filter this workload by tags after billing delay. They schedule cleanup or transfer ownership with an expiry tag.

    Design discussions for AWS Lambda should compare alternatives honestly. Sometimes EC2 or ECS is clearer for long-lived WebSocket lesson rooms; sometimes Lambda is clearer for bursty upload processing; sometimes API Gateway is unnecessary if ALB already exposes the fleet; sometimes CloudFront should serve bytes that developers mistakenly wanted to stream from compute. Choosing the smaller blast radius usually beats choosing the newest service name. When unsure, prototype in sandbox with budgets, measure, then write an ADR.

    Implementation hygiene for AWS Lambda includes reproducible builds, pinned runtime or base image versions that are currently supported, automated tests for the success path and at least two failure paths, and evidence captured for homework or change tickets. Avoid relying on click-ops alone for anything you will need to recreate after an account scrub. Module 3 will industrialize IaC; Module 2 still expects you to document every console click you cannot yet express as code.

    Security reviews ask whether authorization happens before expensive work, whether tenancy isolation holds under retries, whether signing keys or tokens can leak via logs, and whether destructive IAM actions are constrained. Reliability reviews ask about timeouts, retries, idempotency, multi-AZ dependencies, and dead-letter paths. Performance reviews ask what the bottleneck is after a simple load test. Cost reviews ask which pricing dimensions dominate and whether idle resources remain. Sustainability reviews ask whether idle capacity or duplicate storage can be removed. These questions are the Well-Architected habit from lesson 11 applied to AWS Lambda.

    If documentation and this lesson ever appear to disagree on a flag name, quota, or regional feature, trust current AWS documentation and note the access date in your deliverable. This course explicitly forbids inventing features to sound advanced. Interview answers that include “I would verify the current quota in Service Quotas” score higher than fabricated precision.

    Expansion block 3: AWS Lambda in the TechLearningPro progress platform

    Operators responsible for Monday’s board treat AWS Lambda as part of a larger reliability story rather than a standalone lab toy. Before enabling traffic, they write the failure mode in one sentence: what the learner sees, what the teacher sees, and what the on-call engineer sees. They define which metrics prove health and which logs are permitted to contain curriculum metadata versus forbidden raw assessment answers. They confirm IAM roles follow least privilege with resource ARNs scoped to tlp-* prefixes where possible. They confirm network exposure is intentional: no public open management ports, no world-writable buckets, no secrets in deployment artifacts. They confirm a budget alert is active and that Cost Explorer can filter this workload by tags after billing delay. They schedule cleanup or transfer ownership with an expiry tag.

    Design discussions for AWS Lambda should compare alternatives honestly. Sometimes EC2 or ECS is clearer for long-lived WebSocket lesson rooms; sometimes Lambda is clearer for bursty upload processing; sometimes API Gateway is unnecessary if ALB already exposes the fleet; sometimes CloudFront should serve bytes that developers mistakenly wanted to stream from compute. Choosing the smaller blast radius usually beats choosing the newest service name. When unsure, prototype in sandbox with budgets, measure, then write an ADR.

    Implementation hygiene for AWS Lambda includes reproducible builds, pinned runtime or base image versions that are currently supported, automated tests for the success path and at least two failure paths, and evidence captured for homework or change tickets. Avoid relying on click-ops alone for anything you will need to recreate after an account scrub. Module 3 will industrialize IaC; Module 2 still expects you to document every console click you cannot yet express as code.

    Security reviews ask whether authorization happens before expensive work, whether tenancy isolation holds under retries, whether signing keys or tokens can leak via logs, and whether destructive IAM actions are constrained. Reliability reviews ask about timeouts, retries, idempotency, multi-AZ dependencies, and dead-letter paths. Performance reviews ask what the bottleneck is after a simple load test. Cost reviews ask which pricing dimensions dominate and whether idle resources remain. Sustainability reviews ask whether idle capacity or duplicate storage can be removed. These questions are the Well-Architected habit from lesson 11 applied to AWS Lambda.

    If documentation and this lesson ever appear to disagree on a flag name, quota, or regional feature, trust current AWS documentation and note the access date in your deliverable. This course explicitly forbids inventing features to sound advanced. Interview answers that include “I would verify the current quota in Service Quotas” score higher than fabricated precision.

    Expansion block 4: AWS Lambda in the TechLearningPro progress platform

    Operators responsible for Monday’s board treat AWS Lambda as part of a larger reliability story rather than a standalone lab toy. Before enabling traffic, they write the failure mode in one sentence: what the learner sees, what the teacher sees, and what the on-call engineer sees. They define which metrics prove health and which logs are permitted to contain curriculum metadata versus forbidden raw assessment answers. They confirm IAM roles follow least privilege with resource ARNs scoped to tlp-* prefixes where possible. They confirm network exposure is intentional: no public open management ports, no world-writable buckets, no secrets in deployment artifacts. They confirm a budget alert is active and that Cost Explorer can filter this workload by tags after billing delay. They schedule cleanup or transfer ownership with an expiry tag.

    Design discussions for AWS Lambda should compare alternatives honestly. Sometimes EC2 or ECS is clearer for long-lived WebSocket lesson rooms; sometimes Lambda is clearer for bursty upload processing; sometimes API Gateway is unnecessary if ALB already exposes the fleet; sometimes CloudFront should serve bytes that developers mistakenly wanted to stream from compute. Choosing the smaller blast radius usually beats choosing the newest service name. When unsure, prototype in sandbox with budgets, measure, then write an ADR.

    Implementation hygiene for AWS Lambda includes reproducible builds, pinned runtime or base image versions that are currently supported, automated tests for the success path and at least two failure paths, and evidence captured for homework or change tickets. Avoid relying on click-ops alone for anything you will need to recreate after an account scrub. Module 3 will industrialize IaC; Module 2 still expects you to document every console click you cannot yet express as code.

    Security reviews ask whether authorization happens before expensive work, whether tenancy isolation holds under retries, whether signing keys or tokens can leak via logs, and whether destructive IAM actions are constrained. Reliability reviews ask about timeouts, retries, idempotency, multi-AZ dependencies, and dead-letter paths. Performance reviews ask what the bottleneck is after a simple load test. Cost reviews ask which pricing dimensions dominate and whether idle resources remain. Sustainability reviews ask whether idle capacity or duplicate storage can be removed. These questions are the Well-Architected habit from lesson 11 applied to AWS Lambda.

    If documentation and this lesson ever appear to disagree on a flag name, quota, or regional feature, trust current AWS documentation and note the access date in your deliverable. This course explicitly forbids inventing features to sound advanced. Interview answers that include “I would verify the current quota in Service Quotas” score higher than fabricated precision.

    Expansion block 5: AWS Lambda in the TechLearningPro progress platform

    Operators responsible for Monday’s board treat AWS Lambda as part of a larger reliability story rather than a standalone lab toy. Before enabling traffic, they write the failure mode in one sentence: what the learner sees, what the teacher sees, and what the on-call engineer sees. They define which metrics prove health and which logs are permitted to contain curriculum metadata versus forbidden raw assessment answers. They confirm IAM roles follow least privilege with resource ARNs scoped to tlp-* prefixes where possible. They confirm network exposure is intentional: no public open management ports, no world-writable buckets, no secrets in deployment artifacts. They confirm a budget alert is active and that Cost Explorer can filter this workload by tags after billing delay. They schedule cleanup or transfer ownership with an expiry tag.

    Design discussions for AWS Lambda should compare alternatives honestly. Sometimes EC2 or ECS is clearer for long-lived WebSocket lesson rooms; sometimes Lambda is clearer for bursty upload processing; sometimes API Gateway is unnecessary if ALB already exposes the fleet; sometimes CloudFront should serve bytes that developers mistakenly wanted to stream from compute. Choosing the smaller blast radius usually beats choosing the newest service name. When unsure, prototype in sandbox with budgets, measure, then write an ADR.

    Implementation hygiene for AWS Lambda includes reproducible builds, pinned runtime or base image versions that are currently supported, automated tests for the success path and at least two failure paths, and evidence captured for homework or change tickets. Avoid relying on click-ops alone for anything you will need to recreate after an account scrub. Module 3 will industrialize IaC; Module 2 still expects you to document every console click you cannot yet express as code.

    Security reviews ask whether authorization happens before expensive work, whether tenancy isolation holds under retries, whether signing keys or tokens can leak via logs, and whether destructive IAM actions are constrained. Reliability reviews ask about timeouts, retries, idempotency, multi-AZ dependencies, and dead-letter paths. Performance reviews ask what the bottleneck is after a simple load test. Cost reviews ask which pricing dimensions dominate and whether idle resources remain. Sustainability reviews ask whether idle capacity or duplicate storage can be removed. These questions are the Well-Architected habit from lesson 11 applied to AWS Lambda.

    If documentation and this lesson ever appear to disagree on a flag name, quota, or regional feature, trust current AWS documentation and note the access date in your deliverable. This course explicitly forbids inventing features to sound advanced. Interview answers that include “I would verify the current quota in Service Quotas” score higher than fabricated precision.

    Lesson Summary

    AWS Lambda gives TechLearningPro event-driven compute with managed execution environments, least-privilege roles, deliberate concurrency, and idempotent handlers. Use it for uploads, webhooks, and transforms; keep durable state in proper stores; observe errors and throttles; clean up labs. Next, API Gateway exposes synchronous HTTP APIs in front of functions with authz and throttling.

    API Gateway and Serverless APIs continues the serverless path for learner-facing and partner HTTP interfaces.

    Further Reading

    Ready to mark this lesson complete?Track your journey across the entire course.