当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript CloudFront.listDistributions方法代码示例

本文整理汇总了TypeScript中aws-sdk.CloudFront.listDistributions方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CloudFront.listDistributions方法的具体用法?TypeScript CloudFront.listDistributions怎么用?TypeScript CloudFront.listDistributions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aws-sdk.CloudFront的用法示例。


在下文中一共展示了CloudFront.listDistributions方法的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.listDistributions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。