Skip to content

Commit

Permalink
feat: add support for Step Functions (#827)
Browse files Browse the repository at this point in the history
Adds a construct library to model state machines in AWS Step Functions. Integrates with AWS Lambda to make it easy to build serverless workflows.
  • Loading branch information
rix0rrr authored Oct 16, 2018
1 parent 5558fff commit 81b533c
Show file tree
Hide file tree
Showing 30 changed files with 4,000 additions and 12 deletions.
16 changes: 15 additions & 1 deletion packages/@aws-cdk/aws-lambda/lib/lambda-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import events = require('@aws-cdk/aws-events');
import iam = require('@aws-cdk/aws-iam');
import logs = require('@aws-cdk/aws-logs');
import s3n = require('@aws-cdk/aws-s3-notifications');
import stepfunctions = require('@aws-cdk/aws-stepfunctions');
import cdk = require('@aws-cdk/cdk');
import { cloudformation } from './lambda.generated';
import { Permission } from './permission';
Expand Down Expand Up @@ -39,7 +40,7 @@ export interface FunctionRefProps {

export abstract class FunctionRef extends cdk.Construct
implements events.IEventRuleTarget, logs.ILogSubscriptionDestination, s3n.IBucketNotificationDestination,
ec2.IConnectable {
ec2.IConnectable, stepfunctions.IStepFunctionsTaskResource {

/**
* Creates a Lambda function object which represents a function not defined
Expand Down Expand Up @@ -352,6 +353,19 @@ export abstract class FunctionRef extends cdk.Construct
};
}

public asStepFunctionsTaskResource(_callingTask: stepfunctions.Task): stepfunctions.StepFunctionsTaskResourceProps {
return {
resourceArn: this.functionArn,
metricPrefixSingular: 'LambdaFunction',
metricPrefixPlural: 'LambdaFunctions',
metricDimensions: { LambdaFunctionArn: this.functionArn },
policyStatements: [new iam.PolicyStatement()
.addResource(this.functionArn)
.addActions("lambda:InvokeFunction")
]
};
}

private parsePermissionPrincipal(principal?: iam.PolicyPrincipal) {
if (!principal) {
return undefined;
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-lambda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"@aws-cdk/aws-s3": "^0.12.0",
"@aws-cdk/aws-s3-notifications": "^0.12.0",
"@aws-cdk/aws-sqs": "^0.12.0",
"@aws-cdk/aws-stepfunctions": "^0.12.0",
"@aws-cdk/cdk": "^0.12.0",
"@aws-cdk/cx-api": "^0.12.0"
},
Expand Down
Loading

0 comments on commit 81b533c

Please sign in to comment.