本文整理汇总了TypeScript中aws-sdk.CloudFront.updateDistribution方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CloudFront.updateDistribution方法的具体用法?TypeScript CloudFront.updateDistribution怎么用?TypeScript CloudFront.updateDistribution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aws-sdk.CloudFront
的用法示例。
在下文中一共展示了CloudFront.updateDistribution方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _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);
}