createVirtualNode method

Future<CreateVirtualNodeOutput> createVirtualNode({
  1. required String meshName,
  2. required VirtualNodeSpec spec,
  3. required String virtualNodeName,
  4. String? clientToken,
})

Creates a new virtual node within a service mesh.

A virtual node acts as logical pointer to a particular task group, such as an Amazon ECS service or a Kubernetes deployment. When you create a virtual node, you must specify the DNS service discovery name for your task group.

Any inbound traffic that your virtual node expects should be specified as a listener. Any outbound traffic that your virtual node expects to reach should be specified as a backend.

The response metadata for your new virtual node contains the arn that is associated with the virtual node. Set this value (either the full ARN or the truncated resource name, for example, mesh/default/virtualNode/simpleapp, as the APPMESH_VIRTUAL_NODE_NAME environment variable for your task group's Envoy proxy container in your task definition or pod spec. This is then mapped to the node.id and node.cluster Envoy parameters.

May throw BadRequestException. May throw ConflictException. May throw ForbiddenException. May throw InternalServerErrorException. May throw LimitExceededException. May throw NotFoundException. May throw ServiceUnavailableException. May throw TooManyRequestsException.

Parameter meshName : The name of the service mesh in which to create the virtual node.

Parameter spec : The virtual node specification to apply.

Parameter virtualNodeName : The name to use for the virtual node.

Parameter clientToken : Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Up to 36 letters, numbers, hyphens, and underscores are allowed.

Implementation

Future<CreateVirtualNodeOutput> createVirtualNode({
  required String meshName,
  required VirtualNodeSpec spec,
  required String virtualNodeName,
  String? clientToken,
}) async {
  ArgumentError.checkNotNull(meshName, 'meshName');
  _s.validateStringLength(
    'meshName',
    meshName,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(spec, 'spec');
  ArgumentError.checkNotNull(virtualNodeName, 'virtualNodeName');
  _s.validateStringLength(
    'virtualNodeName',
    virtualNodeName,
    1,
    255,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    'spec': spec,
    'virtualNodeName': virtualNodeName,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
  };
  final response = await _protocol.sendRaw(
    payload: $payload,
    method: 'PUT',
    requestUri: '/meshes/${Uri.encodeComponent(meshName)}/virtualNodes',
    exceptionFnMap: _exceptionFns,
  );
  final $json = await _s.jsonFromResponse(response);
  return CreateVirtualNodeOutput(
    virtualNode: VirtualNodeData.fromJson($json),
  );
}