Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodePipeline EcsDeployAction - unable to refer existing Fargate Service #6178

Closed
jkdilunika opened this issue Feb 9, 2020 · 13 comments
Closed
Assignees
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline effort/small Small work item – less than a day of effort feature-request A feature should be added or improved.

Comments

@jkdilunika
Copy link

jkdilunika commented Feb 9, 2020

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

@jkdilunika jkdilunika added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 9, 2020
@skinny85
Copy link
Contributor

Thanks for the issue @jkdilunika . See #5939 (comment) for an explanation :).

@skinny85 skinny85 self-assigned this Feb 10, 2020
@skinny85 skinny85 added feature-request A feature should be added or improved. gap @aws-cdk/aws-codepipeline Related to AWS CodePipeline effort/small Small work item – less than a day of effort and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 10, 2020
@jkdilunika
Copy link
Author

@skinny85 thanks for the response. As I understand, the fix is still going on. Hope I could get it CDK do the next release.

@skinny85
Copy link
Contributor

@jkdilunika yes, the fix is happening in #6203. Feel free to track that PR for progress. We do weekly releases, so it shouldn't be too long before this lands :).

@jkdilunika
Copy link
Author

Thanks @skinny85. I will keep eye on the pull request.

@jkdilunika
Copy link
Author

Hi @skinny85, it seems the fix has not gone even to 1.25.0 release. Can I get any idea which release this merged is planned?

/Kasun

@skinny85
Copy link
Contributor

@jkdilunika the PR has not been merged yet, so it would be pretty surprising if it made it into the release :) I've pinged the owner of the PR about it.

@jkdilunika
Copy link
Author

Thanks @skinny85 for the follow up. We have few tickets blocked at the moment due to this issue. I have created the pipelines using console for the moment. I selected CDK as the IaC tool for this project over terraform (which we normally use) since CDK is very impressive and it is the tool we were waiting so long. However, now I am getting some pressure from the team since this has left some unfinished work. Hope this will be merged soon :)

@skinny85
Copy link
Contributor

There is a new PR adding this: #6412 , so hopefully this happens soon :).

@SomayaB SomayaB removed the gap label Feb 25, 2020
@skinny85
Copy link
Contributor

Done in #6412, released in CDK version 1.28.0.

@nusspez
Copy link

nusspez commented Dec 28, 2021

hello i get the same error in the version 2.3.0

@skinny85
Copy link
Contributor

@nusspez can you show your CDK code, the command that you execute, and the exact error that you get?

@nusspez
Copy link

nusspez commented 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

@nusspez
Copy link

nusspez commented Dec 28, 2021

UPDATE

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline effort/small Small work item – less than a day of effort feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

4 participants