Lambda Flashcards
What is Serverless?
- Serverless is a new paradigm in which the developers don’t have to manage servers anymore…
- They just deploy code
- They just deploy… functions!
- Initially… Serverless == FaaS (Function as a Service)
- Serverless was pioneered by AWS Lambda but now also includes anything that’s managed: “databases, messaging, storage, etc.”
- Serverless does not mean there are no servers… it means you just don’t manage / provision / see them
What are the Serverless services in AWS?
- AWS Lambda
- DynamoDB
- AWS Cognito
- AWS API Gateway
- Amazon S3
- AWS SNS & SQS
- AWS Kinesis Data Firehose
- Aurora Serverless
- Step Functions
- Fargate
What platform is not for Lambda?
Docker
Apart from the supported programming languages by Lambda, what else can you do?
Custom Runtime API (community supported, example Rust)
What is Lambda pricing by call?
Pay per calls:
o First 1,000,000 requests are free
o $0.20 per 1 million requests thereafter ($0.0000002 per request)
What is Lambda pricing by duration?
Pay per duration: (in increment of 100ms, round up)
o 400,000 GB-seconds of compute time per month if FREE
o == 400,000 seconds if function is 1GB RAM
o == 3,200,000 seconds if function is 128 MB RAM
o After that $1.00 for 600,000 GB-seconds
How is calculated the duration of your Lambda?
To the nearest multiple of 100 ms, rounded up. This means that if your function ran in 1 ms you are billed for 100 ms
What is the Lambda Handler?
Handler = name of the file + “.” + name of the function
What is Lambda Execution Role?
A role to interact with the necessary services, it should allow you at least to upload logs to CloudWatch logs because each function invocation will create a new log stream in CloudWatch
What is best practice regarding to Lambda functions and the Role executions?
It is best practice to maintain 1 role per function.
How are Lambda invocations?
Sync and Asyc
What are the main service that invoke Lambda sync?
o ALB o API Gateway o CloudFront (Lambda@Edge) o CLI o SDK o Cognito o Step Functions
How can you expose a Lambda function as an HTTP(S) endpoint?
Using an ALB or API Gateway
What you must do to expose Lambda as an HTTP(S) endpoint using ALB?
The Lambda function must be registered in a target group
What particularity has ALB health checks for Lambda?
Health checks if enabled count as a Lambda function request
How is the comunication between the ALB and Lambda?
HTTP request is translated to JSON
What is the main information sent by an ALB to Lambda?
- ELB information
- HTTP method
- Path
- Query String Params (Key/Value)
- Headers (Key/Value)
- Body (for POST, PUT…)
- isBase64Encoded (flag)
What is the main information sent by Lambda to an ALB?
- Status Code
- Description
- Headers (Key/Value)
- Body
- isBase64Encoded (flag)
What is ALB multi-header setting?
/path?name=foo&name=bar
What happens when you enable ALB multi-headers in Lambda?
When you enable multi-headers, HTTP headers and query string parameters that are sent with multiple values are shown as arrays within the AWS Lambda event and response objects
What is Lambda@Edge?
Run a global AWS Lambda alongside your CDN
What is useful for Lambda@Edge?
You can use Lambda to change CloudFront requests and responses:
o After CloudFront receives a request from a viewer (viewer request)
o Before CloudFront forwards the request to the origin (origin request)
o After CloudFront receives the response from the origin (origin response)
o Before CloudFront forwards the response to the viewer (viewer response)
You can also generate responses to viewers without ever sending the request to the origin
What are Lambda@Edge use cases?
Lambda@Edge: Use Cases • Website Security and Privacy • Dynamic Web Application at the Edge • Search Engine Optimization (SEO) • Intelligently Route Across Origins and Data Centers • Bot Mitigation at the Edge • Real-time Image Transformation • A/B Testing • User Authentication and Authorization • User Prioritization • User Tracking and Analytics
What are the main services that invoke Lambda async?
- S3 Event Notifications
- SNS
- CloudWatch Events / EventBridge
- CodeCommit (CodeCommit Trigger: new branch, new tag, new push)
- CodePipeline (invoke a Lambda function during the pipeline, Lambda must callback)