本文整理汇总了TypeScript中aws-sdk.CloudFront类的典型用法代码示例。如果您正苦于以下问题:TypeScript CloudFront类的具体用法?TypeScript CloudFront怎么用?TypeScript CloudFront使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CloudFront类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Promise
return new Promise(function(resolve, reject) {
console.log("CloudFront Invalidation Started");
cloudfront.createInvalidation(
{
DistributionId: cloudfrontProductionId,
InvalidationBatch: {
CallerReference: `CI-Invalidation-${Date.now().toString()}`,
Paths: {
Quantity: 1,
Items: ["/*"],
},
},
},
function(err: Error, data: any) {
if (err) {
reject(err);
} else {
resolve(data);
}
},
);
}).then(function(invalidation: any) {
示例2: _createCloudFront
private async _createCloudFront() {
if (!this.resources.cloudfront) {
return;
}
let cloudfront;
let params: any = {
MaxItems: "1000"
};
this._cloudfront = new (this._getAWS(this.resources)).CloudFront({
apiVersion: "2018-06-18"
});
await this._createCertificate(this.bucket);
// TODO Handle paginations
let res: CloudFront.ListDistributionsResult = await this._cloudfront
.listDistributions(params)
.promise();
for (let i in res.DistributionList.Items) {
// Search for current cloudfront
if (
res.DistributionList.Items[i].DefaultCacheBehavior.TargetOriginId ===
"S3-" + this.bucket
) {
cloudfront = res.DistributionList.Items[i];
if (cloudfront.Status === "InProgress") {
console.log(
"CloudFront distribution",
cloudfront.Id,
"is in progress, skipping"
);
return Promise.resolve();
}
if (!cloudfront.Enabled) {
console.log(
"CloudFront distribution",
cloudfront.Id,
"is in disabled, skipping"
);
return Promise.resolve();
}
let distributionConfig = await this._cloudfront
.getDistributionConfig({
Id: cloudfront.Id
})
.promise();
if (this._needCloudFrontUpdate(distributionConfig)) {
console.log("Update CloudFront distribution", cloudfront.Id);
return this._cloudfront
.updateDistribution(this._getCloudFrontConfig())
.promise();
}
console.log("Invalidate CloudFront distribution", cloudfront.Id);
params = {
DistributionId: cloudfront.Id,
InvalidationBatch: {
CallerReference: "Webda-deployment",
Paths: {
Quantity: 1,
Items: ["/*"]
}
}
};
await this._cloudfront.createInvalidation(params).promise();
}
}
if (!cloudfront) {
cloudfront = await this._cloudfront
.createDistribution(this._getCloudFrontConfig())
.promise();
console.log(
"Create Cloudfront distribution",
cloudfront.Distribution.Id,
": this take some times on the AWS side before being effective"
);
}
// Ensure Route53 record set
await this._createDNSEntry(this.bucket, "CNAME", cloudfront.DomainName);
}
示例3: setInterval
var handle = setInterval(function() {
cloudfront.getInvalidation(
{
Id: invalidation.Id,
DistributionId: cloudfrontProductionId,
},
function(_err: Error, invalidation: any) {
if (invalidation.Status == "Completed") {
console.log("Done");
clearInterval(handle);
resolve();
} else {
console.log("*");
}
},
);
}, 1000);