Lambda Flashcards
You have created a Lambda function that typically will take around 1 hour to process some data. The code works fine when you run it locally on your machine, but when you invoke the Lambda function it fails with a “timeout” error after 3 seconds. What should you do?
A. Configure your Lambda’s timeout to 25 minutes
B. Configure your Lambda’s memory to 10 GB
C. Run your code somewhere else (eg EC2 instance)
C. Run your code somewhere else (eg EC2 instance)
Lambda’s maximum execution time is 15 minutes. You can run your code somewhere else such as an EC2 instance or use Amazon ECS.
Which of the following is the best way to inject a dynamic DB_URL variable into your Lambda function’s code?
A. Use Lambda’s Environment Variables
B. Place it in the code and create a zip file
C. Place it in the code itself
A. Use Lambda’s Environment Variables
Lambda’s Environment Variables allows you to adjust your function’s behavior without updating code
A Lambda function that’s invoked asynchronously, fails to process from time to time after 3 retries. To troubleshoot the issue, you would like to collect and analyze these events later on. What is the best practice you can do?
A. Add logging statements for all events in your Lambda function, then filter CloudWatch logs
B. Invoke your function synchronously
C. Add a Dead Letter Queue to send messages to SQS
D. Add a Dead Letter Queue to send messages to SNS
C. Add a Dead Letter Queue to send messages to SQS
This is good as SQS will hold the failed messages for some days so we have time to consume and analyze them.
You have enabled a Dead Letter Queue (DLQ) for your Lambda function and configured it to send failed messages to SNS. While testing, you don’t see any events there even though you can tell from CloudWatch metrics that you have failures. What is most likely the reason for this?
A. AWS SNS is having outages
B. Your Lambda function’s execution role is missing permissions
C. You should use SQS instead, there’s no Lambda DLQ for SNS
B. Your Lambda function’s execution role is missing permissions
You have enabled X-Ray integration on your Lambda function but it doesn’t work. What is a possible cause for this?
A. Check IAM permissions for your Lambda function’s execution role
B. Your need to run the X-ray daemon as a dependency in your deployment package
C. You need to open a ticket with AWS support
A. Check IAM permissions for your Lambda function’s execution role
While updating a Lambda function, you get the following exception:
An error occurred: InvalidParameterValueException when calling the UpdateFunctionCode operation: Unzipped size must be smaller than 262144000 bytes. How should you solve this issue?
A. You have uploaded a deployment package zip larger than 50 mb to AWS Lambda
B. The uncompressed deployment package zip exceeds AWS Lambda limits
C. The deployment package zip file is corrupted
B. The uncompressed deployment package zip exceeds AWS Lambda limits
A Lambda function makes requests to 3rd party API. To successfully make the requests, the 3rd party API requires you to send a token which is a long string of 8 KB. Where should you place this token?
A. Place it in the Lambda function’s environment variables
B. Place it in the deployment package zip file
B. Place it in the deployment package zip file
(Environment variables limit is 4kb)
Every time you release a Lambda function version, it gets a new number and you have to manually update all the AWS resources linked to your function (e.g., event triggers). What should you do?
A. Use Lambda Aliases, and update the Alias to point to the new version
B. Use AWS CloudFormation to update all the links automatically
C. Just always use $LATEST and never worry again
A. Use Lambda Aliases, and update the Alias to point to the new version
You have updated a Lambda function and created a new version. Now, you want to test out the new version and ensure it can sustain production traffic. You are risk-averse and don’t want to take down your whole application. What should you do?
A. Create a new Lambda function and test there
B. Use Lambda Aliases, and point to the new and old versions, then assign weights
B. Use Lambda Aliases, and point to the new and old versions, then assign weights
You have a Lambda function used to retrieve data from an RDS DB instance. Each time the Lambda function is invoked, it establishes a new connection to your database. These connections make a load on your database and degrade its performance. So, you tell your developers to use long-lived database connections. They tell you that _____ .
A. It’s impossible, AWS Lambda containers are created and destroyed every time they are called
B. They will move the database connection object outside the function handler
C. They will use an Elasticache cluster to proxy requests to the RDS DB instance
B. They will move the database connection object outside the function handler
Your Lambda function written in Node.js wants to connect to an RDS PostgreSQL database in your VPC. The Lambda function must use the Node.js driver for PostgreSQL to connect to the database. How do you bundle your Lambda function to add the dependencies?
A. Put the function and dependencies in one folder and zip them together
B. Zip the function as-is with a package.json file so that AWS Lambda can resolve the dependencies for you
C. Zip the function and the dependencies separately and upload them in AWS Lambda as two parts
D. Upload the code through the AWS Console and upload the dependencies as a zip
A. Put the function and dependencies in one folder and zip them together
How do you declare a Lambda function in a CloudFormation template?
A. Upload all the code to AWS CodeCommit and refer to the CodeCommit repository in AWS::Lambda::Function block
B. Upload all the code to AWS CodeDeploy and refer to the CodeDeploy application in AWS::Lambda::Function block
C. Upload all the code as a folder to an S3 bucket and refer to the folder in the AWS::Lambda::Function block
D. Upload all the code as a zip file to an S3 bucket and refer to the object in the AWS::Lambda::Function block
D. Upload all the code as a zip file to an S3 bucket and refer to the object in the AWS::Lambda::Function block
Which of the following allows you to deploy your Lambda function globally so that requests made to a CloudFront distribution are filtered at the AWS Edge Locations?
A. Lambda@Edge
B. Deploy Lambda in a global VPC
C. Deploy Lambda in S3 bucket with S3 Cross-Region Replication enabled
A. Lambda@Edge
What is the recommended way to store temporary files used by your Lambda function that will be discarded when the function stops execution?
A. Use the local directory /opt
B. Create a tmp/ directory in the source zip file and use it
C. Use the local directory /tmp
D. Use an S3 bucket
C. Use the local directory /tmp
The maximum size for a Lambda function /tmp space is ____
A. 64 mb
B. 128 mb
C. 1024 mb
D. 10240 mb
D. 10240 mb