AWS Developer DVA-C02 · Development with AWS Services · medium

Five different AWS Lambda functions written in Python 3.12 share the same 45 MB internal cryptography and data-validation library (corp_crypto_utils). Currently, every developer bundles a duplicate copy of the 45 MB library into each function's deployment .zip package, slowing down deployments and making library version updates tedious. Which AWS Lambda feature allows packaging shared libraries once and mounting them into /opt across multiple functions?

Published · Last updated · checked before publication — how we verify questions

Options

  • ALambda Ephemeral Storage (/tmp) shared across functions
  • BAWS Lambda Layers mounted into the /opt directory of each functionCorrect answer
  • CAmazon API Gateway Mapping Templates written in Apache Velocity (VTL)
  • DAWS Step Functions Express Workflow state payloads (256 KB maximum)

Answer: B. AWS Lambda Layers mounted into the /opt directory of each function

Lambda Layers are the feature built for this scenario. A layer is a versioned .zip archive that holds libraries, a custom runtime, or configuration files. You publish it once, and any number of functions can reference its ARN. At cold start Lambda extracts the layer contents into the /opt directory of the execution environment. For Python, packages placed under a python/ folder in the layer are added to the import path, so the functions can import corp_crypto_utils with no code changes. Each function can use up to five layers, and the unzipped size of the function code plus all its layers must stay within 250 MB. Because layer versions are immutable, you update the library by publishing a new version and pointing each function at it. The common trap is to think of /tmp as shared storage. It is not, and it is the wrong place to deliver code dependencies.

Why the other options are wrong

  • A. Lambda Ephemeral Storage (/tmp) shared across functions — Ephemeral storage at /tmp is scratch space attached to a single execution environment. It is not shared between functions, and it does not persist or distribute packaged code. It cannot hold a shared library for five separate functions.
  • C. Amazon API Gateway Mapping Templates written in Apache Velocity (VTL) — API Gateway mapping templates use Apache Velocity Template Language (VTL) to transform request and response payloads at the API layer. They have nothing to do with packaging or distributing Python dependencies to Lambda runtimes.
  • D. AWS Step Functions Express Workflow state payloads (256 KB maximum) — Step Functions Express Workflows orchestrate state machines, and their state payloads are limited to 256 KB. They do not mount code into Lambda functions, and a 45 MB library could not fit in a payload anyway.

All Development with AWS Services questions and the topic overview →

AWS and Amazon Web Services are trademarks of Amazon.com, Inc. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by Amazon Web Services.