HomeInterview QuestionsCan you explain how to create an AWS Lambda layer …

Can you explain how to create an AWS Lambda layer and provide the steps you have followed in your experience?

🟡 Medium Conceptual Junior level
1Times asked
Apr 2026Last seen
Apr 2026First seen

💡 Model Answer

To create a Lambda layer:

  1. Create a directory structure that matches the runtime, e.g., for Python: python/lib/python3.9/site-packages.
  2. Install your dependencies into that directory using pip: pip install -r requirements.txt -t python/lib/python3.9/site-packages.
  3. Zip the top‑level folder (the folder containing the python directory): zip -r layer.zip python.
  4. In the AWS console or via AWS CLI, create a new layer: aws lambda publish-layer-version --layer-name MyLayer --zip-file fileb://layer.zip --compatible-runtimes python3.9.
  5. Note the returned LayerVersionArn.
  6. Add the layer to your Lambda function: either in the console under the function’s Layers section or via CLI: aws lambda update-function-configuration --function-name MyFunc --layers arn:aws:lambda:region:acct-id:layer:MyLayer:1.
  7. Deploy or update your function code. The layer’s contents are now available at /opt during execution.

Key decisions: choose the correct runtime, keep the layer size under 50 MB (compressed), and version layers to avoid breaking changes.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.

Get Assisting AI — Starts at ₹500