Question
A data engineer maintains custom Python scripts that perform a data formatting process that many AWS Lambda functions use. When the data engineer needs to modify the Python scripts, the data engineer must manually update all the Lambda functions.
The data engineer requires a less manual way to update the Lambda functions.
Which solution will meet this requirement?
- A. Store a pointer to the custom Python scripts in the execution context object in a shared Amazon S3 bucket.
- B. Package the custom Python scripts into Lambda layers. Apply the Lambda layers to the Lambda functions. Correct
- C. Store a pointer to the custom Python scripts in environment variables in a shared Amazon S3 bucket.
- D. Assign the same alias to each Lambda function. Call each Lambda function by specifying the function's alias.
Explanation
Lambda layers let you package shared code, such as the custom Python formatting scripts, separately from each function's deployment package and attach it to any number of functions. The shared code is maintained in one place: when the scripts change, the data engineer publishes a new layer version and points the functions at it (for example, with one scripted or infrastructure-as-code update), instead of rebuilding and redeploying every function's code. Pointers in the execution context or environment variables do not deliver the code to the functions, and aliases only name function versions; they do not share code between functions.