CodePipeline EcsDeployAction - unable to refer existing Fargate Service
See original GitHub issueHi,
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:
- Created 4 years ago
- Comments:13 (6 by maintainers)
Top GitHub Comments
UPDATE
works in cdk 2.3.0 with
ecs.FargateService.from_fargate_service_attributes()
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
Environment