【问题标题】:AWS CDK EcsDeployAction update existing Fargate ServiceAWS CDK EcsDeployAction 更新现有 Fargate 服务
【发布时间】:2022-01-02 05:35:48
【问题描述】:

我正在通过 AWS CDK 轻松部署 Fargate 服务。

现在我需要更新一个服务,例如一个任务图像。
我正在尝试通过使用 @aws-cdk/aws-codepipeline 和操作 EcsDeployAction

来完成此操作

我正在尝试导入和更新现有(以前部署的)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: ...
    })
  ]
})

但这似乎不正确,因为我收到了打字稿错误:

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

有什么想法吗?

【问题讨论】:

    标签: typescript aws-cdk aws-codepipeline aws-fargate


    【解决方案1】:

    类型不匹配。 EcsDeployActionProps expects the service propIBaseService 类型。但是它从fromFargateServiceArn 得到了不兼容的IFargateService 类型。

    幸运的是,相关的static fromFargateServiceAttributes(scope, id, attrs) 返回了您正在寻找的兼容类型IBaseService

    【讨论】:

    • 谢谢。我会尝试这种方法,肯定会奏效。
    猜你喜欢
    • 2021-10-18
    • 1970-01-01
    • 2020-11-05
    • 2023-03-17
    • 2022-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-22
    相关资源
    最近更新 更多