From e76706fb6eec09c55d43c419dc660dce37c0d4cf Mon Sep 17 00:00:00 2001 From: Philipp Muens Date: Mon, 7 Nov 2016 15:29:47 +0100 Subject: [PATCH] Check if default policy is available when merging PolicyDocument statements for streams --- .../aws/deploy/compile/events/stream/index.js | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/plugins/aws/deploy/compile/events/stream/index.js b/lib/plugins/aws/deploy/compile/events/stream/index.js index 07284e90f..bbbb278a5 100644 --- a/lib/plugins/aws/deploy/compile/events/stream/index.js +++ b/lib/plugins/aws/deploy/compile/events/stream/index.js @@ -113,20 +113,23 @@ class AwsCompileStreamEvents { }; } - // update the PolicyDocument statements - const statement = this.serverless.service.provider.compiledCloudFormationTemplate - .Resources - .IamPolicyLambdaExecution - .Properties - .PolicyDocument - .Statement; + // update the PolicyDocument statements (if default policy is used) + if (this.serverless.service.provider.compiledCloudFormationTemplate + .Resources.IamPolicyLambdaExecution) { + const statement = this.serverless.service.provider.compiledCloudFormationTemplate + .Resources + .IamPolicyLambdaExecution + .Properties + .PolicyDocument + .Statement; - this.serverless.service.provider.compiledCloudFormationTemplate - .Resources - .IamPolicyLambdaExecution - .Properties - .PolicyDocument - .Statement = statement.concat([streamStatement]); + this.serverless.service.provider.compiledCloudFormationTemplate + .Resources + .IamPolicyLambdaExecution + .Properties + .PolicyDocument + .Statement = statement.concat([streamStatement]); + } const newStreamObject = { [`${normalizedFunctionName}EventSourceMapping${