How to centrally share and update Python code across many Lambda functions?
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?
Community Votes
100% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
The test is on reusing shared code across multiple Lambda functions; the trap is confusing function-level configuration (environment variables, aliases) with a deployable shared code artifact.
Lambda layers let you package shared Python code once and attach it to many Lambda functions, so a single layer update replaces editing every function. This page confirms option B as the answer and explains why S3 pointers, environment variables, and aliases do not deliver centralized code management.
Choosing the environment-variable or S3-pointer options, because they sound like 'configuration' — but each function still needs its own env var set and its own download logic, which repeats exactly the manual editing work the engineer is trying to eliminate.
Community Discussion (9 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Lambda layers are the purpose-built mechanism for sharing code and dependencies between functions: you package the formatting script into a layer once and reference that layer from every function. When the script changes, you publish a new layer version and update the layer reference instead of editing each function's inline code, which removes the manual duplication described in the scenario. The layer is also versioned and immutable, so each function can pin a known-good version while a newer one is rolled out and tested. This is exactly the use case AWS documents for layers, which is why option B is the only one that changes the deployment artifact rather than the per-function settings.Why the Other Options Are Wrong
Option A invents a capability: the execution context object is runtime-internal and cannot be used as a configuration store, and pointing at code in S3 still forces every function to fetch and execute it at invocation time with its own IAM permissions and latency. Option C fails for the same reason plus the duplication problem — environment variables are set per function, so changing the script means editing every function's environment, and the 4 KB limit plus lack of versioning makes it unsuitable for code. Option D misuses aliases, which are pointers to versions of a single function for traffic shifting and stable invocation ARNs; they do nothing to share Python code between different functions.Community Comment Notes
TonyStark0122 summarized the mechanics well, noting that layers "allow you to centrally manage shared code and dependencies across multiple Lambda functions." pypelyncar added the key benefit that a layer is stored in a central location outside the individual function code, and JavierEF put it bluntly that Lambda Layers is "a feature created with this literal objective in mind." kj07 called it a typical Lambda Layers use case, and the unanimous vote record (B: 100) matches that consensus. One nuance worth carrying into the exam: layer versions are immutable, so "automatic" update means publishing a new version and repointing functions — still one artifact to maintain instead of many scripts.Official Reference
Exam Strategy
When a question says code or libraries are duplicated across several Lambda functions and must be updated with less manual effort, the answer is almost always Lambda layers. Rule out any option that stores a 'pointer' in environment variables, execution context, or S3, since those still require per-function edits.
Frequently Asked Questions
Why not store the shared Python scripts in S3 and reference them from environment variables?
Every function would still need its own environment variable and download logic, adding cold-start latency and S3 permissions without any central, versioned code artifact.
Do Lambda layer changes apply automatically to functions already using the layer?
No. Layer versions are immutable, so you publish a new version and repoint the functions (or reference $LATEST), which can be scripted via the Lambda API or IaC.
Related Analysis
Practice All DEA-C01 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DEA-C01 Practice Test →