Amazon web services AWS Cloudfront创建无效

Amazon web services AWS Cloudfront创建无效,amazon-web-services,amazon-cloudfront,Amazon Web Services,Amazon Cloudfront,我正在尝试使用以下代码执行CloudFront失效: var cloudfront = new AWS.CloudFront({s3BucketEndpoint: <String Bucketname>}); var params = { DistributionId: <String ID>, InvalidationBatch: { CallerReference: 'Cl

我正在尝试使用以下代码执行CloudFront失效:

var cloudfront = new AWS.CloudFront({s3BucketEndpoint: <String Bucketname>});
        var params = {
            DistributionId: <String ID>,
            InvalidationBatch: {
                CallerReference: 'Cloudfront Invalidation',
                Paths: {
                    Quantity: 1,
                    Items: [
                        '/*'
                    ]
                }
            }
        };
        cloudfront.createInvalidation(params, function(err, data){
            if (err) console.log(err, err.stack); // an error occurred
            else     console.log(data);           // successful response
        });
var cloudfront = new AWS.CloudFront();

var params = {
  DistributionId: <String ID>,
  InvalidationBatch: {
    CallerReference: Date.now().toString(),
    Paths: {
      Quantity: 1,
      Items: [
        '/*'
      ]
    }
  }
};

cloudfront.createInvalidation(params, function(err, data) {
  if (err) console.log(err, err.stack);
  else     console.log('Data: ' + JSON.stringify(data));
});
var cloudfront=new AWS.cloudfront({s3BucketEndpoint:});
变量参数={
DistributionId:,
失效批次:{
CallerReference:“Cloudfront无效”,
路径:{
数量:1,
项目:[
'/*'
]
}
}
};
createInvalization(参数、函数(错误、数据){
if(err)console.log(err,err.stack);//发生错误
else console.log(数据);//响应成功
});

但是,我在我的
createInvalidation
函数中没有从err或data得到响应。AWS SDK的文档说明您应该得到肯定/否定的响应,但不会返回任何内容,也不会执行任何无效操作。

可能是您的
调用方引用,在(docs.AWS.amazon.com)中,它表示需要唯一标识无效请求

我无意中发现了这个问题,试图做与您所做的相同的事情,并且我能够让
createInvalidation
使用以下代码:

var cloudfront = new AWS.CloudFront({s3BucketEndpoint: <String Bucketname>});
        var params = {
            DistributionId: <String ID>,
            InvalidationBatch: {
                CallerReference: 'Cloudfront Invalidation',
                Paths: {
                    Quantity: 1,
                    Items: [
                        '/*'
                    ]
                }
            }
        };
        cloudfront.createInvalidation(params, function(err, data){
            if (err) console.log(err, err.stack); // an error occurred
            else     console.log(data);           // successful response
        });
var cloudfront = new AWS.CloudFront();

var params = {
  DistributionId: <String ID>,
  InvalidationBatch: {
    CallerReference: Date.now().toString(),
    Paths: {
      Quantity: 1,
      Items: [
        '/*'
      ]
    }
  }
};

cloudfront.createInvalidation(params, function(err, data) {
  if (err) console.log(err, err.stack);
  else     console.log('Data: ' + JSON.stringify(data));
});
参数“callerreference”必须是唯一的,它允许awss3避免您提交相同的请求,并且可以用作密钥时间戳