Skip to content

Commit 4bfa188

Browse files
authored
Merge pull request #285 from mickychetta/issue-271
feat(aws-lambda-stepfunctions): aws-lambda-stepfunctions implementation
2 parents 99a4f44 + 477a86a commit 4bfa188

23 files changed

+2476
-148
lines changed

.viperlightignore

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ source/patterns/@aws-solutions-constructs/aws-iot-lambda-dynamodb/test/iot-lambd
2424
source/patterns/@aws-solutions-constructs/aws-lambda-dynamodb/test/lambda-dynamodb.test.ts:186
2525
source/patterns/@aws-solutions-constructs/aws-lambda-sqs-lambda/test/lambda-sqs-lambda.test.ts:66
2626
source/patterns/@aws-solutions-constructs/aws-lambda-step-function/test/lambda-step-function.test.ts:129
27+
source/patterns/@aws-solutions-constructs/aws-lambda-stepfunctions/test/lambda-stepfunctions.test.ts:129
2728
source/patterns/@aws-solutions-constructs/aws-events-rule-sns/test/events-rule-sns-topic.test.ts:243
2829
source/patterns/@aws-solutions-constructs/aws-events-rule-sqs/test/events-rule-sqs-queue.test.ts:131
2930
source/patterns/@aws-solutions-constructs/aws-dynamodb-stream-lambda/test/dynamodb-stream-lambda.test.ts:105

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
---
55

6-
![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)
6+
![Stability: Deprecated](https://img.shields.io/badge/STABILITY-DEPRECATED-red?style=for-the-badge)
7+
8+
> Some of our early constructs don’t meet the naming standards that evolved for the library. We are releasing completely feature compatible versions with corrected names. The underlying implementation code is the same regardless of whether you deploy the construct using the old or new name. We will support both names for all 1.x releases, but in 2.x we will only publish the correctly named constructs.
79
810
> All classes are under active development and subject to non-backward compatible changes or removal in any
911
> future version. These are not subject to the [Semantic Versioning](https://semver.org/) model.

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

+7-23
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
1616
import * as lambda from '@aws-cdk/aws-lambda';
1717
import * as sfn from '@aws-cdk/aws-stepfunctions';
18-
import * as defaults from '@aws-solutions-constructs/core';
18+
import { LambdaToStepfunctions } from "@aws-solutions-constructs/aws-lambda-stepfunctions";
1919
import { Construct } from '@aws-cdk/core';
2020
import * as logs from '@aws-cdk/aws-logs';
2121

@@ -80,28 +80,12 @@ export class LambdaToStepFunction extends Construct {
8080
*/
8181
constructor(scope: Construct, id: string, props: LambdaToStepFunctionProps) {
8282
super(scope, id);
83-
defaults.CheckProps(props);
83+
const convertedProps: LambdaToStepFunctionProps = { ...props };
84+
const wrappedConstruct: LambdaToStepFunction = new LambdaToStepfunctions(this, `${id}-wrapped`, convertedProps);
8485

85-
// Setup the state machine
86-
[this.stateMachine, this.stateMachineLogGroup] = defaults.buildStateMachine(this, props.stateMachineProps,
87-
props.logGroupProps);
88-
89-
// Setup the Lambda function
90-
this.lambdaFunction = defaults.buildLambdaFunction(this, {
91-
existingLambdaObj: props.existingLambdaObj,
92-
lambdaFunctionProps: props.lambdaFunctionProps,
93-
});
94-
95-
// Assign the state machine ARN as an environment variable
96-
const stateMachineEnvironmentVariableName = props.stateMachineEnvironmentVariableName || 'STATE_MACHINE_ARN';
97-
this.lambdaFunction.addEnvironment(stateMachineEnvironmentVariableName, this.stateMachine.stateMachineArn);
98-
99-
// Grant the start execution permission to the Lambda function
100-
this.stateMachine.grantStartExecution(this.lambdaFunction);
101-
102-
if (props.createCloudWatchAlarms === undefined || props.createCloudWatchAlarms) {
103-
// Deploy best-practice CloudWatch Alarm for state machine
104-
this.cloudwatchAlarms = defaults.buildStepFunctionCWAlarms(this, this.stateMachine);
105-
}
86+
this.lambdaFunction = wrappedConstruct.lambdaFunction;
87+
this.stateMachine = wrappedConstruct.stateMachine;
88+
this.stateMachineLogGroup = wrappedConstruct.stateMachineLogGroup;
89+
this.cloudwatchAlarms = wrappedConstruct.cloudwatchAlarms;
10690
}
10791
}

source/patterns/@aws-solutions-constructs/aws-lambda-step-function/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@aws-cdk/aws-logs": "0.0.0",
6060
"@aws-cdk/core": "0.0.0",
6161
"@aws-solutions-constructs/core": "0.0.0",
62+
"@aws-solutions-constructs/aws-lambda-stepfunctions": "0.0.0",
6263
"constructs": "^3.2.0"
6364
},
6465
"devDependencies": {
@@ -87,6 +88,7 @@
8788
"@aws-cdk/aws-stepfunctions": "0.0.0",
8889
"@aws-cdk/core": "0.0.0",
8990
"@aws-solutions-constructs/core": "0.0.0",
91+
"@aws-solutions-constructs/aws-lambda-stepfunctions": "0.0.0",
9092
"constructs": "^3.2.0",
9193
"@aws-cdk/aws-logs": "0.0.0"
9294
},

0 commit comments

Comments
 (0)