Configures an AWS App Mesh virtual node using AWS Cloud Map for service discovery.

Terraform Template

resource "aws_appmesh_virtual_node" "serviceb1" {
  mesh_name = "aws_appmesh_mesh.simple.id"
  name = "serviceBv1"

  spec {

    backend {

      virtual_service {
        virtual_service_name = "servicea.simpleapp.local"
      }
    }

    listener {

      port_mapping {
        port = 8080
        protocol = "http"
      }
    }

    service_discovery {

      aws_cloud_map {

        attributes = {
          stack = "blue"
        }
        namespace_name = aws_service_discovery_http_namespace.example.name
        service_name = "serviceb1"
      }
    }
  }
}

resource "aws_service_discovery_http_namespace" "example" {
  name = "example-ns"
}