Skip to content

Commit 3333207

Browse files
author
Florian Chazal
committed
doc: describe esbuild external options if layer used
1 parent 67ecf7f commit 3333207

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

docs/index.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,55 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
204204

205205
Container Image deployment (OCI) or inline Lambda functions do not support Lambda Layers.
206206

207+
If you use `esbuild` to bundle your code, make sure to exclude `@aws-lambda-powertools` from being bundled since the packages will be brought by the Layer:
208+
209+
=== "SAM"
210+
211+
```yaml hl_lines="5"
212+
MyLambdaFunction:
213+
Type: AWS::Serverless::Function
214+
Properties:
215+
...
216+
Metadata:
217+
# Manage esbuild properties
218+
BuildMethod: esbuild
219+
BuildProperties:
220+
Minify: true
221+
External:s
222+
- '@aws-lambda-powertools/commons'
223+
- '@aws-lambda-powertools/logger'
224+
- '@aws-lambda-powertools/metrics'
225+
- '@aws-lambda-powertools/tracer'
226+
```
227+
228+
=== "Serverless framework"
229+
230+
```yaml hl_lines="5"
231+
custom:
232+
esbuild:
233+
external:
234+
- '@aws-lambda-powertools/commons'
235+
- '@aws-lambda-powertools/logger'
236+
- '@aws-lambda-powertools/metrics'
237+
- '@aws-lambda-powertools/tracer'
238+
```
239+
240+
=== "CDK"
241+
242+
```typescript hl_lines="11 16"
243+
new awsLambdaNodejs.NodejsFunction(this, 'Function', {
244+
...
245+
bundling: {
246+
externalModules: [
247+
'@aws-lambda-powertools/commons',
248+
'@aws-lambda-powertools/logger',
249+
'@aws-lambda-powertools/metrics',
250+
'@aws-lambda-powertools/tracer',
251+
],
252+
}
253+
});
254+
```
255+
207256
### NPM Modules
208257

209258
The AWS Lambda Powertools for TypeScript utilities (which from here will be referred as Powertools) follow a modular approach, similar to the official [AWS SDK v3 for JavaScript](https://github.com/aws/aws-sdk-js-v3).

0 commit comments

Comments
 (0)