21. Lambda **IMPORTANT** Flashcards
When should you use Lambda@Edge?
Whenever we need to integrate Lambda with a CloudFront distribution or for the following:
- search engine optimization
- web security + privacy
- dynamic web app at edge
- user tracking + analytics
- user authentication + authorization
When can you use Lambda@Edge to change CloudFront requests and responses?
- After CF receives a request from a viewer
- Before CF forwards the request to the origin
- After CF receives the response from the origin
- Before CF forwards the response to the viewer
What is the best way to give other accounts and AWS services permission to use your Lambda resources?
Use resource-based policies to give other accounts and AWS services permission to use your Lambda resources.
True or False: Deploying a Lambda function in a public subnet does not give it internet access or a public IP.
True
True or False: Deploying a Lambda function in a private subnet does not give it internet access or a public IP.
Depends. Deploying a Lambda function in a private subnet gives it internet access if you have a NAT Gateway / Instance.
What is the default Lambda function timeout?
3 seconds
Where should you store reusable, temporary context for Lambda?
/tmp directory
Where should you store persistent objects (not temporary) for Lambda?
S3
What do you set to throttle/limit a Lambda function?
Reserved concurrency at the function level
What is the Lambda concurrency limit?
1,000 concurrent executions
How do you use function dependencies in Lambda?
Install the packages alongside your code and zip it together.
Upload the zip to Lambda if less than 50MB, else to S3 first
True or False: Aliases can reference aliases.
False.
Aliases cannot reference aliases (only versions)
What is the correct way to connect a Lambda function to an RDS instance?
Configure Lambda to connect to VPC with private subnet and Security Group needed to access RDS
How do you increase CPU or network on Lambda?
The more RAM you add, the more vCPU you get
How is Lambda priced?
pay per call (first 1mil free)
and per duration (first 400,000GB-sec per month free)
usually very cheap to run Lambda
What is a synchronous invocation?
- you wait for the function to process the event and return a response
- error handling must happen client side (retries, exponential backoff, etc)
Lambda communicates via synchronous invocation with which services?
CLI SDK API Gateway Application Load Balancer CloudFront (Lambda@Edge) Cognito Step Functions Kinesis Data Firehose
How do you expose a Lambda function as an HTTP(S) endpoint?
- use the ALB or an API Gateway
- Lambda function must be registered in a target group
ALB converts the HTTP to JSON for Lambda (and converts it back)
How does AWS support multi-header values?
An ALB setting that takes HTTP headers and query string parameters with multiple values and forms them into arrays for Lambda events and response objects