@@ -9,6 +9,8 @@ and add it to your function. The construct is an extension of the
9
9
existing [ ` LayerVersion ` ] ( https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-lambda.LayerVersion.html ) construct
10
10
from the CDK library, so you have access to all fields and methods.
11
11
12
+ See the [ API] ( API.md ) for details.
13
+
12
14
``` typescript
13
15
import { LambdaPowertoolsLayer } from ' cdk-lambda-powertools-python-layer' ;
14
16
@@ -23,6 +25,8 @@ from cdk_lambda_powertools_python_layer import LambdaPowertoolsLayer
23
25
powertoolsLayer = LambdaPowertoolsLayer(self , ' PowertoolsLayer' )
24
26
```
25
27
28
+ The layer will be created during the CDK ` synth ` step and thus requires Docker.
29
+
26
30
## Install
27
31
28
32
TypeSript/JavaScript:
@@ -52,6 +56,8 @@ powertoolsLayer = LambdaPowertoolsLayer(self, 'PowertoolsLayer')
52
56
You can then add the layer to your funciton:
53
57
54
58
``` python
59
+ from aws_cdk import aws_lambda
60
+
55
61
aws_lambda.Function(self , ' LambdaFunction' ,
56
62
code = aws_lambda.Code.from_asset(' function' ),
57
63
handler = ' app.handler' ,
@@ -80,7 +86,6 @@ Full example:
80
86
from aws_cdk import Stack, aws_lambda
81
87
from cdk_lambda_powertools_python_layer import LambdaPowertoolsLayer
82
88
from constructs import Construct
83
- from typing_extensions import runtime
84
89
85
90
86
91
class LayerTestStack (Stack ):
@@ -101,46 +106,7 @@ class LayerTestStack(Stack):
101
106
102
107
### TypeScript
103
108
104
- These examples are for TypeScript:
105
-
106
- Build the layer:
107
-
108
- ``` typescript
109
- import { LambdaPowertoolsLayer } from ' cdk-lambda-powertools-python-layer' ;
110
-
111
- const powertoolsLayer = new LambdaPowertoolsLayer (this , ' TestLayer' , {
112
- version: ' 1.22.0' ,
113
- });
114
- ```
115
-
116
- Add to your function:
117
-
118
- ``` typescript
119
- new Function (this , ' LambdaFunction' , {
120
- code: Code .fromAsset (path .join (' ./function' )),
121
- handler: ' app.handler' ,
122
- runtime: Runtime .PYTHON_3_9 ,
123
- layers: [powertoolsLayer ],
124
- });
125
- ```
126
-
127
- You can specify the powertools version:
128
-
129
- ``` typescript
130
- new LambdaPowertoolsLayer (this , ' PowertoolsLayer' , {
131
- version: ' 1.21.0'
132
- });
133
- ```
134
-
135
- Decide if you want to incldue pydantic as extras dependencies:
136
-
137
- ``` typescript
138
- new LambdaPowertoolsLayer (this , ' PowertoolsLayer' , {
139
- includeExtras: true
140
- });
141
- ```
142
-
143
- Full example:
109
+ Full example for TypeScript:
144
110
145
111
``` typescript
146
112
import { Stack , StackProps } from ' aws-cdk-lib' ;
0 commit comments