(AppMesh): How to create two virtual service/node with bidirectional backend without circular dependencies
See original GitHub issueWhat is the problem?
I am currently setting up a CDK stack using ECS and AppMesh to create a micro service environment. In this micro service environment, every service should be able to talk to every other service. What I am trying to do is create a VirtualNode & Service per micro service and then call addBackend
for each of these services and add all other services. However, this creates a cyclic dependencies for all services.
I haven’t found a way yet to create this bidirectional backend setup without creating cyclic dependencies inside the CDK.
Reproduction Steps
// Inside 1 stack
const node1 = new appmesh.VirtualNode(stack1, 'node1', {
virtualNodeName: 'Node1',
mesh: props.mesh,
listeners: [appmesh.VirtualNodeListener.grpc({
port: 8080,
healthCheck: appmesh.HealthCheck.grpc({
healthyThreshold: 2,
interval: cdk.Duration.seconds(5),
timeout: cdk.Duration.seconds(2),
unhealthyThreshold: 3,
}),
})],
accessLog: appmesh.AccessLog.fromFilePath('/dev/stdout'),
});
const service1 = new appmesh.VirtualService(stack2, 'Service1', {
virtualServiceName: 'Service1',
virtualServiceProvider: appmesh.VirtualServiceProvider.virtualNode(node1),
});
// Inside stack 2
const node2 = new appmesh.VirtualNode(this, 'node2', {
virtualNodeName: 'Node2',
mesh: props.mesh,
listeners: [appmesh.VirtualNodeListener.grpc({
port: 8080,
healthCheck: appmesh.HealthCheck.grpc({
healthyThreshold: 2,
interval: cdk.Duration.seconds(5),
timeout: cdk.Duration.seconds(2),
unhealthyThreshold: 3,
}),
})],
accessLog: appmesh.AccessLog.fromFilePath('/dev/stdout'),
});
const service2 = new appmesh.VirtualService(this, 'Service2', {
virtualServiceName: 'Service2',
virtualServiceProvider: appmesh.VirtualServiceProvider.virtualNode(node2),
});
// Added afterwards via Aspect
node1.addBackend(service2);
node2.addBackend(service1)
What did you expect to happen?
I expected there to be a way to create a bidirectional connection between backend services.
What actually happened?
It always creates a circular dependency and I can’t see any escape hatch
CDK CLI Version
1.130.0
Framework Version
No response
Node.js Version
9.0.0
OS
MacOS BigSur
Language
Typescript
Language Version
No response
Other information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
A new version of
@aws-cdk/aws-appmesh
has been published to NPM. Versions >= 1.139.0 contain the fix.Thanks for the info. We are able to reproduce the issue and are now figuring out how to fix this or provide a workaround.