@@ -5,6 +5,7 @@ import events = require('@aws-cdk/aws-events');
55import iam = require( '@aws-cdk/aws-iam' ) ;
66import logs = require( '@aws-cdk/aws-logs' ) ;
77import s3n = require( '@aws-cdk/aws-s3-notifications' ) ;
8+ import stepfunctions = require( '@aws-cdk/aws-stepfunctions' ) ;
89import cdk = require( '@aws-cdk/cdk' ) ;
910import { cloudformation } from './lambda.generated' ;
1011import { Permission } from './permission' ;
@@ -39,7 +40,7 @@ export interface FunctionRefProps {
3940
4041export abstract class FunctionRef extends cdk . Construct
4142 implements events . IEventRuleTarget , logs . ILogSubscriptionDestination , s3n . IBucketNotificationDestination ,
42- ec2 . IConnectable {
43+ ec2 . IConnectable , stepfunctions . IStepFunctionsTaskResource {
4344
4445 /**
4546 * Creates a Lambda function object which represents a function not defined
@@ -352,6 +353,19 @@ export abstract class FunctionRef extends cdk.Construct
352353 } ;
353354 }
354355
356+ public asStepFunctionsTaskResource ( _callingTask : stepfunctions . Task ) : stepfunctions . StepFunctionsTaskResourceProps {
357+ return {
358+ resourceArn : this . functionArn ,
359+ metricPrefixSingular : 'LambdaFunction' ,
360+ metricPrefixPlural : 'LambdaFunctions' ,
361+ metricDimensions : { LambdaFunctionArn : this . functionArn } ,
362+ policyStatements : [ new iam . PolicyStatement ( )
363+ . addResource ( this . functionArn )
364+ . addActions ( "lambda:InvokeFunction" )
365+ ]
366+ } ;
367+ }
368+
355369 private parsePermissionPrincipal ( principal ?: iam . PolicyPrincipal ) {
356370 if ( ! principal ) {
357371 return undefined ;
0 commit comments