*Warning: Your first 1,000 invalidated items ('/*' will invalidate multiple items), per month are free. If you go over this limit, you could find your self paying a lot more than you expected.
let AWS = require("aws-sdk");
let cloudfront = new AWS.CloudFront({ region: "us-east-1" });
async function cloudfront__invalidation(distribution_id)
{
console.log("cloudfront__invalidation: " + distribution_id);
var params = {
DistributionId: distribution_id,
InvalidationBatch: {
CallerReference: new Date().getTime().toString(), /* required */
Paths: {
Quantity: 1,
Items: ['/*']
}
}
};
console.log(params);
return await cloudfront.createInvalidation(params).promise();
}