CmdID / aws / aws appmesh
aws appmesh create-virtual-node
Creates a virtual node within a service mesh. AWS CLI reference
2 examples 6 options Its page in the AWS CLI reference
Examples
Example 1: To create a new virtual node that uses DNS for discovery
The following create-virtual-node example uses a JSON input file to create a virtual node that uses DNS for service discovery.
aws appmesh create-virtual-node --cli-input-json file://create-virtual-node-dns.jsonIdentifyContents of create-virtual-node-dns.json:
{
"meshName": "app1",
"spec": {
"listeners": [
{
"portMapping": {
"port": 80,
"protocol": "http"
}
}
],
"serviceDiscovery": {
"dns": {
"hostname": "serviceBv1.svc.cluster.local"
}
}
},
"virtualNodeName": "vnServiceBv1"
}
Its output, shortened
{
"virtualNode": {
"meshName": "app1",
"metadata": {
"arn": "arn:aws:appmesh:us-west-2:123456789012:mesh/app1/virtualNode/vnServiceBv1",
"createdAt": 1563810019.874,
"lastUpdatedAt": 1563810019.874,
"uid": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"version": 1
},
"spec": {
"listeners": [
{
"portMapping": {
"port": 80,
"protocol": "http"
}
}
],
"serviceDiscovery": {
"dns": {
"hostname": "serviceBv1.svc.cluster.local"
}
}
},
"status": {
"status": "ACTIVE"
},
"virtualNodeName": "vnServiceBv1"
}
… 1 more lineExample 2: To create a new virtual node that uses AWS Cloud Map for discovery
The following create-virtual-node example uses a JSON input file to create a virtual node that uses AWS Cloud Map for service discovery.
aws appmesh create-virtual-node --cli-input-json file://create-virtual-node-cloud-map.jsonIdentifyContents of 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"
}
Its output, shortened
{
"virtualNode": {
"meshName": "app1",
"metadata": {
"arn": "arn:aws:appmesh:us-west-2:123456789012:mesh/app1/virtualNode/vnServiceA",
"createdAt": 1563810859.465,
"lastUpdatedAt": 1563810859.465,
"uid": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"version": 1
},
"spec": {
"backends": [
{
"virtualService": {
"virtualServiceName": "serviceA.svc.cluster.local"
}
}
],
"listeners": [
{
"portMapping": {
"port": 80,
"protocol": "http"
}
}
],
"serviceDiscovery": {
"awsCloudMap": {
"attributes": [
{
… 15 more linesFor more information, see Virtual Nodes in the AWS App Mesh User Guide.
Options
--client-tokenUnique, case-sensitive identifier that you provide to ensure the idempotency of the request.--mesh-nameThe name of the service mesh to create the virtual node in.--mesh-ownerThe Amazon Web Services IAM account ID of the service mesh owner.--specThe virtual node specification to apply.--tagsOptional metadata that you can apply to the virtual node to assist with categorization and organization.--virtual-node-nameThe name to use for the virtual node.