DVA-C03

Introduction to AWS Lambda

Serverless compute that runs your code in response to events.

  • 12 lessons
  • Module quiz

Traditionally, running code in the cloud means running servers: choosing their size, installing the operating system and runtime, patching them, scaling them with demand and paying for them even when they are idle. Many applications, however, consist of short pieces of code that run in response to something happening, such as an HTTP request, a file upload or a message arriving in a queue.

AWS Lambda is a serverless compute service built for this kind of code. The developer uploads a function and configures which events invoke it, and Lambda runs a copy of the function for each event, scaling from zero to thousands of concurrent copies automatically. AWS manages the servers, operating system, patching and availability. Lambda is charged per request and for the compute time used, measured in gigabyte-seconds, so a function that is not invoked costs nothing.

Where Lambda fits

Lambda is the most heavily tested service on the Developer Associate exam and appears in almost every other module, because it is the compute behind most serverless applications. API Gateway invokes it for API requests, Amazon S3 and Amazon EventBridge invoke it when events occur, and it reads messages from Amazon SQS, Amazon Kinesis and DynamoDB Streams. Lambda has limits that shape when it is suitable: a function can run for at most 15 minutes and use up to 10,240 MB of memory, so long-running or very large workloads belong on other services such as AWS Fargate.

How this module is organised

The module contains twelve lessons. Understanding Lambda Functions, Handlers and Runtimes introduces the programming model, packaging, logging and pricing. The module then explains how functions run: Choosing Between Synchronous, Asynchronous and Event Source Mapping Invocations explains the three ways a function is invoked and how errors are retried, Configuring Memory, Timeouts and Quotas for Performance and Cost covers memory, timeouts and start-up time, and Managing Concurrency, Throttling and Cold Starts explains how Lambda scales and how to control it. Releasing Function Changes with Versions and Aliases explains how releases are managed. The next four lessons cover packaging, access control, private networking and add-on tools: Sharing Code and Dependencies with Layers, Granting Permissions with Execution Roles and Resource-Based Policies, Connecting Functions to Private Resources in a VPC and Adding Monitoring and Secrets Caching with Extensions. Exposing Functions with Function URLs and Response Streaming explains how functions are called directly over HTTPS. The module ends with Applying Lambda Best Practices for Performance, Reliability and Security and Making Functions Idempotent to Handle Duplicate Events, which bring these ideas together into reliable function design.

  1. Understanding Lambda Functions, Handlers and Runtimes Lesson 1
  2. Choosing Between Synchronous, Asynchronous and Event Source Mapping Invocations Lesson 2
  3. Configuring Memory, Timeouts and Quotas for Performance and Cost Lesson 3
  4. Managing Concurrency, Throttling and Cold Starts Lesson 4
  5. Releasing Function Changes with Versions and Aliases Lesson 5
  6. Sharing Code and Dependencies with Layers Lesson 6
  7. Granting Permissions with Execution Roles and Resource-Based Policies Lesson 7
  8. Connecting Functions to Private Resources in a VPC Lesson 8
  9. Adding Monitoring and Secrets Caching with Extensions Lesson 9
  10. Exposing Functions with Function URLs and Response Streaming Lesson 10
  11. Applying Lambda Best Practices for Performance, Reliability and Security Lesson 11
  12. Making Functions Idempotent to Handle Duplicate Events Lesson 12
  13. Practise and review
  14. Checkpoint Practice activities across the module
  15. Test your knowledge 13 questions