CodePipeline - ECS CodeDeploy Action cross-account
:question: General Issue
The Question
I'm trying to get CodePipeline setup to deploy to ECS in another account. I based my setup on this blog post that describes something very similar using Lambda instead of ECS.
I have a Tools account which contains the pipeline and the ECR repository for the container I want to deploy. I also have a Dev account which contains the ECS cluster, service, and task definition as well as the CodeDeploy application and deployment group.
I noticed that the CloudFormation actions have an account property and when I tested that out it automatically setup a stack in the Dev account with permissions for the Tools account to execute CloudFormation changes in the Dev account. Super easy. I don't see anything like that for the EcsDeployAction so I'm looking for guidance on how to get EcsDeployAction to work in a cross-account scenario.
Environment
- CDK CLI Version: 1.18.0 (build bc924bc)
- Module Version: @aws-cdk/*@1.18.0
- OS: OSX
- Language: TypeScript
Other information
While searching for a solution I came across this issue which seems related but "ECS deploy Action" is suspiciously unchecked haha.
Hey @tleef ,
the ECS deploy action doesn't have an account property, because the account is taken from the stack the Deployment Group belongs to. Try just passing it directly from the other stack to the CodePipeline action - it should Just Work™.
Thanks, Adam
Did it actually work? ^^
Like a charm The CDK is amazing but its a lot to learn. Thanks for all of your hard work.
That's awesome 😃 If there's anything we can help to make it easier to learn, let us know.
Hi @skinny85. Trying to use CodeDeployEcsDeployAction to trigger a cross-account deployment. Not sure how to leverage the EcsDeploymentGroup.fromEcsDeploymentGroupAttributes to reference the environment of the target account. Would you be able to provide any guidance in this case?
I tried executing the EcsDeploymentGroup.fromEcsDeploymentGroupAttributes from inside a stack that is deployed in the target account and passed the reference to the action but, in the end, CodeDeploy still tries to invoke dg inside the pipeline account.
@ldecaro would you mind opening us a new issue about this? I suspect I know what the problem is, and I think we'll need a PR to fix it. A new issue will make it easier to track.
Hi @skinny85. I created the issue, thanks!
Hi @tleef,
would you mind sharing your solution code plz? I'm facing the same problem and I cannot get it to work. Thanks in advance,
@jacwak it should work by passing the CodeDeploy Deployment Group object from the other Stack directly to your CodePipeline construct.
If you show some code that you have, and specify the error you're facing, we can provide more guidance.