0
0
AWScloud~20 mins

Environment variables in Lambda in AWS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Lambda Environment Variables Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
How does Lambda handle environment variables during execution?

Consider an AWS Lambda function configured with environment variables. What happens if you update an environment variable value in the Lambda console while the function is running?

AThe running function continues using the old environment variable value until it finishes; new invocations use the updated value.
BThe running function immediately uses the new environment variable value without restart.
CThe running function throws an error due to environment variable change.
DThe Lambda service restarts all running instances immediately to apply the new environment variable.
Attempts:
2 left
💡 Hint

Think about how environment variables are loaded when a Lambda function starts.

security
intermediate
2:00remaining
Which environment variable setting improves Lambda security?

You want to store sensitive data like API keys in Lambda environment variables. Which option best improves security?

AUse environment variables only for non-sensitive data and hardcode secrets in code.
BEncrypt environment variables using AWS KMS and enable encryption in Lambda settings.
CStore secrets in environment variables without encryption but restrict IAM roles.
DStore secrets directly as plain text environment variables.
Attempts:
2 left
💡 Hint

Think about how AWS helps protect sensitive data in Lambda.

Configuration
advanced
2:00remaining
What is the correct way to reference an environment variable in a Node.js Lambda function?

Given an environment variable named API_ENDPOINT, which code snippet correctly accesses its value inside a Node.js Lambda handler?

AWS
exports.handler = async (event) => {
  // Access environment variable here
};
Aconst endpoint = process.env.API_ENDPOINT.value;
Bconst endpoint = process.env['API_ENDPOINT'];
Cconst endpoint = process.env.get('API_ENDPOINT');
Dconst endpoint = process.env.API_ENDPOINT;
Attempts:
2 left
💡 Hint

Recall how environment variables are accessed in Node.js.

Architecture
advanced
2:00remaining
How to manage environment variables across multiple Lambda functions in different environments?

You have multiple Lambda functions deployed in development, staging, and production. What is the best practice to manage environment variables for these environments?

AHardcode environment variables in each Lambda function code for each environment.
BUse the same environment variables for all environments to avoid confusion.
CUse separate Lambda environment variable configurations per environment and manage them via infrastructure as code tools.
DStore environment variables in a shared S3 file and read it at runtime from each Lambda.
Attempts:
2 left
💡 Hint

Think about how to keep environment variables consistent and manageable across environments.

🧠 Conceptual
expert
2:00remaining
What happens if a Lambda environment variable exceeds the size limit?

AWS Lambda has a size limit for all environment variables combined. What is the result if you try to deploy a Lambda function with environment variables exceeding this limit?

AThe deployment fails with an error indicating environment variables size exceeded.
BThe Lambda function deploys successfully but truncates environment variables at the limit.
CThe Lambda function runs but environment variables are ignored at runtime.
DAWS automatically compresses environment variables to fit the limit.
Attempts:
2 left
💡 Hint

Consider AWS Lambda deployment constraints and error handling.