

文档 AWS SDK 示例 GitHub 存储库中还有更多 [S AWS DK 示例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用 App Mesh 示例 AWS CLI
<a name="cli_2_app-mesh_code_examples"></a>

以下代码示例向您展示了如何使用 AWS Command Line Interface 与 App Mesh 配合使用来执行操作和实现常见场景。

*操作*是大型程序的代码摘录，必须在上下文中运行。您可以通过操作了解如何调用单个服务函数，还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接，您可以从中找到有关如何在上下文中设置和运行代码的说明。

**Topics**
+ [操作](#actions)

## 操作
<a name="actions"></a>

### `create-mesh`
<a name="app-mesh_CreateMesh_cli_2_topic"></a>

以下代码示例演示了如何使用 `create-mesh`。

**AWS CLI**  
**示例 1：创建新的服务网格**  
以下 `create-mesh` 示例创建一个服务网格。  

```
aws appmesh create-mesh \
    --mesh-name app1
```
输出：  

```
{
    "mesh":{
        "meshName":"app1",
        "metadata":{
            "arn":"arn:aws:appmesh:us-east-1:123456789012:mesh/app1",
            "createdAt":1563809909.282,
            "lastUpdatedAt":1563809909.282,
            "uid":"a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version":1
        },
        "spec":{},
        "status":{
            "status":"ACTIVE"
        }
    }
}
```
**示例 2：创建带有多个标签的新服务网格**  
以下 `create-mesh` 示例创建一个带有多个标签的服务网格。  

```
aws appmesh create-mesh \
    --mesh-name app2 \
    --tags key=key1,value=value1 key=key2,value=value2 key=key3,value=value3
```
输出：  

```
{
    "mesh":{
        "meshName":"app2",
        "metadata":{
            "arn":"arn:aws:appmesh:us-east-1:123456789012:mesh/app2",
            "createdAt":1563822121.877,
            "lastUpdatedAt":1563822121.877,
            "uid":"a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version":1
        },
        "spec":{},
        "status":{
            "status":"ACTIVE"
        }
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[服务网格](https://docs.aws.amazon.com/app-mesh/latest/userguide/meshes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateMesh](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/create-mesh.html)*中的。

### `create-route`
<a name="app-mesh_CreateRoute_cli_2_topic"></a>

以下代码示例演示了如何使用 `create-route`。

**AWS CLI**  
**创建新的 gRPC 路由**  
以下 `create-route` 示例使用 JSON 输入文件创建 gRPC 路由。元数据以 123 开头的 GRPC 流量将路由到名为 serviceBgrpc 的虚拟节点。如果在尝试与路由目标通信时出现特定的 gRPC、HTTP 或 TCP 故障，则会重试该路由三次。每次重试之间有 15 秒的延迟。  

```
aws appmesh create-route \
    --cli-input-json file://create-route-grpc.json
```
`create-route-grpc.json` 的内容：  

```
{
    "meshName" : "apps",
    "routeName" : "grpcRoute",
    "spec" : {
       "grpcRoute" : {
          "action" : {
             "weightedTargets" : [
                {
                   "virtualNode" : "serviceBgrpc",
                   "weight" : 100
                }
             ]
          },
          "match" : {
             "metadata" : [
                {
                   "invert" : false,
                   "match" : {
                      "prefix" : "123"
                   },
                   "name" : "myMetadata"
                }
             ],
             "methodName" : "GetColor",
             "serviceName" : "com.amazonaws.services.ColorService"
          },
          "retryPolicy" : {
             "grpcRetryEvents" : [ "deadline-exceeded" ],
             "httpRetryEvents" : [ "server-error", "gateway-error" ],
             "maxRetries" : 3,
             "perRetryTimeout" : {
                "unit" : "s",
                "value" : 15
             },
             "tcpRetryEvents" : [ "connection-error" ]
          }
       },
       "priority" : 100
    },
    "virtualRouterName" : "serviceBgrpc"
}
```
输出：  

```
{
    "route": {
        "meshName": "apps",
        "metadata": {
            "arn": "arn:aws:appmesh:us-west-2:123456789012:mesh/apps/virtualRouter/serviceBgrpc/route/grpcRoute",
            "createdAt": 1572010806.008,
            "lastUpdatedAt": 1572010806.008,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "routeName": "grpcRoute",
        "spec": {
            "grpcRoute": {
                "action": {
                    "weightedTargets": [
                        {
                            "virtualNode": "serviceBgrpc",
                            "weight": 100
                        }
                    ]
                },
                "match": {
                    "metadata": [
                        {
                            "invert": false,
                            "match": {
                                "prefix": "123"
                            },
                            "name": "mymetadata"
                        }
                    ],
                    "methodName": "GetColor",
                    "serviceName": "com.amazonaws.services.ColorService"
                },
                "retryPolicy": {
                    "grpcRetryEvents": [
                        "deadline-exceeded"
                    ],
                    "httpRetryEvents": [
                        "server-error",
                        "gateway-error"
                    ],
                    "maxRetries": 3,
                    "perRetryTimeout": {
                        "unit": "s",
                        "value": 15
                    },
                    "tcpRetryEvents": [
                        "connection-error"
                    ]
                }
            },
            "priority": 100
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualRouterName": "serviceBgrpc"
    }
}
```
**创建新的 HTTP 或 HTTP/2 路由**  
以下 `create-route` 示例使用 JSON 输入文件创建 HTTP/2 路由。要创建 HTTP 路由，请在规范下将 http2Route 替换为 httpRoute。所有发往标头值以 123 开头的任何 URL 前缀的 HTTP/2 流量都将路由到名为 serviceBhttp2 的虚拟节点。如果在尝试与路由目标通信时出现特定的 HTTP 或 TCP 故障，则会重试该路由三次。每次重试之间有 15 秒的延迟。  

```
aws appmesh create-route \
    --cli-input-json file://create-route-http2.json
```
`create-route-http2.json` 的内容：  

```
{
    "meshName": "apps",
    "routeName": "http2Route",
    "spec": {
        "http2Route": {
            "action": {
                "weightedTargets": [
                    {
                        "virtualNode": "serviceBhttp2",
                        "weight": 100
                    }
                ]
            },
            "match": {
                "headers": [
                    {
                        "invert": false,
                        "match": {
                            "prefix": "123"
                        },
                        "name": "clientRequestId"
                    }
                ],
                "method": "POST",
                "prefix": "/",
                "scheme": "http"
            },
            "retryPolicy": {
                "httpRetryEvents": [
                    "server-error",
                    "gateway-error"
                ],
                "maxRetries": 3,
                "perRetryTimeout": {
                    "unit": "s",
                    "value": 15
                },
                "tcpRetryEvents": [
                    "connection-error"
                ]
            }
        },
        "priority": 200
    },
    "virtualRouterName": "serviceBhttp2"
}
```
输出：  

```
{
    "route": {
        "meshName": "apps",
        "metadata": {
            "arn": "arn:aws:appmesh:us-west-2:123456789012:mesh/apps/virtualRouter/serviceBhttp2/route/http2Route",
            "createdAt": 1572011008.352,
            "lastUpdatedAt": 1572011008.352,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "routeName": "http2Route",
        "spec": {
            "http2Route": {
                "action": {
                    "weightedTargets": [
                        {
                            "virtualNode": "serviceBhttp2",
                            "weight": 100
                        }
                    ]
                },
                "match": {
                    "headers": [
                        {
                            "invert": false,
                            "match": {
                                "prefix": "123"
                            },
                            "name": "clientRequestId"
                        }
                    ],
                    "method": "POST",
                    "prefix": "/",
                    "scheme": "http"
                },
                "retryPolicy": {
                    "httpRetryEvents": [
                        "server-error",
                        "gateway-error"
                    ],
                    "maxRetries": 3,
                    "perRetryTimeout": {
                        "unit": "s",
                        "value": 15
                    },
                    "tcpRetryEvents": [
                        "connection-error"
                    ]
                }
            },
            "priority": 200
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualRouterName": "serviceBhttp2"
    }
}
```
**创建新的 TCP 路由**  
以下 `create-route` 示例使用 JSON 输入文件创建 TCP 路由。75% 的流量路由到名为 serviceBtcp 的虚拟节点，25% 的流量路由到名为 serviceBv2tcp 的虚拟节点。为不同的目标指定不同的权重是部署应用程序新版本的有效方法。您可以调整权重，以便最终将 100% 的流量路由到具有新版本应用程序的目标。  

```
aws appmesh create-route \
    --cli-input-json file://create-route-tcp.json
```
 create-route-tcp.json 的内容：  

```
{
    "meshName": "apps",
    "routeName": "tcpRoute",
    "spec": {
        "priority": 300,
        "tcpRoute": {
            "action": {
                "weightedTargets": [
                    {
                        "virtualNode": "serviceBtcp",
                        "weight": 75
                    },
                    {
                        "virtualNode": "serviceBv2tcp",
                        "weight": 25
                    }
                ]
            }
        }
    },
    "virtualRouterName": "serviceBtcp"
}
```
输出：  

```
{
    "route": {
        "meshName": "apps",
        "metadata": {
            "arn": "arn:aws:appmesh:us-west-2:123456789012:mesh/apps/virtualRouter/serviceBtcp/route/tcpRoute",
            "createdAt": 1572011436.26,
            "lastUpdatedAt": 1572011436.26,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "routeName": "tcpRoute",
        "spec": {
            "priority": 300,
            "tcpRoute": {
                "action": {
                    "weightedTargets": [
                        {
                            "virtualNode": "serviceBtcp",
                            "weight": 75
                        },
                        {
                            "virtualNode": "serviceBv2tcp",
                            "weight": 25
                        }
                    ]
                }
            }
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualRouterName": "serviceBtcp"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[路由](https://docs.aws.amazon.com/app-mesh/latest/userguide/routes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/create-route.html)*中的。

### `create-virtual-gateway`
<a name="app-mesh_CreateVirtualGateway_cli_2_topic"></a>

以下代码示例演示了如何使用 `create-virtual-gateway`。

**AWS CLI**  
**创建新的虚拟网关**  
以下 `create-virtual-gateway` 示例使用 JSON 输入文件创建带有使用端口 9080 的 HTTP 侦听器的虚拟网关。  

```
aws appmesh create-virtual-gateway \
    --mesh-name meshName \
    --virtual-gateway-name virtualGatewayName \
    --cli-input-json file://create-virtual-gateway.json
```
`create-virtual-gateway.json` 的内容：  

```
{
    "spec": {
      "listeners": [
        {
          "portMapping": {
            "port": 9080,
            "protocol": "http"
          }
        }
      ]
    }
}
```
输出：  

```
{
    "virtualGateway": {
        "meshName": "meshName",
        "metadata": {
            "arn": "arn:aws:appmesh:us-west-2:123456789012:mesh/meshName/virtualGateway/virtualGatewayName",
            "createdAt": "2022-04-06T10:42:42.015000-05:00",
            "lastUpdatedAt": "2022-04-06T10:42:42.015000-05:00",
            "meshOwner": "123456789012",
            "resourceOwner": "123456789012",
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "spec": {
            "listeners": [
                {
                    "portMapping": {
                        "port": 9080,
                        "protocol": "http"
                    }
                }
            ]
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualGatewayName": "virtualGatewayName"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟网关](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_gateways.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateVirtualGateway](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/create-virtual-gateway.html)*中的。

### `create-virtual-node`
<a name="app-mesh_CreateVirtualNode_cli_2_topic"></a>

以下代码示例演示了如何使用 `create-virtual-node`。

**AWS CLI**  
**示例 1：创建使用 DNS 进行发现的新虚拟节点**  
以下 `create-virtual-node` 示例使用 JSON 输入文件创建使用 DNS 进行服务发现的虚拟节点。  

```
aws appmesh create-virtual-node \
    --cli-input-json file://create-virtual-node-dns.json
```
`create-virtual-node-dns.json` 的内容：  

```
{
    "meshName": "app1",
    "spec": {
        "listeners": [
            {
                "portMapping": {
                    "port": 80,
                    "protocol": "http"
                }
            }
        ],
        "serviceDiscovery": {
            "dns": {
                "hostname": "serviceBv1.svc.cluster.local"
            }
        }
    },
    "virtualNodeName": "vnServiceBv1"
}
```
输出：  

```
{
    "virtualNode": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualNode/vnServiceBv1",
            "createdAt": 1563810019.874,
            "lastUpdatedAt": 1563810019.874,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "spec": {
            "listeners": [
                {
                    "portMapping": {
                        "port": 80,
                        "protocol": "http"
                    }
                }
            ],
            "serviceDiscovery": {
                "dns": {
                    "hostname": "serviceBv1.svc.cluster.local"
                }
            }
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualNodeName": "vnServiceBv1"
    }
}
```
**示例 2：创建使用 AWS Cloud Map 进行发现的新虚拟节点**  
以下`create-virtual-node`示例使用 JSON 输入文件创建使用 AWS Cloud Map 进行服务发现的虚拟节点。  

```
aws appmesh create-virtual-node \
    --cli-input-json file://create-virtual-node-cloud-map.json
```
`create-virtual-node-cloud-map.json` 的内容：  

```
{
    "meshName": "app1",
    "spec": {
        "backends": [
            {
                "virtualService": {
                    "virtualServiceName": "serviceA.svc.cluster.local"
                }
            }
        ],
        "listeners": [
            {
                "portMapping": {
                    "port": 80,
                    "protocol": "http"
                }
            }
        ],
        "serviceDiscovery": {
            "awsCloudMap": {
                "attributes": [
                    {
                        "key": "Environment",
                        "value": "Testing"
                    }
                ],
                "namespaceName": "namespace1",
                "serviceName": "serviceA"
            }
        }
    },
    "virtualNodeName": "vnServiceA"
}
```
输出：  

```
{
    "virtualNode": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualNode/vnServiceA",
            "createdAt": 1563810859.465,
            "lastUpdatedAt": 1563810859.465,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "spec": {
            "backends": [
                {
                    "virtualService": {
                        "virtualServiceName": "serviceA.svc.cluster.local"
                    }
                }
            ],
            "listeners": [
                {
                    "portMapping": {
                        "port": 80,
                        "protocol": "http"
                    }
                }
            ],
            "serviceDiscovery": {
                "awsCloudMap": {
                    "attributes": [
                        {
                            "key": "Environment",
                            "value": "Testing"
                        }
                    ],
                    "namespaceName": "namespace1",
                    "serviceName": "serviceA"
                }
            }
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualNodeName": "vnServiceA"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟节点](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_nodes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateVirtualNode](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/create-virtual-node.html)*中的。

### `create-virtual-router`
<a name="app-mesh_CreateVirtualRouter_cli_2_topic"></a>

以下代码示例演示了如何使用 `create-virtual-router`。

**AWS CLI**  
**创建新的虚拟路由器**  
以下 `create-virtual-router` 示例使用 JSON 输入文件创建带有使用端口 80 的 HTTP 侦听器的虚拟路由器。  

```
aws appmesh create-virtual-router \
    --cli-input-json file://create-virtual-router.json
```
`create-virtual-router.json` 的内容：  

```
{
    "meshName": "app1",
    "spec": {
        "listeners": [
            {
                "portMapping": {
                    "port": 80,
                    "protocol": "http"
                }
            }
        ]
    },
    "virtualRouterName": "vrServiceB"
}
```
输出：  

```
{
    "virtualRouter": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualRouter/vrServiceB",
            "createdAt": 1563810546.59,
            "lastUpdatedAt": 1563810546.59,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "spec": {
            "listeners": [
                {
                    "portMapping": {
                        "port": 80,
                        "protocol": "http"
                    }
                }
            ]
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualRouterName": "vrServiceB"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟路由器](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_routers.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateVirtualRouter](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/create-virtual-router.html)*中的。

### `create-virtual-service`
<a name="app-mesh_CreateVirtualService_cli_2_topic"></a>

以下代码示例演示了如何使用 `create-virtual-service`。

**AWS CLI**  
**示例 1：创建带有虚拟节点提供程序的新虚拟服务**  
以下 `create-virtual-service` 示例使用 JSON 输入文件创建带有虚拟节点提供程序的虚拟服务。  

```
aws appmesh create-virtual-service \
    --cli-input-json file://create-virtual-service-virtual-node.json
```
`create-virtual-service-virtual-node.json` 的内容：  

```
{
    "meshName": "app1",
    "spec": {
        "provider": {
            "virtualNode": {
                "virtualNodeName": "vnServiceA"
            }
        }
    },
    "virtualServiceName": "serviceA.svc.cluster.local"
}
```
输出：  

```
{
    "virtualService": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualService/serviceA.svc.cluster.local",
            "createdAt": 1563810859.474,
            "lastUpdatedAt": 1563810967.179,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 2
        },
        "spec": {
            "provider": {
                "virtualNode": {
                    "virtualNodeName": "vnServiceA"
                }
            }
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualServiceName": "serviceA.svc.cluster.local"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟节点](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_nodes.html)。  
**示例 2：创建带有虚拟路由器提供程序的新虚拟服务**  
以下 `create-virtual-service` 示例使用 JSON 输入文件创建带有虚拟路由器提供程序的虚拟服务。  

```
aws appmesh create-virtual-service \
    --cli-input-json file://create-virtual-service-virtual-router.json
```
`create-virtual-service-virtual-router.json` 的内容：  

```
{
    "meshName": "app1",
    "spec": {
        "provider": {
            "virtualRouter": {
                "virtualRouterName": "vrServiceB"
            }
        }
    },
    "virtualServiceName": "serviceB.svc.cluster.local"
}
```
输出：  

```
{
    "virtualService": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualService/serviceB.svc.cluster.local",
            "createdAt": 1563908363.999,
            "lastUpdatedAt": 1563908363.999,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "spec": {
            "provider": {
                "virtualRouter": {
                    "virtualRouterName": "vrServiceB"
                }
            }
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualServiceName": "serviceB.svc.cluster.local"
    }
}
```
*有关更多信息，请参阅 App Mesh 用户指南https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual中的虚拟服务< \$1services.html>AWS *  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateVirtualService](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/create-virtual-service.html)*中的。

### `delete-mesh`
<a name="app-mesh_DeleteMesh_cli_2_topic"></a>

以下代码示例演示了如何使用 `delete-mesh`。

**AWS CLI**  
**删除服务网格**  
以下 `delete-mesh` 示例删除指定的服务网格。  

```
aws appmesh delete-mesh \
    --mesh-name app1
```
输出：  

```
{
    "mesh": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1",
            "createdAt": 1563809909.282,
            "lastUpdatedAt": 1563824981.248,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 2
        },
        "spec": {
            "egressFilter": {
                "type": "ALLOW_ALL"
            }
        },
        "status": {
            "status": "DELETED"
        }
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[服务网格](https://docs.aws.amazon.com/app-mesh/latest/userguide/meshes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteMesh](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/delete-mesh.html)*中的。

### `delete-route`
<a name="app-mesh_DeleteRoute_cli_2_topic"></a>

以下代码示例演示了如何使用 `delete-route`。

**AWS CLI**  
**删除路由**  
以下 `delete-route` 示例删除指定路由。  

```
aws appmesh delete-route \
    --mesh-name app1 \
    --virtual-router-name vrServiceB \
    --route-name toVnServiceB-weighted
```
输出：  

```
{
    "route": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualRouter/vrServiceB/route/toVnServiceB-weighted",
            "createdAt": 1563811384.015,
            "lastUpdatedAt": 1563823915.936,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 3
        },
        "routeName": "toVnServiceB-weighted",
        "spec": {
            "httpRoute": {
                "action": {
                    "weightedTargets": [
                        {
                            "virtualNode": "vnServiceBv1",
                            "weight": 80
                        },
                        {
                            "virtualNode": "vnServiceBv2",
                            "weight": 20
                        }
                    ]
                },
                "match": {
                    "prefix": "/"
                }
            }
        },
        "status": {
            "status": "DELETED"
        },
        "virtualRouterName": "vrServiceB"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[路由](https://docs.aws.amazon.com/app-mesh/latest/userguide/routes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/delete-route.html)*中的。

### `delete-virtual-node`
<a name="app-mesh_DeleteVirtualNode_cli_2_topic"></a>

以下代码示例演示了如何使用 `delete-virtual-node`。

**AWS CLI**  
**删除虚拟节点**  
以下 `delete-virtual-node` 示例删除指定的虚拟节点。  

```
aws appmesh delete-virtual-node \
    --mesh-name app1 \
    --virtual-node-name vnServiceBv2
```
输出：  

```
{
    "virtualNode": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualNode/vnServiceBv2",
            "createdAt": 1563810117.297,
            "lastUpdatedAt": 1563824700.678,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 2
        },
        "spec": {
            "backends": [],
            "listeners": [
                {
                    "portMapping": {
                        "port": 80,
                        "protocol": "http"
                    }
                }
            ],
            "serviceDiscovery": {
                "dns": {
                    "hostname": "serviceBv2.svc.cluster.local"
                }
            }
        },
        "status": {
            "status": "DELETED"
        },
        "virtualNodeName": "vnServiceBv2"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟节点](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_nodes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteVirtualNode](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/delete-virtual-node.html)*中的。

### `delete-virtual-router`
<a name="app-mesh_DeleteVirtualRouter_cli_2_topic"></a>

以下代码示例演示了如何使用 `delete-virtual-router`。

**AWS CLI**  
**删除虚拟路由器**  
以下 `delete-virtual-router` 示例删除指定的虚拟路由器。  

```
aws appmesh delete-virtual-router \
    --mesh-name app1 \
    --virtual-router-name vrServiceB
```
输出：  

```
{
    "virtualRouter": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualRouter/vrServiceB",
            "createdAt": 1563810546.59,
            "lastUpdatedAt": 1563824253.467,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 3
        },
        "spec": {
            "listeners": [
                {
                    "portMapping": {
                        "port": 80,
                        "protocol": "http"
                    }
                }
            ]
        },
        "status": {
            "status": "DELETED"
        },
        "virtualRouterName": "vrServiceB"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟路由器](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_routers.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteVirtualRouter](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/delete-virtual-router.html)*中的。

### `delete-virtual-service`
<a name="app-mesh_DeleteVirtualService_cli_2_topic"></a>

以下代码示例演示了如何使用 `delete-virtual-service`。

**AWS CLI**  
**删除虚拟服务**  
以下 `delete-virtual-service` 示例删除指定的虚拟服务。  

```
aws appmesh delete-virtual-service \
    --mesh-name app1 \
    --virtual-service-name serviceB.svc.cluster.local
```
输出：  

```
{
    "virtualService": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualService/serviceB.svc.cluster.local",
            "createdAt": 1563908363.999,
            "lastUpdatedAt": 1563913940.866,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 3
        },
        "spec": {},
        "status": {
            "status": "DELETED"
        },
        "virtualServiceName": "serviceB.svc.cluster.local"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟服务](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_services.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteVirtualService](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/delete-virtual-service.html)*中的。

### `describe-mesh`
<a name="app-mesh_DescribeMesh_cli_2_topic"></a>

以下代码示例演示了如何使用 `describe-mesh`。

**AWS CLI**  
**描述服务网格**  
以下 `describe-mesh` 示例返回有关指定服务网格的详细信息。  

```
aws appmesh describe-mesh \
    --mesh-name app1
```
输出：  

```
{
    "mesh": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1",
            "createdAt": 1563809909.282,
            "lastUpdatedAt": 1563809909.282,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "spec": {},
        "status": {
            "status": "ACTIVE"
        }
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[服务网格](https://docs.aws.amazon.com/app-mesh/latest/userguide/meshes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DescribeMesh](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/describe-mesh.html)*中的。

### `describe-route`
<a name="app-mesh_DescribeRoute_cli_2_topic"></a>

以下代码示例演示了如何使用 `describe-route`。

**AWS CLI**  
**描述路由**  
以下 `describe-route` 示例返回有关指定路由的详细信息。  

```
aws appmesh describe-route \
    --mesh-name app1 \
    --virtual-router-name vrServiceB \
    --route-name toVnServiceB-weighted
```
输出：  

```
{
    "route": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualRouter/vrServiceB/route/toVnServiceB-weighted",
            "createdAt": 1563811384.015,
            "lastUpdatedAt": 1563811384.015,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "routeName": "toVnServiceB-weighted",
        "spec": {
            "httpRoute": {
                "action": {
                    "weightedTargets": [
                        {
                            "virtualNode": "vnServiceBv1",
                            "weight": 90
                        },
                        {
                            "virtualNode": "vnServiceBv2",
                            "weight": 10
                        }
                    ]
                },
                "match": {
                    "prefix": "/"
                }
            }
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualRouterName": "vrServiceB"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[路由](https://docs.aws.amazon.com/app-mesh/latest/userguide/routes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DescribeRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/describe-route.html)*中的。

### `describe-virtual-node`
<a name="app-mesh_DescribeVirtualNode_cli_2_topic"></a>

以下代码示例演示了如何使用 `describe-virtual-node`。

**AWS CLI**  
**描述虚拟节点**  
以下 `describe-virtual-node` 示例返回有关指定虚拟节点的详细信息。  

```
aws appmesh describe-virtual-node \
    --mesh-name app1 \
    --virtual-node-name vnServiceBv1
```
输出：  

```
{
    "virtualNode": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualNode/vnServiceBv1",
            "createdAt": 1563810019.874,
            "lastUpdatedAt": 1563810019.874,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "spec": {
            "backends": [],
            "listeners": [
                {
                    "portMapping": {
                        "port": 80,
                        "protocol": "http"
                    }
                }
            ],
            "serviceDiscovery": {
                "dns": {
                    "hostname": "serviceBv1.svc.cluster.local"
                }
            }
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualNodeName": "vnServiceBv1"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟节点](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_nodes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DescribeVirtualNode](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/describe-virtual-node.html)*中的。

### `describe-virtual-router`
<a name="app-mesh_DescribeVirtualRouter_cli_2_topic"></a>

以下代码示例演示了如何使用 `describe-virtual-router`。

**AWS CLI**  
**描述虚拟路由器**  
以下 `describe-virtual-router` 示例返回有关指定虚拟路由器的详细信息。  

```
aws appmesh describe-virtual-router \
    --mesh-name app1 \
    --virtual-router-name vrServiceB
```
输出：  

```
{
    "virtualRouter": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualRouter/vrServiceB",
            "createdAt": 1563810546.59,
            "lastUpdatedAt": 1563810546.59,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "spec": {
            "listeners": [
                {
                    "portMapping": {
                        "port": 80,
                        "protocol": "http"
                    }
                }
            ]
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualRouterName": "vrServiceB"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟路由器](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_routers.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DescribeVirtualRouter](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/describe-virtual-router.html)*中的。

### `describe-virtual-service`
<a name="app-mesh_DescribeVirtualService_cli_2_topic"></a>

以下代码示例演示了如何使用 `describe-virtual-service`。

**AWS CLI**  
**描述虚拟服务**  
以下 `describe-virtual-service` 示例返回有关指定虚拟服务的详细信息。  

```
aws appmesh describe-virtual-service \
    --mesh-name app1 \
    --virtual-service-name serviceB.svc.cluster.local
```
输出：  

```
{
    "virtualService": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualService/serviceB.svc.cluster.local",
            "createdAt": 1563908363.999,
            "lastUpdatedAt": 1563908363.999,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 1
        },
        "spec": {
            "provider": {
                "virtualRouter": {
                    "virtualRouterName": "vrServiceB"
                }
            }
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualServiceName": "serviceB.svc.cluster.local"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟服务](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_services.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DescribeVirtualService](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/describe-virtual-service.html)*中的。

### `list-meshes`
<a name="app-mesh_ListMeshes_cli_2_topic"></a>

以下代码示例演示了如何使用 `list-meshes`。

**AWS CLI**  
**列出服务网格**  
以下`list-meshes`示例列出了当前 AWS 区域中的所有服务网格。  

```
aws appmesh list-meshes
```
输出：  

```
{
    "meshes": [
        {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1",
            "meshName": "app1"
        }
    ]
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[服务网格](https://docs.aws.amazon.com/app-mesh/latest/userguide/meshes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListMeshes](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/list-meshes.html)*中的。

### `list-routes`
<a name="app-mesh_ListRoutes_cli_2_topic"></a>

以下代码示例演示了如何使用 `list-routes`。

**AWS CLI**  
**列出路由**  
以下 `list-routes` 示例列出指定虚拟路由器的所有路由。  

```
aws appmesh list-routes \
    --mesh-name app1 \
    --virtual-router-name vrServiceB
```
输出：  

```
{
    "routes": [
        {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualRouter/vrServiceB/route/toVnServiceB",
            "meshName": "app1",
            "routeName": "toVnServiceB-weighted",
            "virtualRouterName": "vrServiceB"
        }
    ]
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[路由](https://docs.aws.amazon.com/app-mesh/latest/userguide/routes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListRoutes](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/list-routes.html)*中的。

### `list-tags-for-resource`
<a name="app-mesh_ListTagsForResource_cli_2_topic"></a>

以下代码示例演示了如何使用 `list-tags-for-resource`。

**AWS CLI**  
**列出资源标签**  
以下 `list-tags-for-resource` 示例列出分配给指定资源的所有标签。  

```
aws appmesh list-tags-for-resource \
    --resource-arn arn:aws:appmesh:us-east-1:123456789012:mesh/app1
```
输出：  

```
{
    "tags": [
        {
            "key": "key1",
            "value": "value1"
        },
        {
            "key": "key2",
            "value": "value2"
        },
        {
            "key": "key3",
            "value": "value3"
        }
    ]
}
```
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListTagsForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/list-tags-for-resource.html)*中的。

### `list-virtual-nodes`
<a name="app-mesh_ListVirtualNodes_cli_2_topic"></a>

以下代码示例演示了如何使用 `list-virtual-nodes`。

**AWS CLI**  
**列出虚拟节点**  
以下 `list-virtual-nodes` 示例列出指定服务网格中的所有虚拟节点。  

```
aws appmesh list-virtual-nodes \
    --mesh-name app1
```
输出：  

```
{
    "virtualNodes": [
        {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualNode/vnServiceBv1",
            "meshName": "app1",
            "virtualNodeName": "vnServiceBv1"
        },
        {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualNode/vnServiceBv2",
            "meshName": "app1",
            "virtualNodeName": "vnServiceBv2"
        }
    ]
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟节点](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_nodes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListVirtualNodes](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/list-virtual-nodes.html)*中的。

### `list-virtual-routers`
<a name="app-mesh_ListVirtualRouters_cli_2_topic"></a>

以下代码示例演示了如何使用 `list-virtual-routers`。

**AWS CLI**  
**列出虚拟路由器**  
以下 `list-virtual-routers` 示例列出指定服务网格中的所有虚拟路由器。  

```
aws appmesh list-virtual-routers \
    --mesh-name app1
```
输出：  

```
{
    "virtualRouters": [
        {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualRouter/vrServiceB",
            "meshName": "app1",
            "virtualRouterName": "vrServiceB"
        }
    ]
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟路由器](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_routers.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListVirtualRouters](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/list-virtual-routers.html)*中的。

### `list-virtual-services`
<a name="app-mesh_ListVirtualServices_cli_2_topic"></a>

以下代码示例演示了如何使用 `list-virtual-services`。

**AWS CLI**  
**列出虚拟服务**  
以下 `list-virtual-services` 示例列出指定服务网格中的所有虚拟服务。  

```
aws appmesh list-virtual-services \
    --mesh-name app1
```
输出：  

```
{
    "virtualServices": [
        {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualService/serviceA.svc.cluster.local",
            "meshName": "app1",
            "virtualServiceName": "serviceA.svc.cluster.local"
        },
        {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualService/serviceB.svc.cluster.local",
            "meshName": "app1",
            "virtualServiceName": "serviceB.svc.cluster.local"
        }
    ]
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟服务](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_services.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListVirtualServices](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/list-virtual-services.html)*中的。

### `tag-resource`
<a name="app-mesh_TagResource_cli_2_topic"></a>

以下代码示例演示了如何使用 `tag-resource`。

**AWS CLI**  
**标记资源**  
以下 `tag-resource` 示例将值为 `value1` 的标签 `key1` 添加到指定的资源。  

```
aws appmesh tag-resource \
    --resource-arn arn:aws:appmesh:us-east-1:123456789012:mesh/app1 \
    --tags key=key1,value=value1
```
此命令不生成任何输出。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/tag-resource.html)*中的。

### `untag-resource`
<a name="app-mesh_UntagResource_cli_2_topic"></a>

以下代码示例演示了如何使用 `untag-resource`。

**AWS CLI**  
**取消标记资源**  
以下 `untag-resource` 示例从指定资源中移除键为 `key1` 的标签。  

```
aws appmesh untag-resource \
    --resource-arn arn:aws:appmesh:us-east-1:123456789012:mesh/app1 \
    --tag-keys key1
```
此命令不生成任何输出。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/untag-resource.html)*中的。

### `update-mesh`
<a name="app-mesh_UpdateMesh_cli_2_topic"></a>

以下代码示例演示了如何使用 `update-mesh`。

**AWS CLI**  
**更新服务网格**  
以下 `update-mesh` 示例使用 JSON 输入文件更新服务网格，使所有外部出口流量都能不受任何影响地通过 Envoy 代理转发。  

```
aws appmesh update-mesh \
    --cli-input-json file://update-mesh.json
```
`update-mesh.json` 的内容：  

```
{
    "meshName": "app1",
    "spec": {
        "egressFilter": {
            "type": "ALLOW_ALL"
        }
    }
}
```
输出：  

```
{
    "mesh": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1",
            "createdAt": 1563809909.282,
            "lastUpdatedAt": 1563812829.687,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 2
        },
        "spec": {
            "egressFilter": {
                "type": "ALLOW_ALL"
            }
        },
        "status": {
            "status": "ACTIVE"
        }
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[服务网格](https://docs.aws.amazon.com/app-mesh/latest/userguide/meshes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateMesh](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/update-mesh.html)*中的。

### `update-route`
<a name="app-mesh_UpdateRoute_cli_2_topic"></a>

以下代码示例演示了如何使用 `update-route`。

**AWS CLI**  
**更新路由**  
以下 `update-route` 示例使用 JSON 输入文件更新路由的权重。  

```
aws appmesh update-route \
    --cli-input-json file://update-route-weighted.json
```
`update-route-weighted.json` 的内容：  

```
{
    "meshName": "app1",
    "routeName": "toVnServiceB-weighted",
    "spec": {
        "httpRoute": {
            "action": {
                "weightedTargets": [
                    {
                        "virtualNode": "vnServiceBv1",
                        "weight": 80
                    },
                    {
                        "virtualNode": "vnServiceBv2",
                        "weight": 20
                    }
                ]
            },
            "match": {
                "prefix": "/"
            }
        }
    },
    "virtualRouterName": "vrServiceB"
}
```
输出：  

```
{
    "route": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualRouter/vrServiceB/route/toVnServiceB-weighted",
            "createdAt": 1563811384.015,
            "lastUpdatedAt": 1563819600.022,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 2
        },
        "routeName": "toVnServiceB-weighted",
        "spec": {
            "httpRoute": {
                "action": {
                    "weightedTargets": [
                        {
                            "virtualNode": "vnServiceBv1",
                            "weight": 80
                        },
                        {
                            "virtualNode": "vnServiceBv2",
                            "weight": 20
                        }
                    ]
                },
                "match": {
                    "prefix": "/"
                }
            }
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualRouterName": "vrServiceB"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[路由](https://docs.aws.amazon.com/app-mesh/latest/userguide/routes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/update-route.html)*中的。

### `update-virtual-node`
<a name="app-mesh_UpdateVirtualNode_cli_2_topic"></a>

以下代码示例演示了如何使用 `update-virtual-node`。

**AWS CLI**  
**更新虚拟节点**  
以下 `update-virtual-node` 示例使用 JSON 输入文件向虚拟节点添加运行状况检查。  

```
aws appmesh update-virtual-node \
    --cli-input-json file://update-virtual-node.json
```
`update-virtual-node.json` 的内容：  

```
{
    "clientToken": "500",
    "meshName": "app1",
    "spec": {
        "listeners": [
            {
                "healthCheck": {
                    "healthyThreshold": 5,
                    "intervalMillis": 10000,
                    "path": "/",
                    "port": 80,
                    "protocol": "http",
                    "timeoutMillis": 3000,
                    "unhealthyThreshold": 3
                },
                "portMapping": {
                    "port": 80,
                    "protocol": "http"
                }
            }
        ],
        "serviceDiscovery": {
            "dns": {
                "hostname": "serviceBv1.svc.cluster.local"
            }
        }
    },
    "virtualNodeName": "vnServiceBv1"
}
```
输出：  

```
{
    "virtualNode": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualNode/vnServiceBv1",
            "createdAt": 1563810019.874,
            "lastUpdatedAt": 1563819234.825,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 2
        },
        "spec": {
            "listeners": [
                {
                    "healthCheck": {
                        "healthyThreshold": 5,
                        "intervalMillis": 10000,
                        "path": "/",
                        "port": 80,
                        "protocol": "http",
                        "timeoutMillis": 3000,
                        "unhealthyThreshold": 3
                    },
                    "portMapping": {
                        "port": 80,
                        "protocol": "http"
                    }
                }
            ],
            "serviceDiscovery": {
                "dns": {
                    "hostname": "serviceBv1.svc.cluster.local"
                }
            }
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualNodeName": "vnServiceBv1"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟节点](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_nodes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateVirtualNode](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/update-virtual-node.html)*中的。

### `update-virtual-router`
<a name="app-mesh_UpdateVirtualRouter_cli_2_topic"></a>

以下代码示例演示了如何使用 `update-virtual-router`。

**AWS CLI**  
**更新虚拟路由器**  
以下 `update-virtual-router` 示例使用 JSON 输入文件更新虚拟路由器的侦听器端口。  

```
aws appmesh update-virtual-router \
    --cli-input-json file://update-virtual-router.json
```
`update-virtual-router.json` 的内容：  

```
{
    "meshName": "app1",
    "spec": {
        "listeners": [
            {
                "portMapping": {
                    "port": 8080,
                    "protocol": "http"
                }
            }
        ]
    },
    "virtualRouterName": "vrServiceB"
}
```
输出：  

```
{
    "virtualRouter": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualRouter/vrServiceB",
            "createdAt": 1563810546.59,
            "lastUpdatedAt": 1563819431.352,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 2
        },
        "spec": {
            "listeners": [
                {
                    "portMapping": {
                        "port": 8080,
                        "protocol": "http"
                    }
                }
            ]
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualRouterName": "vrServiceB"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟路由器](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_routers.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateVirtualRouter](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/update-virtual-router.html)*中的。

### `update-virtual-service`
<a name="app-mesh_UpdateVirtualService_cli_2_topic"></a>

以下代码示例演示了如何使用 `update-virtual-service`。

**AWS CLI**  
**更新虚拟服务**  
以下 `update-virtual-service` 示例使用 JSON 输入文件更新虚拟服务，以使用虚拟路由器提供程序。  

```
aws appmesh update-virtual-service \
    --cli-input-json file://update-virtual-service.json
```
`update-virtual-service.json` 的内容：  

```
{
    "meshName": "app1",
    "spec": {
        "provider": {
            "virtualRouter": {
                "virtualRouterName": "vrServiceA"
            }
        }
    },
    "virtualServiceName": "serviceA.svc.cluster.local"
}
```
输出：  

```
{
    "virtualService": {
        "meshName": "app1",
        "metadata": {
            "arn": "arn:aws:appmesh:us-east-1:123456789012:mesh/app1/virtualService/serviceA.svc.cluster.local",
            "createdAt": 1563810859.474,
            "lastUpdatedAt": 1563820257.411,
            "uid": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
            "version": 3
        },
        "spec": {
            "provider": {
                "virtualRouter": {
                    "virtualRouterName": "vrServiceA"
                }
            }
        },
        "status": {
            "status": "ACTIVE"
        },
        "virtualServiceName": "serviceA.svc.cluster.local"
    }
}
```
有关更多信息，请参阅《AWS App Mesh 用户指南》**中的[虚拟服务](https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_services.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateVirtualService](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appmesh/update-virtual-service.html)*中的。