Created
January 2, 2019 15:57
-
-
Save lfreneda/fbe4086f31275679d5b94026207b2c1d to your computer and use it in GitHub Desktop.
Create Cloudfront Invalidation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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