@@ -20,8 +20,6 @@ export interface LambdaInvokeActionProps extends codepipeline.CommonActionProps
20
20
*/
21
21
readonly inputs ?: codepipeline . Artifact [ ] ;
22
22
23
- // tslint:enable:max-line-length
24
-
25
23
/**
26
24
* The optional names of the output Artifacts of the Action.
27
25
* A Lambda Action can have up to 5 outputs.
@@ -34,30 +32,14 @@ export interface LambdaInvokeActionProps extends codepipeline.CommonActionProps
34
32
readonly outputs ?: codepipeline . Artifact [ ] ;
35
33
36
34
/**
37
- * String to be used in the event data parameter passed to the Lambda
38
- * function
39
- *
40
- * See an example JSON event in the CodePipeline documentation.
35
+ * A set of key-value pairs that will be accessible to the invoked Lambda
36
+ * inside the event that the Pipeline will call it with.
41
37
*
42
- * https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html#actions-invoke-lambda-function-json-event-example
38
+ * @see https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html#actions-invoke-lambda-function-json-event-example
43
39
*/
44
- readonly userParameters ?: any ;
40
+ readonly userParameters ?: { [ key : string ] : any } ;
45
41
46
- /**
47
- * Adds the "codepipeline:PutJobSuccessResult" and
48
- * "codepipeline:PutJobFailureResult" for '*' resource to the Lambda
49
- * execution role policy.
50
- *
51
- * NOTE: the reason we can't add the specific pipeline ARN as a resource is
52
- * to avoid a cyclic dependency between the pipeline and the Lambda function
53
- * (the pipeline references) the Lambda and the Lambda needs permissions on
54
- * the pipeline.
55
- *
56
- * @see https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html#actions-invoke-lambda-function-create-function
57
- *
58
- * @default true
59
- */
60
- readonly addPutJobResultPolicy ?: boolean ;
42
+ // tslint:enable:max-line-length
61
43
62
44
/**
63
45
* The lambda function to invoke.
@@ -86,8 +68,8 @@ export class LambdaInvokeAction extends codepipeline.Action {
86
68
} ,
87
69
configuration : {
88
70
FunctionName : props . lambda . functionName ,
89
- UserParameters : props . userParameters
90
- }
71
+ UserParameters : props . lambda . node . stringifyJson ( props . userParameters ) ,
72
+ } ,
91
73
} ) ;
92
74
93
75
this . props = props ;
@@ -104,13 +86,12 @@ export class LambdaInvokeAction extends codepipeline.Action {
104
86
. addAction ( 'lambda:InvokeFunction' )
105
87
. addResource ( this . props . lambda . functionArn ) ) ;
106
88
107
- // allow lambda to put job results for this pipeline.
108
- const addToPolicy = this . props . addPutJobResultPolicy !== undefined ? this . props . addPutJobResultPolicy : true ;
109
- if ( addToPolicy ) {
110
- this . props . lambda . addToRolePolicy ( new iam . PolicyStatement ( )
111
- . addAllResources ( ) // to avoid cycles (see docs)
112
- . addAction ( 'codepipeline:PutJobSuccessResult' )
113
- . addAction ( 'codepipeline:PutJobFailureResult' ) ) ;
114
- }
89
+ // allow lambda to put job results for this pipeline
90
+ // CodePipeline requires this to be granted to '*'
91
+ // (the Pipeline ARN will not be enough)
92
+ this . props . lambda . addToRolePolicy ( new iam . PolicyStatement ( )
93
+ . addAllResources ( )
94
+ . addAction ( 'codepipeline:PutJobSuccessResult' )
95
+ . addAction ( 'codepipeline:PutJobFailureResult' ) ) ;
115
96
}
116
97
}
0 commit comments