Skip to content

(AppMesh): How to create two virtual service/node with bidirectional backend without circular dependencies #17322

@FranzBusch

Description

@FranzBusch

What 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

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-appmeshRelated to AWS App MeshbugThis issue is a bug.effort/smallSmall work item – less than a day of effortneeds-reproductionThis issue needs reproduction.p1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions