How do Lambda packages, layers, and extensions work?
Choose Lambda ZIP or container-image packaging, use layers deliberately, understand extensions, and keep deployment artifacts small and governable.
How do Lambda packages, layers, and extensions work?
Lambda function code can be deployed as a ZIP archive or a container image. Layers can package compatible shared files separately from a ZIP-based function, while extensions integrate monitoring, security, configuration, or governance tools with the Lambda execution environment and lifecycle.
How this topic fits
Compute
Understand Lambda execution, scaling, concurrency, packaging, event sources, cold starts, and when serverless containers are the better fit.
Choose a deployment package format
ZIP archives work well for conventional runtime projects and can be uploaded directly or through Amazon S3. Container images use the Lambda container contract and support larger artifacts and image-based build workflows, but they do not turn the function into a general-purpose container service.
Choose one format from dependency needs, build reproducibility, security scanning, artifact size, and team tooling. The execution model, scaling behavior, and function limits remain Lambda's in either case.
Use layers for a concrete ownership benefit
A layer can provide libraries, custom runtimes, certificates, configuration helpers, or shared tooling to multiple functions. Lambda extracts layer contents into the execution environment in a defined order.
Layers add version and compatibility relationships. Prefer them when independent ownership or reuse is valuable; do not split every dependency into a layer if one self-contained artifact is easier to test, deploy, and roll back.
Understand extension lifecycle and cost
Extensions can run as external processes or integrate with a runtime. They participate in initialization, invocation, and shutdown and can send telemetry, retrieve configuration, or enforce controls.
An extension consumes execution-environment resources and can affect startup and duration. Treat it as production code: pin versions, test failure behavior, monitor overhead, and give it only the permissions it requires.
Build a controlled software supply chain
Lock dependencies, produce artifacts in a repeatable build, scan them, record provenance, and deploy immutable versions through infrastructure as code. Remove compilers, tests, documentation, and packages that are not required at runtime.
A small artifact is not the only goal. Prefer an understandable artifact with explicit dependencies, compatible architecture and runtime settings, and a tested rollback path.
Go deeper with AWS
Read the primary AWS documentation behind the service definitions and architecture guidance in this guide.
Next steps
Continue with the concepts that most directly shape this decision.
Lambda cold starts
Learn the Lambda initialization and invocation lifecycle, what causes cold starts, how reuse works, and which latency optimizations are evidence-based.
IaC, testing, and deployment
Use AWS CDK and CloudFormation for reproducible infrastructure, test business logic and cloud integrations, and promote immutable changes with safe rollback.
Questions about this topic
Browse all serverless concepts
Explore compute, APIs, events, workflows, data, security, reliability, operations, delivery, and AI from one connected AWS serverless learning path.
What is serverless?
Learn what serverless computing means, how it works on AWS, what the cloud provider manages, and which trade-offs still belong to your team.
What is AWS Lambda?
Understand how AWS Lambda runs code, how functions are invoked, where permissions and state live, and when Lambda is a good compute choice.
What is serverless architecture?
Learn how managed compute, APIs, events, queues, workflows, data, identity, and observability fit together in a serverless architecture on AWS.
AWS serverless security
A practical guide to identity, least privilege, event validation, secrets, data protection, dependencies, and incident visibility in AWS serverless systems.
What is agentic AI?
Learn what makes an AI system agentic, how models, tools, memory, orchestration, identity, and evaluation fit together, and where serverless patterns help on AWS.
What is cloud computing?
Understand how on-demand infrastructure and managed services change the way teams provision, scale, pay for, and operate software systems.
What is event-driven architecture?
Learn how producers, routers, and consumers communicate through events, and how to design schemas, delivery, retries, and ownership deliberately.
What is a serverless API?
Understand the request path, authentication, routing, compute, data, throttling, observability, and failure controls behind a serverless API on AWS.
What are serverless workflows?
Learn when explicit workflow state improves retries, branching, parallel work, human approval, visibility, and recovery in distributed applications.
What is Amazon API Gateway?
Learn how API Gateway creates, publishes, secures, monitors, and operates HTTP, REST, and WebSocket APIs for AWS and external backends.
What is Amazon EventBridge?
Understand EventBridge event buses, rules, pipes, schemas, targets, schedules, permissions, delivery, and recovery in event-driven AWS systems.
Make the next serverless decision explicit.
Explore focused products for repeatable work, or bring the architecture decision that needs context and experienced review.