DVA-C02 Question 256
Single answerYou are developing an AWS Lambda function that processes data uploaded to an S3 bucket. You have multiple environments (dev, staging, and production) and want to ensure that changes to the Lambda function are properly managed without impacting the production environment. How can you achieve this using Lambda versions and aliases?
- A
Deploy the Lambda function to multiple AWS accounts, each representing a different environment.
- B
Publish a new Lambda version for each deployment and use aliases to point to the appropriate version for each environment.
- C
Use the $LATEST version for all environments and update the function code directly as needed.
- D
Create separate Lambda functions for each environment instead of using versions and aliases.
Show answer and explanation
Correct answer: B
Explanation
Using Lambda versions and aliases is a best practice for managing multiple environments. When you publish a version, it becomes immutable, ensuring that the code and configuration are locked. Aliases provide a logical pointer to specific versions, allowing you to deploy and test in different environments (e.g., dev, staging, prod) without affecting others. This approach simplifies deployment management and reduces the risk of introducing unintended changes.
- A. Incorrect.
This is not the recommended approach for managing environments. Using separate AWS accounts can provide isolation but is not required for environment-specific versioning within a single account.
- B. Correct.
This is the best practice. Lambda versions allow you to lock your function code and configuration at a specific point in time, while aliases let you assign environment-specific pointers (e.g., dev, staging, prod) to specific versions.
- C. Incorrect.
Using the $LATEST version directly is risky because it always points to the most recent code, which could inadvertently impact all environments, including production.
- D. Incorrect.
Creating separate Lambda functions for each environment is not efficient and makes it harder to manage and track changes across environments. Versions and aliases are designed to solve this problem.