question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CodePipeline EcsDeployAction - unable to refer existing Fargate Service

See original GitHub issue

Hi, I am trying to create AWS CodePipeline to deploy my Fargate Services. I tried this using AWS Console in a CodePipeline which uses CodeBuild to build and dockerise application and CodePipeline Ecs Deploy action to depoly the service.

Now I am trying to do the same using AWS CDK (Typescript). But, it seems like it is not straight forward to refer my existing Fargate Service in EcsDeployAction.

EcsDeployAction wants ecs.BaseService which doesn’t have any static method to refer to an existing one. So, I have to use FargateService.fromFargateServiceArn. But the object it returns doesn’t have cluster instance set. I guess, due to this EcsDeployAction throws an error.

Is there any other way that I can get a reference to Ecs Service?

Reproduction Steps


const fargateService: ecs.FargateService = ecs.FargateService.fromFargateServiceArn(this, 'FargateService', props.fargateServiceArn);

  console.debug('Fargate service arn ${fargateService.serviceArn}, cluster: ${fargateService.cluster}');
  // LOG OUTPUT: Fargate service arn arn:aws:ecs:ap-southeast-2:xxxxx:service/users-api-service, cluster: undefined
  
  const ecsDeployAction = new codePipelineActions.EcsDeployAction({
            actionName: 'Deploy',
            input: buildOutput,
            service: fargateService
   });

Error Log

Cannot read property ‘clusterName’ of undefined Subprocess exited with error 1 Error: Subprocess exited with error 1 at ChildProcess.proc.on.code (/Users/***/.nvm/versions/node/v10.15.3/lib/node_modules/aws-cdk/lib/api/cxapp/exec.ts:115:23) at ChildProcess.emit (events.js:189:13) at ChildProcess.EventEmitter.emit (domain.js:441:20) at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)

Environment

  • **CLI Version :1.23.0
  • **Framework Version:1.23.0
  • **OS :macOS Catalina
  • **Language :TypeScript

Other


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nusspezcommented, Dec 28, 2021

UPDATE

works in cdk 2.3.0 with ecs.FargateService.from_fargate_service_attributes()

0reactions
nusspezcommented, Dec 28, 2021

Code

SERVICE_DEVELOP = ecs.FargateService.from_fargate_service_arn(self,"ServiceDevelop",fargate_service_arn=self.node.try_get_context("SERVICE_DEVELOP") )

Where SERVICE DEVELOP IS: arn:aws:ecs:region:aws_account_id:service/cluster-name/service-name

ERROR LOG

  • Cannot read property ‘clusterName’ of undefined

Environment

  • CDK 2.30
  • OS: macOs Catalina
  • Language :Python
Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS CDK EcsDeployAction update existing Fargate Service
I'm trying to import and update an existing (previously deployed) fargate service, like this: const pipeline = new codepipeline.Pipeline(this, ' ...
Read more >
aws-cdk/aws-codepipeline-actions module
If you want to clone the entire CodeCommit repository (only available for CodeBuild actions), ... FargateService; const pipeline = new codepipeline.
Read more >
Creating AWS CodePipeline Using AWS CDK - Towards AWS
In the EcsDeployAction construct, we need to pass the existing Fargate service details of the application. In this exam example, “driver-service” details.
Read more >
CI/CD With AWS ECS + CodePipeline + CodeDeploy + ...
DevOps: CI/CD With AWS ECS & AWS Codepipeline ‍ ➡️ Pushing codes➡️ GitHub or AWS CodeCommit ➡️ AWS CodePipeline ➡️ AWS...
Read more >
awslabs/aws-cdk - Gitter
Can't see context variables put in home dir version of cdk.json being read. ... I think that aws-cdk/aws-codepipeline-actions/lib/ecs/deploy-action.d.ts ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found