lib/plugins/aws/customResources/resources/s3/lib/bucket.js/updateConfiguration
function updateConfiguration(config) {
  const { lambdaArn, functionName, bucketName, bucketConfigs, region } = config;
  const s3 = new AWS.S3({ region });
  const Bucket = bucketName;

  return getConfiguration(config).then(NotificationConfiguration => {
    // remove configurations for this specific function
    NotificationConfiguration.LambdaFunctionConfigurations = NotificationConfiguration.LambdaFunctionConfigurations.filter(
      conf => !conf.Id.startsWith(functionName)
    );

    // add the events to the existing NotificationConfiguration
    bucketConfigs.forEach(bucketConfig => {
      const Events = [bucketConfig.Event];
      const LambdaFunctionArn = lambdaArn;
      const Id = generateId(functionName, bucketConfig);
      const Filter = createFilter(bucketConfig);
      NotificationConfiguration.LambdaFunctionConfigurations.push({
        Events,
        LambdaFunctionArn,
        Filter,
        Id,
      });
    });

    const payload = {
      Bucket,
      NotificationConfiguration,
    };
    return s3.putBucketNotificationConfiguration(payload).promise();
  });
}