简体   繁体   English

AWS CDK EcsDeployAction 更新现有 Fargate 服务

[英]AWS CDK EcsDeployAction update existing Fargate Service

I'm deployng Fargate services through AWS CDK with ease.我正在通过 AWS CDK 轻松部署 Fargate 服务。

Now I need to update a service, for instance a task image.现在我需要更新一个服务,例如一个任务图像。
I 'm trying to accomplish this by using @aws-cdk/aws-codepipeline and the action EcsDeployAction我正在尝试通过使用 @aws-cdk/aws-codepipeline 和操作 EcsDeployAction 来完成此操作

I'm trying to import and update an existing (previously deployed) fargate service, like this:我正在尝试导入和更新现有(以前部署的)fargate 服务,如下所示:

const pipeline = new codepipeline.Pipeline(this, 'MyPipeline')

// import an existing fargate service
const fargateService = ecs.FargateService.fromFargateServiceArn(
  this,
  "FargateService",
  "MyFargateServiceARN"
);

// Deploy a new version according to what 
const sourceStage = this.pipeline.addStage({
  stageName: 'Deploy',
  actions: [
    new codepipeline_actions.EcsDeployAction({
      actionName: "ECS-Service",
      service: fargateService,       <--- here the typescript error
      input: ...
    })
  ]
})

But it does not seem correct because I get a typescript error:但这似乎不正确,因为我收到 typescript 错误:

Property 'cluster' is missing in type 'IFargateService' but required in type 'IBaseService'

Any idea?任何想法?

There's a type mismatch.类型不匹配。 EcsDeployActionProps expects the service prop to be of the type IBaseService . EcsDeployActionProps 期望服务属性为IBaseService类型。 But it's getting an incompatible IFargateService type from fromFargateServiceArn .但它从fromFargateServiceArn获得了不兼容的IFargateService类型。

Luckily, the related static fromFargateServiceAttributes(scope, id, attrs) returns the compatible type IBaseService you are looking for.幸运的是,相关的static fromFargateServiceAttributes(scope, id, attrs)返回您正在寻找的兼容类型IBaseService

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM