本文整理匯總了TypeScript中aws-sdk.ECS.createService方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ECS.createService方法的具體用法?TypeScript ECS.createService怎麽用?TypeScript ECS.createService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類aws-sdk.ECS
的用法示例。
在下文中一共展示了ECS.createService方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: _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();
}
}