Skip to content
This repository was archived by the owner on Sep 8, 2022. It is now read-only.

Commit e804200

Browse files
author
Alexander Melnyk
authored
chore: simplified examples (#15)
* docs: simplified examples * chore: remove API.md, it should be generated
1 parent abd586b commit e804200

File tree

3 files changed

+12
-170
lines changed

3 files changed

+12
-170
lines changed

API.md

Lines changed: 0 additions & 124 deletions
This file was deleted.

README.md

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and add it to your function. The construct is an extension of the
99
existing [`LayerVersion`](https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-lambda.LayerVersion.html) construct
1010
from the CDK library, so you have access to all fields and methods.
1111

12+
See the [API](API.md) for details.
13+
1214
```typescript
1315
import { LambdaPowertoolsLayer } from 'cdk-lambda-powertools-python-layer';
1416

@@ -23,6 +25,8 @@ from cdk_lambda_powertools_python_layer import LambdaPowertoolsLayer
2325
powertoolsLayer = LambdaPowertoolsLayer(self, 'PowertoolsLayer')
2426
```
2527

28+
The layer will be created during the CDK `synth` step and thus requires Docker.
29+
2630
## Install
2731

2832
TypeSript/JavaScript:
@@ -52,6 +56,8 @@ powertoolsLayer = LambdaPowertoolsLayer(self, 'PowertoolsLayer')
5256
You can then add the layer to your funciton:
5357

5458
```python
59+
from aws_cdk import aws_lambda
60+
5561
aws_lambda.Function(self, 'LambdaFunction',
5662
code=aws_lambda.Code.from_asset('function'),
5763
handler='app.handler',
@@ -80,7 +86,6 @@ Full example:
8086
from aws_cdk import Stack, aws_lambda
8187
from cdk_lambda_powertools_python_layer import LambdaPowertoolsLayer
8288
from constructs import Construct
83-
from typing_extensions import runtime
8489

8590

8691
class LayerTestStack(Stack):
@@ -101,46 +106,7 @@ class LayerTestStack(Stack):
101106

102107
### TypeScript
103108

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:
144110

145111
```typescript
146112
import { Stack, StackProps } from 'aws-cdk-lib';

src/lambda-powertools-layer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { aws_lambda as lambda } from 'aws-cdk-lib';
33
import { Construct } from 'constructs';
44

55
/**
6-
* Properties necessary to create Powertools layer for python.
6+
* Properties for Powertools layer for python.
77
*/
88
export interface PowertoolsLayerProps {
99
/**
10-
* The powertools package version form pypi repository.
10+
* The powertools package version from pypi repository.
1111
*/
1212
readonly version?: string;
1313
/**
14-
* A flag to decide wether to include the extras package, used for parsing.
14+
* A flag for the pydantic extras dependency, used for parsing.
1515
* This will increase the size of the layer significantly. If you don't use parsing, ignore it.
1616
*/
1717
readonly includeExtras?: boolean;
@@ -25,9 +25,9 @@ export class LambdaPowertoolsLayer extends lambda.LayerVersion {
2525

2626
/**
2727
* creates build argument for the Dockerfile.
28-
* We have multiple combinations between version and extras package that results in different suffix for the installation.
28+
* There are multiple combinations between version and extras package that results in different suffix for the installation.
2929
* With and without version, with and without extras flag.
30-
* We construct one suffix here because it is easier to do than inside the Dockerfile with bash commands.
30+
* We construct one suffix here because it is easier to do in code than inside the Dockerfile with bash commands.
3131
* For example, if we set extras=true and version=1.22.0 we get '[pydantic]==1.22.0'.
3232
*
3333
*/

0 commit comments

Comments
 (0)