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${