Skip to content

Chapter 4 of 8

Serverless with Lambda

AWS Lambda is the serverless compute layer at the heart of many event-driven workloads. Each invocation runs inside an execution context, a runtime environment that hosts the function code, runtime, environment variables, and any initialized state. When Lambda reuses an execution context across invocations, initialization cost is amortized, but the first invocation against a new context pays a cold start penalty from downloading the code, starting the runtime, and running init code. Provisioned Concurrency, or simply minimizing package size and init logic, mitigates that latency.

Lambda has several hard limits to keep in mind. The deployment package can be up to 50 MB zipped or 250 MB unzipped for direct upload, and up to 4 GB when uploaded into /tmp via an EFS mount, which is how large files are handled. The default and maximum timeout is 900 seconds (15 minutes), so longer workflows should be decomposed, for example using Step Functions. Memory can be configured from 128 MB to 10,240 MB in 1 MB increments, with CPU and network bandwidth scaling linearly with memory. The default account-wide concurrency limit is 1,000 concurrent executions, which can be tuned via reserved concurrency or warmed up on demand via Provisioned Concurrency.

To define and deploy serverless applications, AWS SAM (Serverless Application Model) provides an open-source CloudFormation extension with simplified YAML and JSON syntax for Lambda, API Gateway, DynamoDB, SQS, and similar resources. With sam build and sam deploy, the SAM template is transformed into a standard CloudFormation stack at deploy time. SAM is the typical companion to hand-written CloudFormation for serverless workloads and lets developers express function URLs, event sources, and IAM permissions concisely.

All chapters
  1. 1AWS Foundations and the Shared Responsibility Model
  2. 2Identity, Access, and Authentication
  3. 3Compute, Containers, and Deployment
  4. 4Serverless with Lambda
  5. 5Storage on AWS
  6. 6Networking and Application Delivery
  7. 7Databases, Messaging, and Event-Driven Integration
  8. 8Observability, Security, and DevOps Practices

Drill it

Reading is not remembering. These come from the AWS Developer Associate Dva C02 deck:

Q

What does the AWS shared responsibility model define?

The division of security responsibilities between AWS (security OF the cloud: infrastructure, hardware, regions, services) and the customer (security IN the clo...

Q

Which AWS service is required to launch an EC2 instance?

An AMI (Amazon Machine Image), an instance type, a VPC with subnet, a security group, an IAM role/credentials, and optionally key pair and EBS volume.

Q

What is an IAM role vs an IAM user?

An IAM user is a permanent identity with long-lived credentials. An IAM role is an identity with no long-lived credentials that is assumed temporarily by users,...

Q

What is the maximum size of an IAM policy?

5,120 characters for managed policies attached to a user/group/role; service-specific quotas apply (e.g. inline user policy up to 2,048 chars, group 5,120, role...