當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript CloudFront.getDistributionConfig方法代碼示例

本文整理匯總了TypeScript中aws-sdk.CloudFront.getDistributionConfig方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CloudFront.getDistributionConfig方法的具體用法?TypeScript CloudFront.getDistributionConfig怎麽用?TypeScript CloudFront.getDistributionConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在aws-sdk.CloudFront的用法示例。


在下文中一共展示了CloudFront.getDistributionConfig方法的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);
 }
開發者ID:loopingz,項目名稱:webda-shell,代碼行數:77,代碼來源:s3.ts


注:本文中的aws-sdk.CloudFront.getDistributionConfig方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。