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.

[ecs] Circular dependency between EcsDeployAction and Fargate cluster

See original GitHub issue

When trying to create ECS cluster with image pipeline together, it can form an annoying dependency:

ECS initialization require the image, the image is not there until the pipeline is created and run for once, the pipeline has a EcsDeployAction depending on ECS as deployment target, eventually ECS will wait for the image until timeout:

        this.alBFargate = new ecs_patterns.ApplicationLoadBalancedFargateService(this, props.appName, {
            cluster: ecsCluster,
            taskImageOptions: {
                image: ecs.ContainerImage.fromEcrRepository(ecrRepo)
            }
        })

 // . . .

        const imgBuildPipeline = new pipeline.Pipeline(this, 'broadworks-auth-pipeline', {
            pipelineName: id + '-build-deploy-IMG',
            stages: [
                {
                    stageName: 'Build',
                    actions: [
                        new pipelineActions.CodeBuildAction({
                            actionName: 'Img_Build',
                            project: broadworksAuthBuild,// deploy to ecrRepo
                            input: sourceOutput,
                            outputs: [cdkBuildOutput],
                        }),
                    ],
                },
                {
                    stageName: 'Deploy',
                    actions: [
                        new pipelineActions.EcsDeployAction({
                            actionName: 'deployToECS',
                            service: this.alBFargate.service,
                            input: cdkBuildOutput
                        }),
                    ],
                }
            ],
        });

I would expect that the ECS cluster can finish initialization without any image.

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
flashflexprocommented, Nov 9, 2020

My workaround is to split the pipeline into two, the 1st build and push the image into ECR, the 2nd use triggered by the ECR with EcrSourceAction and deploy to ECS.

On Sat, Nov 7, 2020 at 11:47 AM Gary Y flashflexpro@gmail.com wrote:

Adam, thanks for sharing the code, I am not sure how to use it, could you be more specific please?

On Mon, Nov 2, 2020 at 4:31 PM Adam Ruka notifications@github.com wrote:

@flashflexpro https://github.com/flashflexpro if CDK Pipelines doesn’t fir your needs, I think what you want is this example: https://github.com/rix0rrr/cdk-ecs-demo

It’s for an older version of the CDK, but the general idea is the same.

The crucial class there is PipelineContainerImage https://github.com/rix0rrr/cdk-ecs-demo/blob/master/lib/pipeline-container-image.ts. It allows you to create an image that is “late bound”, that is, will only be created when the pipeline executes.

While we currently don’t have PipelineContainerImage in the main CDK repo, you can always copy&paste the class into your code, and we could also add it to the CDK if you think that it would be useful.

Let me know if this solves your problem!

Thanks, Adam

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws/aws-cdk/issues/11002#issuecomment-720736178, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVPH4KBM3EUFXMHO4JFH4DSN4QL3ANCNFSM4SZD7QUA .

0reactions
github-actions[bot]commented, Nov 14, 2020

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

aws-cdk/aws-ecs module - AWS Documentation
The following code imports an existing cluster using the ARN which can be used to import an Amazon ECS service either EC2 or...
Read more >
How do I resolve this circular reference in AWS ...
Sharing an update from the GitHub issue. The circular dependency has been broken by introducing a new resource: Cluster Capacity Provider ...
Read more >
Deploying updates to ECS Fargate services for every ECR ...
How to setup your AWS ECS Fargate service so it automatically gets re-deployed once its ECR image gets updated for continuous delivery with ......
Read more >
AWS re:Invent 2019: [REPEAT] Best practices for CI/CD using ...
AWS re:Invent 2019: [REPEAT] Best practices for CI/CD using AWS Fargate and Amazon ECS (CON333-R). 25K views 3 years ago AWS re:Invent 2019 ......
Read more >
@aws-cdk/aws-ecs | Yarn - Package Manager
Fast, reliable, and secure dependency management.
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