📎 Referral Code: —
🎁 Referral Earnings ₹0 →
📊 Dashboard Sign In
🎁 ₹0
Your Referral Earnings → Tap to view
Buy
🛒
Buy Course
Videos
📘
Basic Videos
🚀
Project Related Videos
🐍
Old Videos Style — will be removed soon
📚
Buy Book
After Course Completion
📒
My Interview Tracker — HR calls & follow-ups
📈
My Performance — Track your progress
🎯
Interview Prep — Resume & questions for a job
🏢
Company Interview Questions — with answers
🤖
Central Command — your HQ bot
💼
Jobs — AWS Data Engineer openings
Personal Training
🎬
Live Classes
🎯
My 1:1 Dashboard
🗺️
Course Roadmap
🎤
Mock Interview
🧑‍💼
HR Discussion
🗓️
Slot Booking
📅
My Booked Slots
Passive Income
🎁
Refer & Earn — ₹1,000 per referral
🤝
Browse Job Support
💰
Become a Supporter
🔗
Browse Referrals
📢
Post a Referral
🎓
Course Marketplace — Other Trainers
🧑‍🏫
Teach a Course
📊
My Courses & Earnings
🎬
Reels
AI Tools
🌐
Project Explanation Agent
👤
My Profile
🏢
Recruiter Board
🛟
Support Works

← Stellantis interview questions

🎬No video for this question yet. The written answer is below.

what is lambda layers?
  • How many layers we can create?

🏢 Stellantis 🏷️ AWS #1 of 7

📝 Answer

Interviewer:
What are AWS Lambda Layers? And how many layers can you attach to a Lambda function?
Candidate:
So basically, let me explain this step by step from a practical point of view. First, AWS Lambda Layers are a way to separate common code or dependencies from the main Lambda function code. Instead of packaging everything inside one deployment package, we can create layers that contain libraries, custom modules, or even runtime dependencies. In simple terms, I would say a Lambda Layer is like a shared reusable component. So multiple Lambda functions can use the same layer instead of duplicating code again and again. Now, how I usually think about it is… when I build a Lambda function, I ask myself, “Is there any common code or dependency that I will reuse across multiple functions?” If yes, then I move that into a layer. In my project, I was working on an ETL pipeline where multiple Lambda functions were interacting with S3, validating data, and pushing results to Redshift. All those functions required common libraries like pandas, requests, and some custom validation logic. Initially, I packaged everything inside each Lambda, but it made deployment heavy and difficult to maintain. So what I did was… I created a Lambda Layer that contained all the shared dependencies and utility functions. Then I attached that layer to multiple Lambda functions. This reduced duplication and made updates much easier. For example, if I needed to update a validation function, I just updated the layer instead of modifying every Lambda. Now coming to the second part of your question… how many layers we can attach. As per AWS limits, a single Lambda function can have up to 5 layers attached to it. So in practice, I usually organize layers like this… one for external libraries, one for internal shared utilities, and maybe one for logging or monitoring tools. But I always try to keep it minimal because too many layers can make debugging slightly complex. Also, one important thing I learned from experience is about size limitations. Each layer has size limits, and when combined with the Lambda deployment package, we need to stay within AWS limits. So we need to design layers carefully. Let me show a small example structure.
# Example Layer Structure

python/
│
├── lib/
│   └── python3.9/
│       └── site-packages/
│           ├── pandas/
│           ├── requests/
│           └── custom_utils.py

# After zipping this folder, upload as Lambda Layer
So overall, Lambda Layers help in code reusability, reducing deployment size, and improving maintainability, especially in real-time ETL or microservices-based architectures. One challenge I faced initially was version management. When multiple functions depend on the same layer, updating the layer can impact all functions. So I started versioning layers properly and testing before attaching new versions.
Interviewer (Follow-up):
That’s good. Can you explain how you would manage versioning of Lambda Layers in a production environment?