0
0
AWScloud~20 mins

Lambda handler function structure in AWS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Lambda Handler Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identify the correct AWS Lambda handler signature

Which of the following AWS Lambda handler function signatures is correct for Node.js?

Afunction handler(event) { return 'done'; }
Bexports.handler = (context, event) => { return 'done'; }
Cexports.handler = async (event, context) => { return 'done'; }
Dhandler = (event, context, callback) => { return 'done'; }
Attempts:
2 left
💡 Hint

Remember the order of parameters: event first, then context.

Configuration
intermediate
2:00remaining
Determine the output of a Python Lambda handler

What is the output when this AWS Lambda Python handler is invoked with {"key": "value"} as event?

AWS
def lambda_handler(event, context):
    return event.get('key', 'default')
A"value"
B"default"
CNone
DKeyError
Attempts:
2 left
💡 Hint

Check how dict.get() works in Python.

Architecture
advanced
2:30remaining
Choose the best event source for a Lambda function triggered by file uploads

You want to run a Lambda function automatically whenever a new file is uploaded to an S3 bucket. Which event source configuration is correct?

ASet up CloudWatch Events to poll the S3 bucket every minute
BConfigure S3 bucket event notifications to trigger Lambda on 's3:ObjectCreated:*' events
CUse API Gateway to invoke Lambda when files are uploaded
DManually invoke Lambda from an EC2 instance after upload
Attempts:
2 left
💡 Hint

Think about native S3 event triggers for Lambda.

security
advanced
2:30remaining
Identify the least privilege IAM policy for Lambda execution

Which IAM policy grants the least privilege necessary for a Lambda function to write logs to CloudWatch?

A{ "Effect": "Allow", "Action": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"], "Resource": "arn:aws:logs:*:*:*" }
B{ "Effect": "Allow", "Action": "*", "Resource": "*" }
C{ "Effect": "Allow", "Action": ["logs:PutLogEvents"], "Resource": "*" }
D{ "Effect": "Allow", "Action": ["logs:CreateLogGroup", "logs:CreateLogStream"], "Resource": "arn:aws:logs:*:*:*" }
Attempts:
2 left
💡 Hint

Consider all actions needed to create and write logs.

service_behavior
expert
3:00remaining
Predict Lambda function behavior with asynchronous invocation and error handling

A Lambda function is invoked asynchronously. It throws an exception during execution. What happens to the event and error?

AThe event is lost immediately with no retries or notifications
BThe error is returned immediately to the caller
CThe function retries indefinitely until it succeeds
DThe event is retried twice by default, then sent to a dead-letter queue if configured
Attempts:
2 left
💡 Hint

Think about Lambda's default retry behavior for asynchronous calls.