@@ -5,6 +5,7 @@ import events = require('@aws-cdk/aws-events');
5
5
import iam = require( '@aws-cdk/aws-iam' ) ;
6
6
import logs = require( '@aws-cdk/aws-logs' ) ;
7
7
import s3n = require( '@aws-cdk/aws-s3-notifications' ) ;
8
+ import stepfunctions = require( '@aws-cdk/aws-stepfunctions' ) ;
8
9
import cdk = require( '@aws-cdk/cdk' ) ;
9
10
import { cloudformation } from './lambda.generated' ;
10
11
import { Permission } from './permission' ;
@@ -39,7 +40,7 @@ export interface FunctionRefProps {
39
40
40
41
export abstract class FunctionRef extends cdk . Construct
41
42
implements events . IEventRuleTarget , logs . ILogSubscriptionDestination , s3n . IBucketNotificationDestination ,
42
- ec2 . IConnectable {
43
+ ec2 . IConnectable , stepfunctions . IStepFunctionsTaskResource {
43
44
44
45
/**
45
46
* Creates a Lambda function object which represents a function not defined
@@ -352,6 +353,19 @@ export abstract class FunctionRef extends cdk.Construct
352
353
} ;
353
354
}
354
355
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
+
355
369
private parsePermissionPrincipal ( principal ?: iam . PolicyPrincipal ) {
356
370
if ( ! principal ) {
357
371
return undefined ;
0 commit comments