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

Commit bede976

Browse files
author
Alexander Melnyk
authored
fix: add layerVersionName param (#34)
* add layerVersionName param * fix tests * update lock
1 parent fc99af4 commit bede976

File tree

6 files changed

+799
-755
lines changed

6 files changed

+799
-755
lines changed

.projen/tasks.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

API.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ const powertoolsLayerProps: PowertoolsLayerProps = { ... }
9090
| **Name** | **Type** | **Description** |
9191
| --- | --- | --- |
9292
| [`includeExtras`](#cdklambdapowertoolspythonlayerpowertoolslayerpropspropertyincludeextras) | `boolean` | A flag for the pydantic extras dependency, used for parsing. |
93+
| [`layerVersionName`](#cdklambdapowertoolspythonlayerpowertoolslayerpropspropertylayerversionname) | `string` | the name of the layer, will be randomised if empty. |
9394
| [`version`](#cdklambdapowertoolspythonlayerpowertoolslayerpropspropertyversion) | `string` | The powertools package version from pypi repository. |
9495

9596
---
@@ -108,6 +109,18 @@ This will increase the size of the layer significantly. If you don't use parsing
108109

109110
---
110111

112+
##### `layerVersionName`<sup>Optional</sup> <a name="cdk-lambda-powertools-python-layer.PowertoolsLayerProps.property.layerVersionName" id="cdklambdapowertoolspythonlayerpowertoolslayerpropspropertylayerversionname"></a>
113+
114+
```typescript
115+
public readonly layerVersionName: string;
116+
```
117+
118+
- *Type:* `string`
119+
120+
the name of the layer, will be randomised if empty.
121+
122+
---
123+
111124
##### `version`<sup>Optional</sup> <a name="cdk-lambda-powertools-python-layer.PowertoolsLayerProps.property.version" id="cdklambdapowertoolspythonlayerpowertoolslayerpropspropertyversion"></a>
112125

113126
```typescript

package.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lambda-powertools-layer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export interface PowertoolsLayerProps {
1515
* This will increase the size of the layer significantly. If you don't use parsing, ignore it.
1616
*/
1717
readonly includeExtras?: boolean;
18+
19+
/**
20+
* the name of the layer, will be randomised if empty
21+
*/
22+
readonly layerVersionName?: string;
1823
}
1924

2025
/**
@@ -50,6 +55,7 @@ export class LambdaPowertoolsLayer extends lambda.LayerVersion {
5055
PACKAGE_SUFFIX: LambdaPowertoolsLayer.constructBuildArgs(props?.includeExtras, props?.version),
5156
},
5257
}),
58+
layerVersionName: props?.layerVersionName ? props?.layerVersionName : undefined,
5359
license: 'MIT-0',
5460
compatibleRuntimes: [
5561
lambda.Runtime.PYTHON_3_6,

test/lambda-powertools-layer.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Stack } from 'aws-cdk-lib';
22
import { Template } from 'aws-cdk-lib/assertions';
33
import { LambdaPowertoolsLayer } from '../lib';
44

5+
56
describe('with no configuration the construct', () => {
67
const stack = new Stack();
78
new LambdaPowertoolsLayer(stack, 'PowertoolsLayer');
@@ -30,6 +31,19 @@ describe('with no configuration the construct', () => {
3031
});
3132
});
3233

34+
describe('for layerVersionName configuraiton the construct', () => {
35+
test('synthisizes to a layer with provided name', () => {
36+
const stack = new Stack();
37+
new LambdaPowertoolsLayer(stack, 'PowertoolsLayer', {
38+
layerVersionName: 'mySpecialName',
39+
});
40+
41+
Template.fromStack(stack).hasResourceProperties('AWS::Lambda::LayerVersion', {
42+
LayerName: 'mySpecialName',
43+
});
44+
});
45+
});
46+
3347
describe('with version configuration the construct', () => {
3448
test('synthesizes to a layer with specific valid version', () => {
3549
const stack = new Stack();

0 commit comments

Comments
 (0)