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


TypeScript aws-sdk.ECS類代碼示例

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


在下文中一共展示了ECS類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: _registerTaskDefinition

 async _registerTaskDefinition(taskDefinition) {
   taskDefinition = this._replaceForAWS(taskDefinition);
   let params: ECS.RegisterTaskDefinitionRequest = {
     containerDefinitions: this._getWorkersDefinition(),
     family: taskDefinition,
     taskRoleArn: this._taskRole,
     volumes: [],
     requiresCompatibilities: ["FARGATE"],
     networkMode: "awsvpc",
     cpu: this.resources.taskCpu,
     memory: this.resources.taskMemory,
     executionRoleArn: this._taskRole
   };
   let res = await this._ecs.registerTaskDefinition(params).promise();
   this._taskDefinitionArn = res.taskDefinition.taskDefinitionArn;
 }
開發者ID:loopingz,項目名稱:webda-shell,代碼行數:16,代碼來源:fargate.ts

示例2:

 _createCluster() {
   return this._ecs
     .listClusters()
     .promise()
     .then(res => {
       for (let i in res.clusterArns) {
         if (res.clusterArns[i].endsWith(this.resources.clusterName)) {
           return this._ecs
             .describeClusters({
               clusters: [res.clusterArns[i]]
             })
             .promise()
             .then(res => {
               this._cluster = res.clusters[0];
             });
         }
       }
       if (!this._cluster) {
         return this._ecs
           .createCluster({
             clusterName: this.resources.clusterName
           })
           .promise()
           .then(res => {
             this._cluster = res.cluster;
           });
       }
     });
 }
開發者ID:loopingz,項目名稱:webda-shell,代碼行數:29,代碼來源:fargate.ts

示例3: _createService

 private async _createService() {
   let res = await this._ecs
     .listServices({
       cluster: this._cluster.clusterName,
       launchType: "FARGATE"
     })
     .promise();
   let serviceName = this._replaceForAWS(this.resources.serviceName);
   for (let i in res.serviceArns) {
     if (res.serviceArns[i].split("/")[1] === serviceName) {
       this._service = res.serviceArns[i];
       break;
     }
   }
   let serviceDefinition: any = {
     desiredCount: this.resources.tasksNumber,
     taskDefinition: this._taskDefinitionArn,
     cluster: this._cluster.clusterName,
     serviceName: serviceName,
     launchType: "FARGATE",
     networkConfiguration: {
       awsvpcConfiguration: {
         subnets: this._subnets,
         assignPublicIp: this.resources.publicIp,
         securityGroups: []
       }
     }
   };
   if (this.resources.securityGroup) {
     serviceDefinition.networkConfiguration.awsvpcConfiguration.securityGroups.push(
       this.resources.securityGroup
     );
   }
   if (!this._service) {
     // Create the service
     return this._ecs.createService(serviceDefinition).promise();
   } else {
     serviceDefinition.service = serviceDefinition.serviceName;
     delete serviceDefinition.serviceName;
     delete serviceDefinition.launchType;
     // Update the service
     return this._ecs.updateService(serviceDefinition).promise();
   }
 }
開發者ID:loopingz,項目名稱:webda-shell,代碼行數:44,代碼來源:fargate.ts


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