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

fix: add layerVersionName param #34

Merged
merged 3 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

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

---

##### `layerVersionName`<sup>Optional</sup> <a name="cdk-lambda-powertools-python-layer.PowertoolsLayerProps.property.layerVersionName" id="cdklambdapowertoolspythonlayerpowertoolslayerpropspropertylayerversionname"></a>

```typescript
public readonly layerVersionName: string;
```

- *Type:* `string`

the name of the layer, will be randomised if empty.

---

##### `version`<sup>Optional</sup> <a name="cdk-lambda-powertools-python-layer.PowertoolsLayerProps.property.version" id="cdklambdapowertoolspythonlayerpowertoolslayerpropspropertyversion"></a>

```typescript
Expand Down
1 change: 1 addition & 0 deletions package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/lambda-powertools-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export interface PowertoolsLayerProps {
* This will increase the size of the layer significantly. If you don't use parsing, ignore it.
*/
readonly includeExtras?: boolean;

/**
* the name of the layer, will be randomised if empty
*/
readonly layerVersionName?: string;
}

/**
Expand Down Expand Up @@ -50,6 +55,7 @@ export class LambdaPowertoolsLayer extends lambda.LayerVersion {
PACKAGE_SUFFIX: LambdaPowertoolsLayer.constructBuildArgs(props?.includeExtras, props?.version),
},
}),
layerVersionName: props?.layerVersionName ? props?.layerVersionName : undefined,
license: 'MIT-0',
compatibleRuntimes: [
lambda.Runtime.PYTHON_3_6,
Expand Down
14 changes: 14 additions & 0 deletions test/lambda-powertools-layer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Stack } from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
import { LambdaPowertoolsLayer } from '../lib';


describe('with no configuration the construct', () => {
const stack = new Stack();
new LambdaPowertoolsLayer(stack, 'PowertoolsLayer');
Expand Down Expand Up @@ -30,6 +31,19 @@ describe('with no configuration the construct', () => {
});
});

describe('for layerVersionName configuraiton the construct', () => {
test('synthisizes to a layer with provided name', () => {
const stack = new Stack();
new LambdaPowertoolsLayer(stack, 'PowertoolsLayer', {
layerVersionName: 'mySpecialName',
});

Template.fromStack(stack).hasResourceProperties('AWS::Lambda::LayerVersion', {
LayerName: 'mySpecialName',
});
});
});

describe('with version configuration the construct', () => {
test('synthesizes to a layer with specific valid version', () => {
const stack = new Stack();
Expand Down
Loading