0
0
AWScloud~20 mins

Creating a Lambda function in AWS - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Lambda Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
What happens when a Lambda function is invoked with an event?

Consider an AWS Lambda function configured with a handler that processes incoming events. What is the expected behavior when the function is invoked with a valid event?

AThe Lambda function deletes the event without processing it.
BThe Lambda function stores the event in S3 and does not execute any code.
CThe Lambda function automatically scales to multiple instances without running the handler.
DThe Lambda function executes the handler code with the event data and returns a response or error.
Attempts:
2 left
💡 Hint

Think about what a Lambda function is designed to do when triggered.

Configuration
intermediate
2:00remaining
Which IAM role policy allows a Lambda function to write logs to CloudWatch?

You want your Lambda function to write logs to CloudWatch Logs. Which IAM policy statement should be attached to the Lambda execution role?

A{"Effect": "Deny", "Action": ["logs:CreateLogGroup"], "Resource": "*"}
B{"Effect": "Allow", "Action": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"], "Resource": "arn:aws:logs:*:*:*"}
C{"Effect": "Allow", "Action": ["ec2:StartInstances"], "Resource": "*"}
D{"Effect": "Allow", "Action": ["s3:PutObject"], "Resource": "arn:aws:s3:::my-bucket/*"}
Attempts:
2 left
💡 Hint

Focus on permissions related to CloudWatch Logs actions.

Architecture
advanced
2:30remaining
How to design a Lambda function for high availability and fault tolerance?

You need to design a Lambda function that remains highly available and fault tolerant in case of failures. Which architecture approach best achieves this?

ADisable CloudWatch Logs to improve performance and reduce failure points.
BDeploy the Lambda function only in one Availability Zone to reduce latency.
CDeploy the Lambda function in multiple AWS Regions and use Route 53 latency-based routing to invoke the nearest function.
DUse a single Lambda function with no retries configured to avoid duplicate processing.
Attempts:
2 left
💡 Hint

Consider geographic redundancy and routing to improve availability.

security
advanced
2:30remaining
What is the best practice to secure environment variables in Lambda functions?

You want to store sensitive data like API keys in Lambda environment variables securely. What is the best practice to protect these secrets?

AEncrypt environment variables using AWS KMS and enable Lambda to decrypt them at runtime.
BStore secrets directly in plain text environment variables without encryption.
CHardcode secrets inside the Lambda function code for faster access.
DSend secrets as part of the event payload when invoking the Lambda function.
Attempts:
2 left
💡 Hint

Think about encryption and secure key management.

Best Practice
expert
3:00remaining
How to optimize cold start performance for a Lambda function written in Java?

Java Lambda functions often have longer cold start times. Which approach best reduces cold start latency?

AUse provisioned concurrency to keep Lambda instances initialized and ready to serve requests.
BIncrease the memory allocation to the minimum value to reduce startup time.
CAvoid using any dependencies and write all code inline in the handler method.
DDisable VPC access to reduce network initialization delays.
Attempts:
2 left
💡 Hint

Consider AWS features that keep functions warm.