Sample syntax for NodeJS CloudFront createInvalidation

amazon-cloudfront, node.js

Solution

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

Problem

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?

Original source