Skip to content

Instantly share code, notes, and snippets.

@codemilli
Created September 18, 2017 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codemilli/ee333027da984746269211c7ae2421ef to your computer and use it in GitHub Desktop.
Save codemilli/ee333027da984746269211c7ae2421ef to your computer and use it in GitHub Desktop.
check cloudfront invalidation done
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment