Fix s3 is undefined bug

This commit is contained in:
Philipp Muens 2016-06-14 20:03:56 +02:00
parent 5eed5c3621
commit 8ea06053a2

View File

@ -42,7 +42,9 @@ class AwsCompileS3Events {
this.serverless.service.getAllFunctions().forEach((functionName) => {
const s3BucketObject = this.serverless.service.getFunction(functionName);
if (s3BucketObject.events.aws.s3) {
// checking all three levels in the obj tree
// to avoid "can't read property of undefined" error
if (s3BucketObject.events && s3BucketObject.events.aws && s3BucketObject.events.aws.s3) {
// iterate over all defined buckets
s3BucketObject.events.aws.s3.forEach((bucketName) => {
// 1. create the S3 bucket with the corresponding notification