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.

Cyclic Reference when trying to make a CodeBuild project to EKS

See original GitHub issue

I’m trying to make two separate stack,

  1. creates a bunch of CI/CD stuff, which includes a build stage to deploy to EKS cluster.
  2. creates a EKS cluster and configures it.

When I tried to deploy the stacks, I get the following error. I guess it’s somewhat related to #5760 , #3300?

Reproduction Steps

  1. CicdForAppStack
constructor(scope: cdk.Construct, id: string, props: CommonProps) {
    super(scope, id, props);
...
const deployToMainEKScluster = new codebuild.PipelineProject(this, 'deploy-to-main', {
            environment: {
                buildImage: codebuild.LinuxBuildImage.fromAsset(this, 'custom-image', {
                    directory: './buildimage'
                })
            },
            environmentVariables: { 
                'CLUSTER_NAME': {
                    value: `${props.cluster.clusterName}`
                  },
                'ECR_REPO_URI': {
                value: `${ecrForHelloPy.repositoryUri}`
              } 
            },
            buildSpec: codebuild.BuildSpec.fromObject({
                version: "0.2",
                phases: {
                  install: {
                    commands: [
                      'env',
                      'export TAG=${CODEBUILD_RESOLVED_SOURCE_VERSION}',
                      '/usr/local/bin/entrypoint.sh'                    ]
                  },
                  build: {
                    commands: [
                        `sed -i 's@CONTAINER_IMAGE@'"$ECR_REPO_URI:$TAG"'@' hello-py.yaml`,
                        'kubectl apply -f hello-py.yaml'
                    ]
                  }
                }})
        });
  1. ClusterStack I think it’s quite ordinary stack for EKS, so I just add the link to the code, instead of pasting it over. https://github.com/yjw113080/aws-cdk-eks-multi-region/blob/master/lib/cluster-stack.ts

Error Log

/Users/jiwony/multi-cluster-ts/node_modules/@aws-cdk/core/lib/stack.ts:659
        throw new Error(`'${target.node.path}' depends on '${this.node.path}' (${cycle.join(', ')}). Adding this dependency (${reason}) would create a cyclic reference.`);
              ^
Error: 'CicdForAppStack' depends on 'v2-ClusterStack-ap-northeast-1' (CicdForAppStack -> v2-ClusterStack-ap-northeast-1/demogo-cluster/Resource/Resource/Default.Ref). Adding this dependency (v2-ClusterStack-ap-northeast-1 -> CicdForAppStack/deploy-to-main/Role/Resource.Arn) would create a cyclic reference.
    at ClusterStack._addAssemblyDependency (/Users/jiwony/multi-cluster-ts/node_modules/@aws-cdk/core/lib/stack.ts:659:15)
    at Object.addDependency (/Users/jiwony/multi-cluster-ts/node_modules/@aws-cdk/core/lib/deps.ts:44:20)
    at ClusterStack.addDependency (/Users/jiwony/multi-cluster-ts/node_modules/@aws-cdk/core/lib/stack.ts:364:5)
    at CicdForAppStack.prepareCrossReference (/Users/jiwony/multi-cluster-ts/node_modules/@aws-cdk/core/lib/stack.ts:926:24)
    at ClusterStack.prepare (/Users/jiwony/multi-cluster-ts/node_modules/@aws-cdk/core/lib/stack.ts:769:37)
    at ClusterStack.onPrepare (/Users/jiwony/multi-cluster-ts/node_modules/@aws-cdk/core/lib/construct-compat.ts:105:10)
    at Node.prepare (/Users/jiwony/multi-cluster-ts/node_modules/constructs/lib/construct.ts:441:28)
    at Node.synthesize (/Users/jiwony/multi-cluster-ts/node_modules/constructs/lib/construct.ts:399:10)
    at Function.synth (/Users/jiwony/multi-cluster-ts/node_modules/@aws-cdk/core/lib/construct-compat.ts:225:22)
    at App.synth (/Users/jiwony/multi-cluster-ts/node_modules/@aws-cdk/core/lib/app.ts:141:36)

Environment

  • **CLI Version 😗*1.30.0 (build 4f54ff7
  • **Framework Version:**1.30.0
  • **OS 😗*OSX Mojave
  • **Language 😗*Typescript

Other


This is 🐛 Bug Report

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
skinny85commented, Apr 1, 2020

I think I know this from the error message. Let me reformat it a little:

Error: 'CicdForAppStack' depends on 'v2-ClusterStack-ap-northeast-1':

CicdForAppStack -> v2-ClusterStack-ap-northeast-1/demogo-cluster/Resource/Resource/Default.Ref).

Adding this dependency: 

v2-ClusterStack-ap-northeast-1 -> CicdForAppStack/deploy-to-main/Role/Resource.Arn

would create a cyclic reference

I assume the CicdForAppStack/deploy-to-main/Role/Resource.Arn is because you need to add the role to the resource policy of the ECR repo to allow it access. Because of that, you can’t also have a dynamic reference to the Cluster - you have to hard-code it to avoid the dependency.

Does that make sense…?

0reactions
yjw113080commented, Apr 2, 2020

Ah I got this. Thanks for your explanation! closing this issue. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve CodeBuild Unauthorized errors when connecting to ...
I'm trying to connect to an Amazon Elastic Kubernetes Service (Amazon EKS) cluster from AWS CodeBuild using the CodeBuild service role.
Read more >
awslabs/aws-cdk - Gitter
I have an RDS DB instance created in one construct of my CDK stack. I want to reorganize the stack and create the...
Read more >
Executing kubectl on AWS CodeBuild connecting Amazon ...
I just had to create another role with same Trusted Relationship and policy as the original one. BUT it worked.
Read more >
Continuous Deployment to Kubernetes (EKS) using AWS ...
Without further ado, let me tell you what I'm trying to do. ... Build Provider: AWS CodeBuild; Click Create Project; Give Project Name...
Read more >
CI/CD pipelines explained: Everything you need to know
As one build is pushed to deployment, the next build undergoes testing, ... especially when combined in the cyclical process known as CI/CD....
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