Lambda Flashcards

1
Q

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)

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A. Use Lambda’s Environment Variables

Lambda’s Environment Variables allows you to adjust your function’s behavior without updating code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

B. Your Lambda function’s execution role is missing permissions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A. Check IAM permissions for your Lambda function’s execution role

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

B. The uncompressed deployment package zip exceeds AWS Lambda limits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

B. Place it in the deployment package zip file

(Environment variables limit is 4kb)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A. Use Lambda Aliases, and update the Alias to point to the new version

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

B. Use Lambda Aliases, and point to the new and old versions, then assign weights

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

B. They will move the database connection object outside the function handler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A. Put the function and dependencies in one folder and zip them together

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

D. Upload all the code as a zip file to an S3 bucket and refer to the object in the AWS::Lambda::Function block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A. Lambda@Edge

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

C. Use the local directory /tmp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

The maximum size for a Lambda function /tmp space is ____

A. 64 mb
B. 128 mb
C. 1024 mb
D. 10240 mb

A

D. 10240 mb

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which of the following AWS services allows you to schedule your Lambda function to be invoked every hour?

A. Amazon S3
B. Simple Queue Service
C. Amazon EventBridge
D. Kinesis Data Streams

A

C. Amazon EventBridge

17
Q

To use your Lambda function with an Application Load Balancer, the Lambda function must be registered with ____

A. An event source mapping
B. A target group
C. An asynchronous invocation
D. An auto scaling group

A

B. A target group

18
Q

You have enabled and configured Event Notifications in your S3 bucket to invoke a Lambda function every time an object is uploaded to your S3 bucket. You have noticed that there’s duplicate logging into CloudWatch Logs with the same request ID. What do you think is the reason for this?

A. The Lambda function has failed and retries have happened
B. The S3 bucket invoked your lambda function too many times
C. The Lambda function timeout is too low

A

A. The Lambda function has failed and retries have happened

19
Q

Which of the following AWS service does NOT require a Lambda Event Source Mapping?

A. DynamoDB Streams
B. Kinesis Data Streams
C. Simple Queue Service
D. Simple Notification Service

A

D. Simple Notification Service

(because it is asynchronous)

20
Q

Which of the following is the recommended way to send the result of an asynchronous Lambda function to an SQS queue?

A. Write it in the Lambda function code
B. Use Lambda destinations
C. Use Lambda layers
D. Use a Dead Letter Queue

A

B. Use Lambda destinations

21
Q

AWS Lambda natively supports the following programming languages, EXCEPT ____

A. Go
B. Python
C. C++
D. Node.js
E. Java

A

C. C++

22
Q

You have a Lambda function written in Python which has a lot of dependencies. Each time you update and deploy your function, it takes 15 minutes to natively compile these dependencies and therefore deployments have been really slow. What do you suggest?

A. Store the dependencies in an S3 bucket
B. Build the dependencies on an EC2 instance
C. Migrate to Node.js
D. Create a Lambda Layer and include all the dependencies in it

A

D. Create a Lambda Layer and include all the dependencies in it

23
Q

You want to give another AWS account access to invoke a Lambda function in your AWS account. Which of the following can NOT be used to do so?

A. Lambda execution role
B. Lambda resource-based policy
C. Cross-account IAM role

A

A. Lambda execution role

24
Q

You have a CloudFormation template that declares a Lambda function. The Lambda function’s code is stored in an S3 bucket with Versioning enabled. You use S3Bucket, S3Key, and S3ObjectVersion in the CloudFormation template to reference the code. You have updated the Lambda function’s code then uploaded it to S3, but the function hasn’t been updated. What should you do?

A. Update S3Bucket to reference the updated code
B. Update S3Key to reference the updated code
C. Update S3ObjectVersion to reference the updated code

A

C. Update S3ObjectVersion to reference the updated code

25
Q

Which of the following Lambda features can NOT be used to create a custom runtime if it isn’t natively supported by AWS Lambda?

A. Lambda Layers
B. Lambda Destinations
C. Lambda Container Images

A

B. Lambda Destinations

26
Q

You are using CodeDeploy for automated deployments to your Lambda function. You updated your Lambda function’s code and want to deploy the new version, test it with a small amount of traffic, then totally shift to the new version. Which CodeDeploy deployment type do you recommend?

A. Linear
B. AllAtOnce
C. Canary

A

C. Canary