Authentication vs Authorization in AWS Amplify
Authentication vs Authorization in AWS Amplify
Why Permissions Feel Confusing in Amplify
Why AWS Lambda Layers Become Essential as Your Serverless App Grows

When you first start using AWS Lambda, everything feels clean and simple. You write a function. You deploy it. It works.
But then your application grows. You add more Lambdas. You share utilities. You introduce heavier dependencies.
And suddenly…
At that point, every small change starts costing more time than it should.
That’s exactly when Lambda Layers stop being “nice to have” — and become necessary.
Let me show you why…
A Lambda Layer is a separate package that contains shared code or dependencies. A layer is versioned, and you can attach the same layer to multiple functions.
Instead of bundling everything inside every function, you move common logic into a layer and attach it to multiple functions.
Think of it like:
AWS mounts the layer into the runtime environment, and your function can import it normally.
Without layers, every Lambda carries its own dependencies.
If you have:
They get bundled repeatedly.
With layers, those dependencies are packaged once and reused.
As your system grows, you naturally separate:
Layers help enforce this separation.
Example structure:
amplify/ functions/ layers/
Now shared capabilities live in one place — not scattered across several functions.
Let’s look at a practical scenario.
We needed to build a feature that:
Everything worked; until it didn’t.
Amplify Gen 2 uses esbuild to bundle Lambda functions.
The issue?
It doesn’t natively process .*hbs *template files.
When we tried importing templates directly inside the Lambda function:
We needed a solution that wouldn’t turn into a maintenance hack.
Instead of fighting the bundler, we changed the architecture.
We created a dedicated layer for report templates and locales:
amplify/ layers/ report-template-layer/ templates/ summary-report.hbs analytics-report.hbs compliance-overview.hbs activity-summary.hbs locales/ en/ es/ de/
Then our service layer looked something like:
amplify/ services/ report-data-service.ts report-generator.ts report-i18n.ts template-renderer.ts
The Lambda function simply attached the layer.
When a layer is attached, AWS mounts it under /opt/, so your function can read templates from there at runtime.
Now the rendering flow became:
Clean. Stable. Predictable.
The templates were no longer part of the esbuild bundle.
Any future reporting Lambda could reuse the same layer.
No hacks. No custom bundler overrides. Just proper structure.
Layers are especially useful when you have:
If you only have:
You can keep things simple.
Layers are a scaling tool — not a starting requirement.
Lambda Layers aren’t just about reducing package size.
They’re about:
In our case, they weren’t an optimization. They were the clean architectural fix to a real build limitation. And that’s usually when you know you’re using the right tool.
A version of this article was first published on March 9, 2026 on Medium.
Why Permissions Feel Confusing in Amplify
Core AWS Services You Must Know as a Developer AWS looks exciting from a distance. Then you open the console for the first time and see a long list of services, categories, and unfamiliar names. EC2 …
A Practical Way to Manage Reusable Templates in Serverless Apps