Cyclic Reference when trying to make a CodeBuild project to EKS
See original GitHub issueI’m trying to make two separate stack,
- creates a bunch of CI/CD stuff, which includes a build stage to deploy to EKS cluster.
- 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
- 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'
]
}
}})
});
- 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:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I know this from the error message. Let me reformat it a little:
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…?
Ah I got this. Thanks for your explanation! closing this issue. 😃