Create the virtual service

Please note that this workshop has been archived and is not actively maintained. On September 30, 2026, AWS will discontinue support for AWS App Mesh. For more information, visit this blog post.

  • Like you did previously, start by creating a virtual node.
# Define variables #
EXT_LOAD_BALANCER=$(jq < cfn-output.json -r '.ExternalLoadBalancerDNS');
SPEC=$(cat <<-EOF
  { 
    "serviceDiscovery": {
      "dns": { 
        "hostname": "$EXT_LOAD_BALANCER"
      }
    },
    "backends": [
      {
        "virtualService": {
          "virtualServiceName": "crystal.appmeshworkshop.hosted.local"
        }
      },
      {
        "virtualService": {
          "virtualServiceName": "nodejs.appmeshworkshop.hosted.local"
        }
      }
    ],      
    "logging": {
      "accessLog": {
        "file": {
          "path": "/dev/stdout"
        }
      }
    },      
    "listeners": [
      {
        "healthCheck": {
          "healthyThreshold": 3,
          "intervalMillis": 10000,
          "path": "/health",
          "port": 3000,
          "protocol": "http",
          "timeoutMillis": 5000,
          "unhealthyThreshold": 3
        },
        "portMapping": { "port": 3000, "protocol": "http" }
      }
    ]
  }
EOF
); \
# Create app mesh virtual node #
aws appmesh create-virtual-node \
  --mesh-name appmesh-workshop \
  --virtual-node-name frontend \
  --spec "$SPEC"
  • Create the virtual service.
# Define variables #
SPEC=$(cat <<-EOF
  { 
    "provider": {
      "virtualNode": { 
        "virtualNodeName": "frontend"
      }
    }
  }
EOF
); \
# Create app mesh virtual service #
aws appmesh create-virtual-service \
  --mesh-name appmesh-workshop \
  --virtual-service-name frontend.appmeshworkshop.hosted.local \
  --spec "$SPEC"