code: function invalidate(dist, paths, options, callback) {
          var cloudfront = new AWS.CloudFront();
  
          if (options.accessKeyId) {
              cloudfront.config.update({
                  accessKeyId: options.accessKeyId,
                  secretAccessKey: options.secretAccessKey,
              });
          }
          
          paths = paths.map(function (v) {
              if (v.charAt(0) === "/") {
                  return v;
              } else {
                  return "/" + v;
              }
          });
          
          var callerReference = "cf-invalidate-" + Date.now() + "_" + randomDigits();
          
          cloudfront.createInvalidation({
              DistributionId: dist,
              InvalidationBatch: {
                  CallerReference: callerReference,
                  Paths: {
                      Quantity: paths.length,
                      Items: paths,
                  },
              },
          }, function (err, res) {
              if (err) {return callback(err);}
              
              var invalidationId = res.Invalidation.Id;
              if (options.wait) {
                  var i = 0;
                  var iteration = function () {
                      cloudfront.getInvalidation({
                          DistributionId: dist,
                          Id: invalidationId
                      }, function (err, res) {
                          if (err) {return callback(err);}
                          
                          if (res.Invalidation.Status === "Completed") {
                              return callback();
                          } else {
                              var nextTry = Math.min(60000, 1000 * Math.pow(2, i++));
                              log('Invalidation not done yet, next try in ' + nextTry + 'ms.');
                              setTimeout(function () {
                                  iteration();
                              }, nextTry);
                          }
                          
                      });
                  };
                  iteration();
                  
              } else {
                  callback();
              }
              
          });
          
      }
docs: Function: invalidate
  
  Invalidates objects on cloudfront.
  
  Parameters:
  dist - Cloudfront distribution ID
  paths - An array of pathnames to invalidate
  options - Options object
  wait - If true, wait until the invalidation is complete.
  accessKeyId - If set, use this as the AWS key ID
  secretAccessKey - The AWS secret key
  callback - Callback