Home > Software engineering >  AWS CDK EcsDeployAction update existing Fargate Service
AWS CDK EcsDeployAction update existing Fargate Service

Time:11-25

I'm deployng Fargate services through AWS CDK with ease.

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

I'm trying to import and update an existing (previously deployed) fargate service, like this:

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:

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

Any idea?

CodePudding user response:

There's a type mismatch. EcsDeployActionProps expects the service prop to be of the type IBaseService. But it's getting an incompatible IFargateService type from fromFargateServiceArn.

Luckily, the related static fromFargateServiceAttributes(scope, id, attrs) returns the compatible type IBaseService you are looking for.

  • Related