[appmesh] VirtualNode in separate stack from Mesh creates circular dependency
See original GitHub issueAdding a VirtualNode to a Mesh (where the Mesh is in one stack and the VirtualNode is in another) creates an circular reference, but shouldn’t.
Reproduction Steps
Sample code available at buzzsurfr/appmesh-cross-stack-bug
Sample code in master branch works, but uncommenting the following lines…
…then run:
npm run build
cdk ls
What did you expect to happen?
This shouldn’t be a circular reference and should work.
What actually happened?
/Users/username/Sandbox/cdk/appmesh-cross-stack-bug/node_modules/@aws-cdk/core/lib/stack.ts:688
throw new Error(`'${target.node.path}' depends on '${this.node.path}' (${cycle.join(', ')}). Adding this dependency (${reason}) would create a cyclic reference.`);
^
Error: 'InfrastructureStack' depends on 'MeshedServiceStack' (InfrastructureStack -> MeshedServiceStack/service/CloudmapService/Resource.Name). Adding this dependency (MeshedServiceStack -> InfrastructureStack/Mesh/Resource.MeshName) would create a cyclic reference.
at MeshedServiceStack._addAssemblyDependency (/Users/username/Sandbox/cdk/appmesh-cross-stack-bug/node_modules/@aws-cdk/core/lib/stack.ts:688:13)
at Object.addDependency (/Users/username/Sandbox/cdk/appmesh-cross-stack-bug/node_modules/@aws-cdk/core/lib/deps.ts:52:20)
at MeshedServiceStack.addDependency (/Users/username/Sandbox/cdk/appmesh-cross-stack-bug/node_modules/@aws-cdk/core/lib/stack.ts:445:5)
at resolveValue (/Users/username/Sandbox/cdk/appmesh-cross-stack-bug/node_modules/@aws-cdk/core/lib/private/refs.ts:101:12)
at Object.resolveReferences (/Users/username/Sandbox/cdk/appmesh-cross-stack-bug/node_modules/@aws-cdk/core/lib/private/refs.ts:31:24)
at Object.prepareApp (/Users/username/Sandbox/cdk/appmesh-cross-stack-bug/node_modules/@aws-cdk/core/lib/private/prepare-app.ts:36:5)
at Object.synthesize (/Users/username/Sandbox/cdk/appmesh-cross-stack-bug/node_modules/@aws-cdk/core/lib/private/synthesis.ts:21:3)
at App.synth (/Users/username/Sandbox/cdk/appmesh-cross-stack-bug/node_modules/@aws-cdk/core/lib/stage.ts:175:23)
at process.<anonymous> (/Users/username/Sandbox/cdk/appmesh-cross-stack-bug/node_modules/@aws-cdk/core/lib/app.ts:112:45)
at Object.onceWrapper (events.js:422:26)
Subprocess exited with error 1
Environment
- CLI Version : 1.61.1 (build 347918f)
- Framework Version: ^1.61.1
- Node.js Version: v13.12.0
- OS : macOS Catalina 10.15.6
- Language (Version): TypeScript (3.9.7)
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
aws-cdk/aws-appmesh module - AWS Documentation
AWS App Mesh is a service mesh based on the Envoy proxy that makes it easy ... the same stack as the mesh...
Read more >awsappmesh - Go Packages
AWS App Mesh is a service mesh based on the Envoy proxy that makes it easy to ... across stacks (or nested stack)...
Read more >Introduction to AWS App Mesh - AWS Online Tech Talks
To learn more, please visit: https://aws.amazon.com/app-meshAWS App Mesh is a service mesh that makes it easy to monitor and control ...
Read more >Weird circular dependency issue when updating a CDK ec2 ...
I am using CDK pipelines here to deploy a very simple stack. The stack consists of 2 sub-stacks: an Aurora cluster and an...
Read more >AWS::AppMesh::VirtualNode - Amazon CloudFormation
Creates a virtual node within a service mesh. A virtual node acts as a logical pointer to a particular task group, such as...
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 Free
Top 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
This is really great point and has been suggested by @dfezzie as well.
Conclusion:
.add()
method and the constructor to create a resource.I think I agree with your conclusions @Seiya6329. Looks like I was worried about that
new VirtualNode(...
case for nothing 🙂.This looks to be just a matter of various references between CDK constructs causing dependencies between Stacks. I don’t think there’s anything unusual here for AppMesh.
For the problem posted originally in the issue, it’s just a matter of changing from:
to:
to solve the cycle.
I think the only possible action from this might be adding some clarification to the documentation of the various
add*()
methods in AppMesh that they create a resource in the same Stack as the object they are called on (the Mesh in case ofVirtualNode
), which might be different than the current Stack. But I think that 's as far as any code changes are needed here.