Skip to content

Instantly share code, notes, and snippets.

@lfreneda
Created January 2, 2019 15:57
Show Gist options
  • Save lfreneda/fbe4086f31275679d5b94026207b2c1d to your computer and use it in GitHub Desktop.
Save lfreneda/fbe4086f31275679d5b94026207b2c1d to your computer and use it in GitHub Desktop.
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