Skip to content

create_virtual_node

create_virtual_node(
    virtual_node_name: ResourceName,
    mesh_name: ResourceName,
    spec: VirtualNodeSpec,
    *,
    config_overrides: Optional[AppMeshClientConfig] = None,
    tags: Optional[TagList] = None,
    client_token: Optional[str] = None,
    mesh_owner: Optional[AccountId] = None,
) -> CreateVirtualNodeOutput

Creates a virtual node within a service mesh.

A virtual node acts as a logical pointer to a particular task group, such as an Amazon ECS service or a Kubernetes deployment. When you create a virtual node, you can specify the service discovery information for your task group, and whether the proxy running in a task group will communicate with other proxies using Transport Layer Security (TLS).

You define a listener for any inbound traffic that your virtual node expects. Any virtual service that your virtual node expects to communicate to is 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 to the full ARN; for example, arn:aws:appmesh:us-west-2:123456789012:myMesh/default/virtualNode/myApp) as the APPMESH_RESOURCE_ARN 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.

By default, App Mesh uses the name of the resource you specified in APPMESH_RESOURCE_ARN when Envoy is referring to itself in metrics and traces. You can override this behavior by setting the APPMESH_RESOURCE_CLUSTER environment variable with your own name.

For more information about virtual nodes, see Virtual nodes. You must be using 1.15.0 or later of the Envoy image when setting these variables. For more information aboutApp Mesh Envoy variables, see Envoy image in the App Mesh User Guide.

Parameters:

  • virtual_node_name (ResourceName) –

    The name to use for the virtual node.

  • mesh_name (ResourceName) –

    The name of the service mesh to create the virtual node in.

  • spec (VirtualNodeSpec) –

    The virtual node specification to apply.

  • tags (Optional[TagList], default: None ) –

    Optional metadata that you can apply to the virtual node to assist with categorization and organization. Each tag consists of a key and an optional value, both of which you define. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.

  • client_token (Optional[str], default: None ) –

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

  • mesh_owner (Optional[AccountId], default: None ) –

    The Amazon Web Services IAM account ID of the service mesh owner. If the account ID is not your own, then the account that you specify must share the mesh with your account before you can create the resource in the service mesh. For more information about mesh sharing, see Working with shared meshes.

Raises:

  • BadRequestException –

    The request syntax was malformed. Check your request syntax and try again.

  • ConflictException –

    The request contains a client token that was used for a previous update resource call with different specifications. Try the request again with a new client token.

  • ForbiddenException –

    You don't have permissions to perform this action.

  • InternalServerErrorException –

    The request processing has failed because of an unknown error, exception, or failure.

  • LimitExceededException –

    You have exceeded a service limit for your account. For more information, see Service Limits in the App Mesh User Guide.

  • NotFoundException –

    The specified resource doesn't exist. Check your request syntax and try again.

  • ServiceUnavailableException –

    The request has failed due to a temporary failure of the service.

  • TooManyRequestsException –

    The maximum request rate permitted by the App Mesh APIs has been exceeded for your account. For best results, use an increasing or variable sleep interval between requests.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_app_mesh/_services/app_mesh.py
def create_virtual_node(
    self,
    virtual_node_name: "capo_app_mesh.types.resource_name.ResourceName",
    mesh_name: "capo_app_mesh.types.resource_name.ResourceName",
    spec: "capo_app_mesh.types.virtual_node_spec.VirtualNodeSpec",
    *,
    config_overrides: Optional[AppMeshClientConfig] = None,
    tags: Optional["capo_app_mesh.types.tag_list.TagList"] = None,
    client_token: Optional[str] = None,
    mesh_owner: Optional["capo_app_mesh.types.account_id.AccountId"] = None,
) -> "capo_app_mesh.types.create_virtual_node_output.CreateVirtualNodeOutput":
    """<p>Creates a virtual node within a service mesh.</p> <p> A virtual node acts as a logical pointer to a particular task group, such as an Amazon ECS service or a Kubernetes deployment. When you create a virtual node, you can specify the service discovery information for your task group, and whether the proxy running in a task group will communicate with other proxies using Transport Layer Security (TLS).</p> <p>You define a <code>listener</code> for any inbound traffic that your virtual node expects. Any virtual service that your virtual node expects to communicate to is specified as a <code>backend</code>.</p> <p>The response metadata for your new virtual node contains the <code>arn</code> that is associated with the virtual node. Set this value to the full ARN; for example, <code>arn:aws:appmesh:us-west-2:123456789012:myMesh/default/virtualNode/myApp</code>) as the <code>APPMESH_RESOURCE_ARN</code> environment variable for your task group's Envoy proxy container in your task definition or pod spec. This is then mapped to the <code>node.id</code> and <code>node.cluster</code> Envoy parameters.</p> <note> <p>By default, App Mesh uses the name of the resource you specified in <code>APPMESH_RESOURCE_ARN</code> when Envoy is referring to itself in metrics and traces. You can override this behavior by setting the <code>APPMESH_RESOURCE_CLUSTER</code> environment variable with your own name.</p> </note> <p>For more information about virtual nodes, see <a href="https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_nodes.html">Virtual nodes</a>. You must be using <code>1.15.0</code> or later of the Envoy image when setting these variables. For more information aboutApp Mesh Envoy variables, see <a href="https://docs.aws.amazon.com/app-mesh/latest/userguide/envoy.html">Envoy image</a> in the App Mesh User Guide.</p>

    Args:
        virtual_node_name: <p>The name to use for the virtual node.</p>
        mesh_name: <p>The name of the service mesh to create the virtual node in.</p>
        spec: <p>The virtual node specification to apply.</p>
        tags: <p>Optional metadata that you can apply to the virtual node to assist with categorization and organization. Each tag consists of a key and an optional value, both of which you define. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.</p>
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Up to 36 letters, numbers, hyphens, and underscores are allowed.</p>
        mesh_owner: <p>The Amazon Web Services IAM account ID of the service mesh owner. If the account ID is not your own, then the account that you specify must share the mesh with your account before you can create the resource in the service mesh. For more information about mesh sharing, see <a href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working with shared meshes</a>.</p>

    Raises:
        capo_app_mesh.errors.bad_request_exception.BadRequestException: <p>The request syntax was malformed. Check your request syntax and try again.</p>
        capo_app_mesh.errors.conflict_exception.ConflictException: <p>The request contains a client token that was used for a previous update resource call with different specifications. Try the request again with a new client token.</p>
        capo_app_mesh.errors.forbidden_exception.ForbiddenException: <p>You don't have permissions to perform this action.</p>
        capo_app_mesh.errors.internal_server_error_exception.InternalServerErrorException: <p>The request processing has failed because of an unknown error, exception, or failure.</p>
        capo_app_mesh.errors.limit_exceeded_exception.LimitExceededException: <p>You have exceeded a service limit for your account. For more information, see <a href="https://docs.aws.amazon.com/app-mesh/latest/userguide/service-quotas.html">Service Limits</a> in the <i>App Mesh User Guide</i>.</p>
        capo_app_mesh.errors.not_found_exception.NotFoundException: <p>The specified resource doesn't exist. Check your request syntax and try again.</p>
        capo_app_mesh.errors.service_unavailable_exception.ServiceUnavailableException: <p>The request has failed due to a temporary failure of the service.</p>
        capo_app_mesh.errors.too_many_requests_exception.TooManyRequestsException: <p>The maximum request rate permitted by the App Mesh APIs has been exceeded for your account. For best results, use an increasing or variable sleep interval between requests.</p>
        capo_app_mesh.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_app_mesh.types.create_virtual_node_input.CreateVirtualNodeInput]",
    ) -> OperationResponse[
        "capo_app_mesh.types.create_virtual_node_output.CreateVirtualNodeOutput"
    ]:
        import capo_app_mesh._operations.app_mesh.create_virtual_node

        output, http_response = (
            capo_app_mesh._operations.app_mesh.create_virtual_node.create_virtual_node(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateVirtualNode")
    )
    input_: capo_app_mesh.types.create_virtual_node_input.CreateVirtualNodeInput = {
        "virtual_node_name": virtual_node_name,
        "mesh_name": mesh_name,
        "spec": spec,
    }
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if mesh_owner is not None:
        input_["mesh_owner"] = mesh_owner

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output