Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sample syntax for NodeJS CloudFront createInvalidation

There seems scant examples of NodeJS AWS SDK.

Does anyone have some sample code to show how paramters should be formed for the createInvalidation method?

like image 995
ljs.dev Avatar asked Mar 22 '23 13:03

ljs.dev


1 Answers

The documentation for the NodeJS implementation is available at docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudFront.html

You can create an Invalidation as mentioned below.

var cloudfront = new AWS.CloudFront();
var params = {
  DistributionId: 'STRING_VALUE', // required
  InvalidationBatch: { // required
    CallerReference: 'STRING_VALUE', // required
    Paths: { // required
      Quantity: 0, // required
      Items: [
        'STRING_VALUE',
        // ... more items ...
      ]
    }
  }
};
cloudfront.createInvalidation(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

The details of the options and response is available at http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudFront.html#createInvalidation-property

Hope this helps

like image 67
Abishek Avatar answered Apr 01 '23 19:04

Abishek