Skip to content

Commit 8130c54

Browse files
committed
Update to version v1.79.0
1 parent 15300ed commit 8130c54

File tree

12 files changed

+138
-18
lines changed

12 files changed

+138
-18
lines changed

.github/workflows/slack-notify.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Issue Slack Notification
22-
if: github.event_name == 'issues' || github.event_name == 'issue_comment'
22+
if: ${{ github.event_name == 'issues' || (!github.event.issue.pull_request && github.event_name == 'issue_comment') }}
2323
uses: 8398a7/action-slack@v3
2424
with:
2525
status: custom
@@ -33,7 +33,7 @@ jobs:
3333
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
3434
ISSUE_NUMBER: ${{ github.event.issue.number }}
3535
- name: PR Slack Notification
36-
if: github.event_name == 'pull_request'
36+
if: ${{ github.event_name == 'pull_request' || (github.event.issue.pull_request && github.event_name == 'issue_comment') }}
3737
uses: 8398a7/action-slack@v3
3838
with:
3939
status: custom
@@ -47,10 +47,10 @@ jobs:
4747
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
4848
PR_NUMBER: ${{ github.event.number }}
4949
- name: Set env
50-
if: github.event_name == 'release'
50+
if: ${{ github.event_name == 'release' }}
5151
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
5252
- name: Release Slack Notification
53-
if: github.event_name == 'release'
53+
if: ${{ github.event_name == 'release' }}
5454
uses: 8398a7/action-slack@v3
5555
with:
5656
status: custom

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## 1.79.0 (2020-12-31)
6+
7+
### Changed
8+
- Upgraded all patterns to CDK v1.79.0
9+
- Fixed the override warning bug for `aws-lambda-step-function` pattern ([#108](https://github.com/awslabs/aws-solutions-constructs/issues/108))
10+
- Updated `aws-lambda-sqs` construct props `existingVpc` from `ec2.Vpc` to `ec2.IVpc`
11+
512
## 1.78.0 (2020-12-22)
613

714
### Changed

source/lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"./patterns/@aws-solutions-constructs/*"
77
],
88
"rejectCycles": "true",
9-
"version": "1.78.0"
9+
"version": "1.79.0"
1010
}

source/patterns/@aws-solutions-constructs/aws-lambda-sqs/README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,23 @@ _Parameters_
6363
|deployDeadLetterQueue?|`boolean`|Whether to create a secondary queue to be used as a dead letter queue. Defaults to `true`.|
6464
|deadLetterQueueProps?|[`sqs.QueueProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.QueueProps.html)|Optional user-provided props to override the default props for the dead letter queue. Only used if the `deployDeadLetterQueue` property is set to true.|
6565
|maxReceiveCount?|`number`|The number of times a message can be unsuccessfully dequeued before being moved to the dead letter queue. Defaults to `15`.|
66-
|existingVpc?|`ec2.Vpc`|An optional, existing VPC into which this construct should be deployed. When deployed in a VPC, the Lambda function will use ENIs in the VPC to access network resources and an Interface Endpoint will be created in the VPC for Amazon SQS. If an existing VPC is provided, the `deployVpc` property cannot be `true`|
67-
|deployVpc?|`boolean`|Whether to create a new VPC based on `vpcProps` into which to deploy this construct. Setting this to true will deploy the minimal, most private VPC to run the construct:
66+
|existingVpc?|[`ec2.IVpc`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ec2.IVpc.html)|An optional, existing VPC into which this pattern should be deployed. When deployed in a VPC, the Lambda function will use ENIs in the VPC to access network resources and an Interface Endpoint will be created in the VPC for Amazon SQS. If an existing VPC is provided, the `deployVpc` property cannot be `true`. This uses `ec2.IVpc` to allow clients to supply VPCs that exist outside the stack using the [`ec2.Vpc.fromLookup()`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ec2.Vpc.html#static-fromwbrlookupscope-id-options) method.|
67+
|deployVpc?|`boolean`|Whether to create a new VPC based on `vpcProps` into which to deploy this pattern. Setting this to true will deploy the minimal, most private VPC to run the pattern:
6868

6969
* One isolated subnet in each Availability Zone used by the CDK program
7070
* `enableDnsHostnames` and `enableDnsSupport` will both be set to true
7171

7272
If this property is `true` then `existingVpc` cannot be specified. Defaults to `false`.|
73-
|vpcProps?|`ec2.VpcProps`|Optional user-provided properties to override the default properties for the new VPC. `enableDnsHostnames`, `enableDnsSupport`, `natGateways` and `subnetConfiguration` are set by the Construct, so any values for those properties supplied here will be overrriden. If `deployVpc` is not `true` then this property will be ignored.|
74-
73+
|vpcProps?|`ec2.VpcProps`|Optional user-provided properties to override the default properties for the new VPC. `enableDnsHostnames`, `enableDnsSupport`, `natGateways` and `subnetConfiguration` are set by the pattern, so any values for those properties supplied here will be overrriden. If `deployVpc` is not `true` then this property will be ignored.|
74+
7575
## Pattern Properties
7676

7777
| **Name** | **Type** | **Description** |
7878
|:-------------|:----------------|-----------------|
7979
|lambdaFunction|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.Function.html)|Returns an instance of the Lambda function created by the pattern.|
8080
|sqsQueue|[`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.Queue.html)|Returns an instance of the SQS queue created by the pattern. |
8181
|deadLetterQueue?|[`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.Queue.html)|Returns an instance of the dead letter queue created by the pattern, if one is deployed.|
82+
|vpc?|[`ec2.IVpc`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ec2.IVpc.html)|Returns an interface on the VPC used by the pattern (if any). This may be a VPC created by the pattern or the VPC supplied to the pattern constructor.|
8283

8384
## Default settings
8485

source/patterns/@aws-solutions-constructs/aws-lambda-sqs/lib/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface LambdaToSqsProps {
7474
/**
7575
* An existing VPC for the construct to use (construct will NOT create a new VPC in this case)
7676
*/
77-
readonly existingVpc?: ec2.Vpc;
77+
readonly existingVpc?: ec2.IVpc;
7878
/**
7979
* Properties to override default properties if deployVpc is true
8080
*/
@@ -94,7 +94,7 @@ export class LambdaToSqs extends Construct {
9494
public readonly lambdaFunction: lambda.Function;
9595
public readonly sqsQueue: sqs.Queue;
9696
public readonly deadLetterQueue?: sqs.DeadLetterQueue;
97-
public readonly vpc?: ec2.Vpc;
97+
public readonly vpc?: ec2.IVpc;
9898

9999
/**
100100
* @summary Constructs a new instance of the LambdaToSqs class.

source/patterns/@aws-solutions-constructs/aws-lambda-sqs/test/lambda-sqs.test.ts

+32
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,38 @@ test("Test minimal deployment with an existing VPC", () => {
299299
});
300300
});
301301

302+
// --------------------------------------------------------------
303+
// Test minimal deployment with an existing VPC and existing Lambda function not in a VPCs
304+
//
305+
// buildLambdaFunction should throw an error if the Lambda function is not
306+
// attached to a VPC
307+
// --------------------------------------------------------------
308+
test("Test minimal deployment with an existing VPC and existing Lambda function not in a VPC", () => {
309+
// Stack
310+
const stack = new Stack();
311+
312+
const testLambdaFunction = new lambda.Function(stack, 'test-lamba', {
313+
runtime: lambda.Runtime.NODEJS_10_X,
314+
handler: "index.handler",
315+
code: lambda.Code.fromAsset(`${__dirname}/lambda`),
316+
});
317+
318+
const testVpc = new ec2.Vpc(stack, "test-vpc", {});
319+
320+
// Helper declaration
321+
const app = () => {
322+
// Helper declaration
323+
new LambdaToSqs(stack, "lambda-to-sqs-stack", {
324+
existingLambdaObj: testLambdaFunction,
325+
existingVpc: testVpc,
326+
});
327+
};
328+
329+
// Assertion
330+
expect(app).toThrowError();
331+
332+
});
333+
302334
// --------------------------------------------------------------
303335
// Test bad call with existingVpc and deployVpc
304336
// --------------------------------------------------------------

source/patterns/@aws-solutions-constructs/core/lib/lambda-helper.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface BuildLambdaFunctionProps {
3636
*
3737
* @default - none
3838
*/
39-
readonly vpc?: ec2.Vpc;
39+
readonly vpc?: ec2.IVpc;
4040
}
4141

4242
export function buildLambdaFunction(scope: cdk.Construct, props: BuildLambdaFunctionProps): lambda.Function {
@@ -48,14 +48,19 @@ export function buildLambdaFunction(scope: cdk.Construct, props: BuildLambdaFunc
4848
throw Error('Either existingLambdaObj or lambdaFunctionProps is required');
4949
}
5050
} else {
51+
if (props.vpc) {
52+
if (!props.existingLambdaObj.isBoundToVpc) {
53+
throw Error('A Lambda function must be bound to a VPC upon creation, it cannot be added to a VPC in a subsequent construct');
54+
}
55+
}
5156
return props.existingLambdaObj;
5257
}
5358
}
5459

5560
export function deployLambdaFunction(scope: cdk.Construct,
5661
lambdaFunctionProps: lambda.FunctionProps,
5762
functionId?: string,
58-
vpc?: ec2.Vpc): lambda.Function {
63+
vpc?: ec2.IVpc): lambda.Function {
5964

6065
const _functionId = functionId ? functionId : 'LambdaFunction';
6166
const _functionRoleId = _functionId + 'ServiceRole';

source/patterns/@aws-solutions-constructs/core/lib/override-warning-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function flagOverriddenDefaults(defaultProps: object, userProps: object)
4444
* 'Argument to Intrinsic must be a plain value object', so such props are excluded from the diff check.
4545
*/
4646
function _prefilter(_path: any[], _key: string): boolean {
47-
const prefilters = ['maxRecordAge', 'expiration', 'transitionAfter'];
47+
const prefilters = ['maxRecordAge', 'expiration', 'transitionAfter', 'destination', 'timeout'];
4848

4949
if (prefilters.indexOf(_key) >= 0) {
5050
return true;

source/patterns/@aws-solutions-constructs/core/lib/sagemaker-helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function addPermissions(_role: iam.Role) {
103103

104104
}
105105

106-
export function buildSagemakerNotebook(scope: cdk.Construct, props: BuildSagemakerNotebookProps): [sagemaker.CfnNotebookInstance, ec2.Vpc?,
106+
export function buildSagemakerNotebook(scope: cdk.Construct, props: BuildSagemakerNotebookProps): [sagemaker.CfnNotebookInstance, ec2.IVpc?,
107107
ec2.SecurityGroup?] {
108108
// Setup the notebook properties
109109
let sagemakerNotebookProps;

source/patterns/@aws-solutions-constructs/core/lib/vpc-helper.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface BuildVpcProps {
2020
/**
2121
* Existing instance of a VPC, if this is set then the all Props are ignored
2222
*/
23-
readonly existingVpc?: ec2.Vpc;
23+
readonly existingVpc?: ec2.IVpc;
2424
/**
2525
* User provided props to override the default props for the VPC.
2626
*/
@@ -32,7 +32,7 @@ export interface BuildVpcProps {
3232
readonly constructVpcProps?: ec2.VpcProps;
3333
}
3434

35-
export function buildVpc(scope: Construct, props?: BuildVpcProps): ec2.Vpc {
35+
export function buildVpc(scope: Construct, props?: BuildVpcProps): ec2.IVpc {
3636
if (props?.existingVpc) {
3737
return props?.existingVpc;
3838
}
@@ -116,7 +116,7 @@ const endpointSettings: EndpointDefinition[] = [
116116

117117
export function AddAwsServiceEndpoint(
118118
scope: Construct,
119-
vpc: ec2.Vpc,
119+
vpc: ec2.IVpc,
120120
interfaceTag: ServiceEndpointTypes
121121
) {
122122
if (!vpc.node.children.some((child) => child.node.id === interfaceTag)) {

source/patterns/@aws-solutions-constructs/core/test/lambda-helper.test.ts

+48
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,51 @@ test("Test for error if VPC in arguments AND in Lambda Function properties", ()
324324

325325
expect(app).toThrowError();
326326
});
327+
328+
test("Test minimal deployment with an existing VPC and existing Lambda function not in a VPC", () => {
329+
// Stack
330+
const stack = new Stack();
331+
332+
const testLambdaFunction = new lambda.Function(stack, 'test-lamba', {
333+
runtime: lambda.Runtime.NODEJS_10_X,
334+
handler: "index.handler",
335+
code: lambda.Code.fromAsset(`${__dirname}/lambda`),
336+
});
337+
338+
const testVpc = new ec2.Vpc(stack, "test-vpc", {});
339+
340+
const app = () => {
341+
defaults.buildLambdaFunction(stack, {
342+
existingLambdaObj: testLambdaFunction,
343+
vpc: testVpc,
344+
});
345+
346+
};
347+
348+
// Assertion
349+
expect(app).toThrowError();
350+
351+
});
352+
353+
test("Test minimal deployment with an existing VPC and existing Lambda function in a VPC", () => {
354+
// Stack
355+
const stack = new Stack();
356+
357+
const testVpc = new ec2.Vpc(stack, "test-vpc", {});
358+
359+
const testLambdaFunction = new lambda.Function(stack, 'test-lamba', {
360+
runtime: lambda.Runtime.NODEJS_10_X,
361+
handler: "index.handler",
362+
code: lambda.Code.fromAsset(`${__dirname}/lambda`),
363+
vpc: testVpc,
364+
});
365+
366+
defaults.buildLambdaFunction(stack, {
367+
existingLambdaObj: testLambdaFunction,
368+
vpc: testVpc,
369+
});
370+
371+
// All we're doing here is confirming that buildLambdaFunction does NOT
372+
// throw an exception when the existing Lambda function is in a VPCs
373+
374+
});

source/patterns/@aws-solutions-constructs/core/test/override-warning-service.test.ts

+27
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,31 @@ test('Test override warning on/off: undefined on', () => {
203203
overrideProps(a, b);
204204
// Assert
205205
expect(warn).toBeCalledTimes(1);
206+
});
207+
208+
// --------------------------------------------------------------
209+
// Test current prefilters
210+
// --------------------------------------------------------------
211+
test('Test current prefilters', () => {
212+
// Arrange
213+
const a = {
214+
destination: 'sampleDestinationValueA',
215+
maxRecordAge: 'sampleMaxRecordAgeValueA',
216+
expiration: 'sampleExpirationValueA',
217+
transitionAfter: 'sampleTransitionValueA',
218+
timeout: 'sampleTimeoutValueA'
219+
};
220+
const b = {
221+
destination: 'sampleDestinationValueB',
222+
maxRecordAge: 'sampleMaxRecordAgeValueB',
223+
expiration: 'sampleExpirationValueB',
224+
transitionAfter: 'sampleTransitionValueB',
225+
timeout: 'sampleTimeoutValueB'
226+
};
227+
// Act
228+
const warn = jest.spyOn(log, 'warn');
229+
process.env.overrideWarningsEnabled = undefined;
230+
overrideProps(a, b);
231+
// Assert
232+
expect(warn).toBeCalledTimes(0);
206233
});

0 commit comments

Comments
 (0)