Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create Cloudfront Invalidation
const aws = require('aws-sdk')
const moment = require('moment')
const callerReference = moment().format('YYYYMMDDHHmmss')
aws.config.update({
credentials: {
accessKeyId: 'shhhhhhhhhhh',
secretAccessKey: 'shhhhhhhhhhhh'
}
})
const cloudfront = new aws.CloudFront()
cloudfront.createInvalidation({
DistributionId: '',
InvalidationBatch: {
CallerReference: callerReference,
Paths: {
Quantity: 4,
Items: [
'/index.html',
'/styles/*',
'/scripts/*',
'/app/*'
]
}
}
}, function(err, invalidation) {
console.log('err', err)
console.log(JSON.stringify(invalidation, null, 2))
process.exit(err ? 1 : 0)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.