What are AWS Lambda layers?

Instruction: Describe what AWS Lambda layers are and how they are used.

Context: This question gauges the candidate's knowledge of AWS Lambda layers, a feature that allows for code and dependencies sharing across multiple Lambda functions.

Updated

Official answer

A Lambda layer is a versioned ZIP archive containing supplementary code or data, such as libraries or a custom runtime. ZIP-based functions can reference up to five layers; Lambda extracts their content under /opt using the documented runtime search paths.

For example, several Python functions can reference a shared dependency layer built for their Python version and CPU architecture. The function configuration names a specific layer-version ARN. Publishing a new layer version does not automatically update those functions: update each selected function's configuration, test it, and publish/deploy a new function version as appropriate.

Layers reduce duplication in the function's own upload, but their expanded content counts toward the combined 250 MB unzipped package limit. They do not bypass that quota or guarantee faster initialization. Measure cold-start behavior, compatibility and dependency conflicts rather than assuming a shared library is automatically cached for all functions.

Container-image functions package dependencies inside the image instead of attaching ZIP layers. Check layer ownership, permissions, provenance and update responsibility, especially for externally supplied layers. Pin and retain the tested version so a shared-library rollout can be controlled and reversed.

Layers and versions, Lambda package quotas

Related Questions