aws-cdk-lib.aws_appmesh.VirtualNode

class VirtualNode (construct)

LanguageType name
.NETAmazon.CDK.AWS.AppMesh.VirtualNode
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsappmesh#VirtualNode
Javasoftware.amazon.awscdk.services.appmesh.VirtualNode
Pythonaws_cdk.aws_appmesh.VirtualNode
TypeScript (source)aws-cdk-lib » aws_appmesh » VirtualNode

Implements IConstruct, IDependable, IResource, IVirtualNode

VirtualNode represents a newly defined AppMesh VirtualNode.

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.

See also: https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_nodes.html

Example

// Cloud Map service discovery is currently required for host ejection by outlier detection
const vpc = new ec2.Vpc(this, 'vpc');
const namespace = new cloudmap.PrivateDnsNamespace(this, 'test-namespace', {
    vpc,
    name: 'domain.local',
});
const service = namespace.createService('Svc');

declare const mesh: appmesh.Mesh;
const node = mesh.addVirtualNode('virtual-node', {
  serviceDiscovery: appmesh.ServiceDiscovery.cloudMap(service),
  listeners: [appmesh.VirtualNodeListener.http({
    outlierDetection: {
      baseEjectionDuration: Duration.seconds(10),
      interval: Duration.seconds(30),
      maxEjectionPercent: 50,
      maxServerErrors: 5,
    },
  })],
});

Initializer

new VirtualNode(scope: Construct, id: string, props: VirtualNodeProps)

Parameters

  • scope Construct
  • id string
  • props VirtualNodeProps

Construct Props

NameTypeDescription
meshIMeshThe Mesh which the VirtualNode belongs to.
accessLog?AccessLogAccess Logging Configuration for the virtual node.
backendDefaults?BackendDefaultsDefault Configuration Virtual Node uses to communicate with Virtual Service.
backends?Backend[]Virtual Services that this is node expected to send outbound traffic to.
listeners?VirtualNodeListener[]Initial listener for the virtual node.
serviceDiscovery?ServiceDiscoveryDefines how upstream clients will discover this VirtualNode.
virtualNodeName?stringThe name of the VirtualNode.

mesh

Type: IMesh

The Mesh which the VirtualNode belongs to.


accessLog?

Type: AccessLog (optional, default: No access logging)

Access Logging Configuration for the virtual node.


backendDefaults?

Type: BackendDefaults (optional, default: No Config)

Default Configuration Virtual Node uses to communicate with Virtual Service.


backends?

Type: Backend[] (optional, default: No backends)

Virtual Services that this is node expected to send outbound traffic to.


listeners?

Type: VirtualNodeListener[] (optional, default: No listeners)

Initial listener for the virtual node.


serviceDiscovery?

Type: ServiceDiscovery (optional, default: No Service Discovery)

Defines how upstream clients will discover this VirtualNode.


virtualNodeName?

Type: string (optional, default: A name is automatically determined)

The name of the VirtualNode.

Properties

NameTypeDescription
envResourceEnvironmentThe environment this resource belongs to.
meshIMeshThe Mesh which the VirtualNode belongs to.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.
virtualNodeArnstringThe Amazon Resource Name belonging to the VirtualNode.
virtualNodeNamestringThe name of the VirtualNode.

env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


mesh

Type: IMesh

The Mesh which the VirtualNode belongs to.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.


virtualNodeArn

Type: string

The Amazon Resource Name belonging to the VirtualNode.


virtualNodeName

Type: string

The name of the VirtualNode.

Methods

NameDescription
addBackend(backend)Add a Virtual Services that this node is expected to send outbound traffic to.
addListener(listener)Utility method to add an inbound listener for this VirtualNode.
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
grantStreamAggregatedResources(identity)Grants the given entity appmesh:StreamAggregatedResources.
toString()Returns a string representation of this construct.
static fromVirtualNodeArn(scope, id, virtualNodeArn)Import an existing VirtualNode given an ARN.
static fromVirtualNodeAttributes(scope, id, attrs)Import an existing VirtualNode given its name.

addBackend(backend)

public addBackend(backend: Backend): void

Parameters

  • backend Backend

Add a Virtual Services that this node is expected to send outbound traffic to.


addListener(listener)

public addListener(listener: VirtualNodeListener): void

Parameters

  • listener VirtualNodeListener

Utility method to add an inbound listener for this VirtualNode.

Note: At this time, Virtual Nodes support at most one listener. Adding more than one will result in a failure to deploy the CloudFormation stack. However, the App Mesh team has plans to add support for multiple listeners on Virtual Nodes and Virtual Routers.

See also: https://github.com/aws/aws-app-mesh-roadmap/issues/120


applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


grantStreamAggregatedResources(identity)

public grantStreamAggregatedResources(identity: IGrantable): Grant

Parameters

  • identity IGrantable

Returns

  • Grant

Grants the given entity appmesh:StreamAggregatedResources.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromVirtualNodeArn(scope, id, virtualNodeArn)

public static fromVirtualNodeArn(scope: Construct, id: string, virtualNodeArn: string): IVirtualNode

Parameters

  • scope Construct
  • id string
  • virtualNodeArn string

Returns

  • IVirtualNode

Import an existing VirtualNode given an ARN.


static fromVirtualNodeAttributes(scope, id, attrs)

public static fromVirtualNodeAttributes(scope: Construct, id: string, attrs: VirtualNodeAttributes): IVirtualNode

Parameters

  • scope Construct
  • id string
  • attrs VirtualNodeAttributes

Returns

  • IVirtualNode

Import an existing VirtualNode given its name.