VirtualNode L2 construct
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. [disable-awslint:no-grants]
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,
},
})],
});
# mesh: appmesh.Mesh
# Cloud Map service discovery is currently required for host ejection by outlier detection
vpc = ec2.Vpc(self, "vpc")
namespace = cloudmap.PrivateDnsNamespace(self, "test-namespace",
vpc=vpc,
name="domain.local"
)
service = namespace.create_service("Svc")
node = mesh.add_virtual_node("virtual-node",
service_discovery=appmesh.ServiceDiscovery.cloud_map(service),
listeners=[appmesh.VirtualNodeListener.http(
outlier_detection=appmesh.OutlierDetection(
base_ejection_duration=Duration.seconds(10),
interval=Duration.seconds(30),
max_ejection_percent=50,
max_server_errors=5
)
)]
)
Mesh mesh;
// Cloud Map service discovery is currently required for host ejection by outlier detection
Vpc vpc = new Vpc(this, "vpc");
PrivateDnsNamespace namespace = PrivateDnsNamespace.Builder.create(this, "test-namespace")
.vpc(vpc)
.name("domain.local")
.build();
Service service = namespace.createService("Svc");
VirtualNode node = mesh.addVirtualNode("virtual-node", VirtualNodeBaseProps.builder()
.serviceDiscovery(ServiceDiscovery.cloudMap(service))
.listeners(List.of(VirtualNodeListener.http(HttpVirtualNodeListenerOptions.builder()
.outlierDetection(OutlierDetection.builder()
.baseEjectionDuration(Duration.seconds(10))
.interval(Duration.seconds(30))
.maxEjectionPercent(50)
.maxServerErrors(5)
.build())
.build())))
.build());
// Install: dotnet add package Amazon.CDK.Lib
Mesh mesh;
// Cloud Map service discovery is currently required for host ejection by outlier detection
var vpc = new Vpc(this, "vpc");
var namespace = new PrivateDnsNamespace(this, "test-namespace", new PrivateDnsNamespaceProps {
Vpc = vpc,
Name = "domain.local"
});
var service = namespace.CreateService("Svc");
var node = mesh.AddVirtualNode("virtual-node", new VirtualNodeBaseProps {
ServiceDiscovery = ServiceDiscovery.CloudMap(service),
Listeners = new [] { VirtualNodeListener.Http(new HttpVirtualNodeListenerOptions {
OutlierDetection = new OutlierDetection {
BaseEjectionDuration = Duration.Seconds(10),
Interval = Duration.Seconds(30),
MaxEjectionPercent = 50,
MaxServerErrors = 5
}
}) }
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var mesh Mesh
// Cloud Map service discovery is currently required for host ejection by outlier detection
vpc := ec2.NewVpc(this, jsii.String("vpc"))
namespace := cloudmap.NewPrivateDnsNamespace(this, jsii.String("test-namespace"), &PrivateDnsNamespaceProps{
Vpc: Vpc,
Name: jsii.String("domain.local"),
})
service := namespace.CreateService(jsii.String("Svc"))
node := mesh.addVirtualNode(jsii.String("virtual-node"), &VirtualNodeBaseProps{
ServiceDiscovery: appmesh.ServiceDiscovery_CloudMap(service),
Listeners: []VirtualNodeListener{
appmesh.VirtualNodeListener_Http(&HttpVirtualNodeListenerOptions{
OutlierDetection: &OutlierDetection{
BaseEjectionDuration: awscdk.Duration_Seconds(jsii.Number(10)),
Interval: awscdk.Duration_*Seconds(jsii.Number(30)),
MaxEjectionPercent: jsii.Number(50),
MaxServerErrors: jsii.Number(5),
},
}),
},
})
Initializer
new VirtualNode(scope: Construct, id: string, props: VirtualNodeProps)
VirtualNode(scope: Construct, id: str, props: VirtualNodeProps)
new VirtualNode(Construct scope, String id, VirtualNodeProps props)
new VirtualNode(Construct scope, string id, VirtualNodeProps props)
NewVirtualNode(Scope Construct, Id *string, Props VirtualNodeProps)
Construct Props
accessLogoptionalAccessLogaccess_logoptionalAccessLogaccessLogoptionalAccessLogAccessLogoptionalAccessLogAccessLogoptionalAccessLog#Default: No access logging
backendDefaultsoptionalBackendDefaultsbackend_defaultsoptionalBackendDefaultsbackendDefaultsoptionalBackendDefaultsBackendDefaultsoptionalBackendDefaultsBackendDefaultsoptionalBackendDefaults#Default: No Config
backendsoptionalBackend[]backendsoptionaltyping.List[Backend]backendsoptionalList<Backend>BackendsoptionalBackend[]Backendsoptional*[]Backend#Default: No backends
listenersoptionalVirtualNodeListener[]listenersoptionaltyping.List[VirtualNodeListener]listenersoptionalList<VirtualNodeListener>ListenersoptionalVirtualNodeListener[]Listenersoptional*[]VirtualNodeListener#Default: No listeners
serviceDiscoveryoptionalServiceDiscoveryservice_discoveryoptionalServiceDiscoveryserviceDiscoveryoptionalServiceDiscoveryServiceDiscoveryoptionalServiceDiscoveryServiceDiscoveryoptionalServiceDiscovery#Default: No Service Discovery
virtualNodeNameoptionalstringvirtual_node_nameoptionalstrvirtualNodeNameoptionalStringVirtualNodeNameoptionalstringVirtualNodeNameoptional*string#Default: A name is automatically determined
Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
grantsVirtualNodeGrantsgrantsVirtualNodeGrantsgrantsVirtualNodeGrantsGrantsVirtualNodeGrantsGrantsVirtualNodeGrantsrequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#virtualNodeArnstringvirtual_node_arnstrvirtualNodeArnStringVirtualNodeArnstringVirtualNodeArn*stringrequired#virtualNodeNamestringvirtual_node_namestrvirtualNodeNameStringVirtualNodeNamestringVirtualNodeName*stringrequired#virtualNodeRefVirtualNodeReferencevirtual_node_refVirtualNodeReferencevirtualNodeRefVirtualNodeReferenceVirtualNodeRefVirtualNodeReferenceVirtualNodeRefVirtualNodeReferencerequired#Methods
addBackend(backend: Backend): voiddef add_backend(self, backend: Backend) -> Nonepublic void addBackend(Backend backend)public void AddBackend(Backend backend)func AddBackend(Backend Backend)#addListener(listener: VirtualNodeListener): voiddef add_listener(self, listener: VirtualNodeListener) -> Nonepublic void addListener(VirtualNodeListener listener)public void AddListener(VirtualNodeListener listener)func AddListener(Listener VirtualNodeListener)#notes
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.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
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).
fromVirtualNodeArn(scope: Construct, id: string, virtualNodeArn: string): IVirtualNode@staticmethod def from_virtual_node_arn(scope: Construct, id: str, virtual_node_arn: str) -> IVirtualNodepublic static IVirtualNode fromVirtualNodeArn(Construct scope, String id, String virtualNodeArn)public static IVirtualNode FromVirtualNodeArn(Construct scope, string id, string virtualNodeArn)func FromVirtualNodeArn(Scope Construct, Id *string, VirtualNodeArn *string) IVirtualNodestatic#fromVirtualNodeAttributes(scope: Construct, id: string, attrs: VirtualNodeAttributes): IVirtualNode@staticmethod def from_virtual_node_attributes(scope: Construct, id: str, attrs: VirtualNodeAttributes) -> IVirtualNodepublic static IVirtualNode fromVirtualNodeAttributes(Construct scope, String id, VirtualNodeAttributes attrs)public static IVirtualNode FromVirtualNodeAttributes(Construct scope, string id, VirtualNodeAttributes attrs)func FromVirtualNodeAttributes(Scope Construct, Id *string, Attrs VirtualNodeAttributes) IVirtualNodestatic#grantStreamAggregatedResources(identity: IGrantable): Grantdef grant_stream_aggregated_resources(self, identity: IGrantable) -> Grantpublic Grant grantStreamAggregatedResources(IGrantable identity)public Grant GrantStreamAggregatedResources(IGrantable identity)func GrantStreamAggregatedResources(Identity IGrantable) Grant#[disable-awslint:no-grants]
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.