Skip to content

Commit

Permalink
Merge pull request #927 from awslabs/bump/2.34.0
Browse files Browse the repository at this point in the history
chore(release): 2.34.0
  • Loading branch information
biffgaut authored Mar 18, 2023
2 parents 58e726f + 452b2f6 commit bc4b391
Show file tree
Hide file tree
Showing 96 changed files with 998 additions and 119 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

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.

## [2.34.0](https://github.com/awslabs/aws-solutions-constructs/compare/v2.33.0...v2.34.0) (2023-03-18)

Built on CDK v2.68.0

### Bug Fixes

* **StepFunctions:** Address LogGroup behavior problems ([#922](https://github.com/awslabs/aws-solutions-constructs/issues/922)) ([84e581c](https://github.com/awslabs/aws-solutions-constructs/commit/84e581cad10f59daf827fb6e8f8101e1ec6b11f3))

## [2.33.0](https://github.com/awslabs/aws-solutions-constructs/compare/v2.32.0...v2.33.0) (2023-03-03)

Build on CDK v2.67.0
Expand Down
2 changes: 1 addition & 1 deletion deployment/v2/align-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const findVersion = process.argv[2];
const replaceVersion = process.argv[3];

// these versions need to be sourced from a config file
const awsCdkLibVersion = '2.67.0';
const awsCdkLibVersion = '2.68.0';
const constructsVersion = '10.0.0';
const MODULE_EXEMPTIONS = new Set([
'@aws-cdk/cloudformation-diff',
Expand Down
2 changes: 1 addition & 1 deletion source/lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"./patterns/@aws-solutions-constructs/*"
],
"rejectCycles": "true",
"version": "2.33.0"
"version": "2.34.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Duration } from 'aws-cdk-lib';
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
import '@aws-cdk/assert/jest';
import * as cdk from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';

function deployNewStateMachine(stack: cdk.Stack) {

Expand Down Expand Up @@ -192,4 +193,28 @@ test('check custom event bus resource with props when deploy:true', () => {
expect(stack).toHaveResource('AWS::Events::EventBus', {
Name: 'testcustomeventbus'
});
});
});

test('check LogGroup name', () => {
const stack = new cdk.Stack();

deployNewStateMachine(stack);

// Perform some fancy stuff to examine the specifics of the LogGroupName
const expectedPrefix = '/aws/vendedlogs/states/constructs/';
const lengthOfDatetimeSuffix = 13;

const LogGroup = Template.fromStack(stack).findResources("AWS::Logs::LogGroup");

const logName = LogGroup.testeventbridgestepfunctionsStateMachineLogGroup826A5B74.Properties.LogGroupName;
const suffix = logName.slice(-lengthOfDatetimeSuffix);

// Look for the expected Prefix and the 13 digit time suffix
expect(logName.slice(0, expectedPrefix.length)).toEqual(expectedPrefix);
expect(IsWholeNumber(suffix)).not.toBe(false);
});

function IsWholeNumber(target: string): boolean {
const numberPattern = /[0-9]{13}/;
return target.match(numberPattern) !== null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"testeventbridgestepfunctionsneweventbusconstructStateMachineLogGroup6DC6AD59": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/eventbridgestepfunctionsexistingeventbustesteventbridgestepfunctionsneweventbusconstructstatemachinelogac9442d7e2fa"
"LogGroupName": "integ-test-existing-eventbus"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const props: EventbridgeToStepfunctionsProps = {
},
existingEventBusInterface: existingEventBus,
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "integ-test-existing-eventbus"
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"testeventbridgestepfunctionsneweventbusconstructStateMachineLogGroup6DC6AD59": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/eventbridgestepfunctionsneweventbustesteventbridgestepfunctionsneweventbusconstructstatemachinelog651032919fdf"
"LogGroupName": "integ-test-new-eventbus"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ const props: EventbridgeToStepfunctionsProps = {
},
eventBusProps: { eventBusName: 'test' },
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "integ-test-new-eventbus"
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"testeventbridgestepfunctionsconstructStateMachineLogGroup3098B32C": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/eventbridgestepfunctionsnoargumenttesteventbridgestepfunctionsconstructstatemachinelog56559569213c"
"LogGroupName": "integ-test-no-arguments"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const props: EventbridgeToStepfunctionsProps = {
schedule: events.Schedule.rate(Duration.minutes(5))
},
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "integ-test-no-arguments"
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"testeventbridgestepfunctionsandlambdaconstructStateMachineLogGroup7C2D036A": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/eventbridgestepfunctionswithlambdatesteventbridgestepfunctionsandlambdaconstructstatemachinelog1db1bc901e42"
"LogGroupName": "with-lambda"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const props: EventbridgeToStepfunctionsProps = {
schedule: events.Schedule.rate(Duration.minutes(5))
},
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "with-lambda"
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FargateToStepfunctions } from "../lib";
import * as stepfunctions from 'aws-cdk-lib/aws-stepfunctions';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import { Template } from 'aws-cdk-lib/assertions';

const clusterName = "custom-cluster-name";
const containerName = "custom-container-name";
Expand Down Expand Up @@ -311,4 +312,29 @@ function testStateMachineProps(stack: cdk.Stack, userProps?: stepfunctions.State
const defaultTestProp = { definition: new stepfunctions.Pass(stack, 'StartState') };

return defaults.consolidateProps(defaultTestProp, userProps);
}
}

test('check LogGroup name', () => {
const stack = new cdk.Stack();
const publicApi = true;

createFargateConstructWithNewResources(stack, publicApi);

// Perform some fancy stuff to examine the specifics of the LogGroupName
const expectedPrefix = '/aws/vendedlogs/states/constructs/';
const lengthOfDatetimeSuffix = 13;

const LogGroup = Template.fromStack(stack).findResources("AWS::Logs::LogGroup");

const logName = LogGroup.testconstructStateMachineLogGroup2EB4F48B.Properties.LogGroupName;
const suffix = logName.slice(-lengthOfDatetimeSuffix);

// Look for the expected Prefix and the 13 digit time suffix
expect(logName.slice(0, expectedPrefix.length)).toEqual(expectedPrefix);
expect(IsWholeNumber(suffix)).not.toBe(false);
});

function IsWholeNumber(target: string): boolean {
const numberPattern = /[0-9]{13}/;
return target.match(numberPattern) !== null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@
"testconstructStateMachineLogGroup2EB4F48B": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/newresourcestestconstructstatemachinelog63b3cb15f80b"
"LogGroupName": "with-lambda"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ const constructProps: FargateToStepfunctionsProps = {
existingFargateServiceObject: createFargateServiceResponse.service,
stateMachineEnvironmentVariableName: 'CUSTOM_NAME',
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "with-lambda"
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@
"testconstructStateMachineLogGroup2EB4F48B": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/nocloudwatchalarmstestconstructstatemachinelogdbb9902b27ea"
"LogGroupName": "with-lambda"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ const constructProps: FargateToStepfunctionsProps = {
existingFargateServiceObject: createFargateServiceResponse.service,
createCloudWatchAlarms: false,
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "with-lambda"
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"testlambdastepfunctionsconstructStateMachineLogGroup1FD4C0D4": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/deploylambdatestlambdastepfunctionsconstructstatemachinelogb258d52dbe27"
"LogGroupName": "with-lambda"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ const props: LambdaToStepfunctionsProps = {
definition: startState
},
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
},
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "with-lambda"
}
};

// Add the pattern
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"testlambdastepfunctionsStateMachineLogGroupD3F22A89": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/deployfunctionwithvpctestlambdastepfunctionsstatemachinelog97398dca7a29"
"LogGroupName": "with-lambda"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ const props: LambdaToStepfunctionsProps = {
stateMachineProps: {
definition: startState
},
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
},
deployVpc: true,
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "with-lambda"
}
};

new LambdaToStepfunctions(stack, "test-lambda-stepfunctions", props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"testlambdastepfunctionsconstructStateMachineLogGroup1FD4C0D4": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/existingfunctiontestlambdastepfunctionsconstructstatemachinelog9e0bca5b4cd6"
"LogGroupName": "with-lambda"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ const props: LambdaToStepfunctionsProps = {
definition: startState
},
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
},
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "with-lambda"
}
};

// Add the pattern
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as stepfunctions from 'aws-cdk-lib/aws-stepfunctions';
import * as ec2 from "aws-cdk-lib/aws-ec2";
import { LambdaToStepfunctions } from '../lib';
import '@aws-cdk/assert/jest';
import { Template } from "aws-cdk-lib/assertions";

// --------------------------------------------------------------
// Test deployment with new Lambda function
Expand Down Expand Up @@ -461,4 +462,41 @@ test("Test bad call with existingVpc and deployVpc", () => {
};
// Assertion
expect(app).toThrowError();
});
});

test('check LogGroup name', () => {
// Stack
const stack = new Stack();
// Helper declaration
const startState = new stepfunctions.Pass(stack, 'StartState');
new LambdaToStepfunctions(stack, 'lambda-to-step-function-stack', {
lambdaFunctionProps: {
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(`${__dirname}/lambda`),
environment: {
LAMBDA_NAME: 'existing-function'
}
},
stateMachineProps: {
definition: startState
}
});
// Perform some fancy stuff to examine the specifics of the LogGroupName
const expectedPrefix = '/aws/vendedlogs/states/constructs/';
const lengthOfDatetimeSuffix = 13;

const LogGroup = Template.fromStack(stack).findResources("AWS::Logs::LogGroup");

const logName = LogGroup.lambdatostepfunctionstackStateMachineLogGroupEAD4854E.Properties.LogGroupName;
const suffix = logName.slice(-lengthOfDatetimeSuffix);

// Look for the expected Prefix and the 13 digit time suffix
expect(logName.slice(0, expectedPrefix.length)).toEqual(expectedPrefix);
expect(IsWholeNumber(suffix)).not.toBe(false);
});

function IsWholeNumber(target: string): boolean {
const numberPattern = /[0-9]{13}/;
return target.match(numberPattern) !== null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"tests3stepfunctionstests3stepfunctionseventrulestepfunctionconstructStateMachineLogGroupB4555776": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/customloggingbuckettests3stepfunctionseventrulestepfunctionconstructstatemachineloga4e9bc58c9e9"
"LogGroupName": "with-lambda"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ new S3ToStepfunctions(stack, 'test-s3-stepfunctions', {
versioned: true
},
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "with-lambda"
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
"tests3stepfunctionspreexistingbucketconstructtests3stepfunctionspreexistingbucketconstructeventrulestepfunctionconstructStateMachineLogGroup9D5E3E4D": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/preexistingbuckettests3stepfunctionspreexistingbucketconstructeventrulestepfunctstatemachineloga29d0790019e"
"LogGroupName": "with-lambda"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const props: S3ToStepfunctionsProps = {
definition: startState
},
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "with-lambda"
},
logS3AccessLogs: false
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"tests3stepfunctionsconstructtests3stepfunctionsconstructeventrulestepfunctionconstructStateMachineLogGroupE86C2CF5": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/s3stepfunctionsnoargumenttests3stepfunctionsconstructeventrulestepfunctionconstructstatemachinelogf07752992857"
"LogGroupName": "with-lambda"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const props: S3ToStepfunctionsProps = {
removalPolicy: RemovalPolicy.DESTROY,
},
logGroupProps: {
removalPolicy: RemovalPolicy.DESTROY
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: "with-lambda"
},
logS3AccessLogs: false
};
Expand Down
Loading

0 comments on commit bc4b391

Please sign in to comment.