VirtualGateway L2 construct
VirtualGateway represents a newly defined App Mesh Virtual Gateway.
A virtual gateway allows resources that are outside of your mesh to communicate to resources that are inside of your mesh.
Example
// A Virtual Node with a gRPC listener with a connection pool set
declare const mesh: appmesh.Mesh;
const node = new appmesh.VirtualNode(this, 'node', {
mesh,
// DNS service discovery can optionally specify the DNS response type as either LOAD_BALANCER or ENDPOINTS.
// LOAD_BALANCER means that the DNS resolver returns a loadbalanced set of endpoints,
// whereas ENDPOINTS means that the DNS resolver is returning all the endpoints.
// By default, the response type is assumed to be LOAD_BALANCER
serviceDiscovery: appmesh.ServiceDiscovery.dns('node', appmesh.DnsResponseType.ENDPOINTS),
listeners: [appmesh.VirtualNodeListener.http({
port: 80,
connectionPool: {
maxConnections: 100,
maxPendingRequests: 10,
},
})],
});
// A Virtual Gateway with a gRPC listener with a connection pool set
const gateway = new appmesh.VirtualGateway(this, 'gateway', {
mesh,
listeners: [appmesh.VirtualGatewayListener.grpc({
port: 8080,
connectionPool: {
maxRequests: 10,
},
})],
virtualGatewayName: 'gateway',
});
# A Virtual Node with a gRPC listener with a connection pool set
# mesh: appmesh.Mesh
node = appmesh.VirtualNode(self, "node",
mesh=mesh,
# DNS service discovery can optionally specify the DNS response type as either LOAD_BALANCER or ENDPOINTS.
# LOAD_BALANCER means that the DNS resolver returns a loadbalanced set of endpoints,
# whereas ENDPOINTS means that the DNS resolver is returning all the endpoints.
# By default, the response type is assumed to be LOAD_BALANCER
service_discovery=appmesh.ServiceDiscovery.dns("node", appmesh.DnsResponseType.ENDPOINTS),
listeners=[appmesh.VirtualNodeListener.http(
port=80,
connection_pool=appmesh.HttpConnectionPool(
max_connections=100,
max_pending_requests=10
)
)]
)
# A Virtual Gateway with a gRPC listener with a connection pool set
gateway = appmesh.VirtualGateway(self, "gateway",
mesh=mesh,
listeners=[appmesh.VirtualGatewayListener.grpc(
port=8080,
connection_pool=appmesh.GrpcConnectionPool(
max_requests=10
)
)],
virtual_gateway_name="gateway"
)
// A Virtual Node with a gRPC listener with a connection pool set
Mesh mesh;
VirtualNode node = VirtualNode.Builder.create(this, "node")
.mesh(mesh)
// DNS service discovery can optionally specify the DNS response type as either LOAD_BALANCER or ENDPOINTS.
// LOAD_BALANCER means that the DNS resolver returns a loadbalanced set of endpoints,
// whereas ENDPOINTS means that the DNS resolver is returning all the endpoints.
// By default, the response type is assumed to be LOAD_BALANCER
.serviceDiscovery(ServiceDiscovery.dns("node", DnsResponseType.ENDPOINTS))
.listeners(List.of(VirtualNodeListener.http(HttpVirtualNodeListenerOptions.builder()
.port(80)
.connectionPool(HttpConnectionPool.builder()
.maxConnections(100)
.maxPendingRequests(10)
.build())
.build())))
.build();
// A Virtual Gateway with a gRPC listener with a connection pool set
VirtualGateway gateway = VirtualGateway.Builder.create(this, "gateway")
.mesh(mesh)
.listeners(List.of(VirtualGatewayListener.grpc(GrpcGatewayListenerOptions.builder()
.port(8080)
.connectionPool(GrpcConnectionPool.builder()
.maxRequests(10)
.build())
.build())))
.virtualGatewayName("gateway")
.build();
// Install: dotnet add package Amazon.CDK.Lib
// A Virtual Node with a gRPC listener with a connection pool set
Mesh mesh;
var node = new VirtualNode(this, "node", new VirtualNodeProps {
Mesh = mesh,
// DNS service discovery can optionally specify the DNS response type as either LOAD_BALANCER or ENDPOINTS.
// LOAD_BALANCER means that the DNS resolver returns a loadbalanced set of endpoints,
// whereas ENDPOINTS means that the DNS resolver is returning all the endpoints.
// By default, the response type is assumed to be LOAD_BALANCER
ServiceDiscovery = ServiceDiscovery.Dns("node", DnsResponseType.ENDPOINTS),
Listeners = new [] { VirtualNodeListener.Http(new HttpVirtualNodeListenerOptions {
Port = 80,
ConnectionPool = new HttpConnectionPool {
MaxConnections = 100,
MaxPendingRequests = 10
}
}) }
});
// A Virtual Gateway with a gRPC listener with a connection pool set
var gateway = new VirtualGateway(this, "gateway", new VirtualGatewayProps {
Mesh = mesh,
Listeners = new [] { VirtualGatewayListener.Grpc(new GrpcGatewayListenerOptions {
Port = 8080,
ConnectionPool = new GrpcConnectionPool {
MaxRequests = 10
}
}) },
VirtualGatewayName = "gateway"
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// A Virtual Node with a gRPC listener with a connection pool set
var mesh Mesh
node := appmesh.NewVirtualNode(this, jsii.String("node"), &VirtualNodeProps{
Mesh: Mesh,
// DNS service discovery can optionally specify the DNS response type as either LOAD_BALANCER or ENDPOINTS.
// LOAD_BALANCER means that the DNS resolver returns a loadbalanced set of endpoints,
// whereas ENDPOINTS means that the DNS resolver is returning all the endpoints.
// By default, the response type is assumed to be LOAD_BALANCER
ServiceDiscovery: appmesh.ServiceDiscovery_Dns(jsii.String("node"), appmesh.DnsResponseType_ENDPOINTS),
Listeners: []VirtualNodeListener{
appmesh.VirtualNodeListener_Http(&HttpVirtualNodeListenerOptions{
Port: jsii.Number(80),
ConnectionPool: &HttpConnectionPool{
MaxConnections: jsii.Number(100),
MaxPendingRequests: jsii.Number(10),
},
}),
},
})
// A Virtual Gateway with a gRPC listener with a connection pool set
gateway := appmesh.NewVirtualGateway(this, jsii.String("gateway"), &VirtualGatewayProps{
Mesh: Mesh,
Listeners: []VirtualGatewayListener{
appmesh.VirtualGatewayListener_Grpc(&GrpcGatewayListenerOptions{
Port: jsii.Number(8080),
ConnectionPool: &GrpcConnectionPool{
MaxRequests: jsii.Number(10),
},
}),
},
VirtualGatewayName: jsii.String("gateway"),
})
Initializer
new VirtualGateway(scope: Construct, id: string, props: VirtualGatewayProps)
VirtualGateway(scope: Construct, id: str, props: VirtualGatewayProps)
new VirtualGateway(Construct scope, String id, VirtualGatewayProps props)
new VirtualGateway(Construct scope, string id, VirtualGatewayProps props)
NewVirtualGateway(Scope Construct, Id *string, Props VirtualGatewayProps)
Construct Props
accessLogAccessLogaccess_logAccessLogaccessLogAccessLogAccessLogAccessLogAccessLogAccessLog= no access logging#backendDefaultsBackendDefaultsbackend_defaultsBackendDefaultsbackendDefaultsBackendDefaultsBackendDefaultsBackendDefaultsBackendDefaultsBackendDefaults= No Config#listenersVirtualGatewayListener[]listenerstyping.List[VirtualGatewayListener]listenersList<VirtualGatewayListener>ListenersVirtualGatewayListener[]Listeners*[]VirtualGatewayListener= Single HTTP listener on port 808…#Only one is supported.
default
Default: Single HTTP listener on port 8080
virtualGatewayNamestringvirtual_gateway_namestrvirtualGatewayNameStringVirtualGatewayNamestringVirtualGatewayName*string= A name is automatically determin…#default
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.
grantsVirtualGatewayGrantsgrantsVirtualGatewayGrantsgrantsVirtualGatewayGrantsGrantsVirtualGatewayGrantsGrantsVirtualGatewayGrantsrequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#virtualGatewayArnstringvirtual_gateway_arnstrvirtualGatewayArnStringVirtualGatewayArnstringVirtualGatewayArn*stringrequired#virtualGatewayNamestringvirtual_gateway_namestrvirtualGatewayNameStringVirtualGatewayNamestringVirtualGatewayName*stringrequired#virtualGatewayRefVirtualGatewayReferencevirtual_gateway_refVirtualGatewayReferencevirtualGatewayRefVirtualGatewayReferenceVirtualGatewayRefVirtualGatewayReferenceVirtualGatewayRefVirtualGatewayReferencerequired#Methods
addGatewayRoute(id: string, props: GatewayRouteBaseProps): GatewayRoutedef add_gateway_route(self, id: str, props: GatewayRouteBaseProps) -> GatewayRoutepublic GatewayRoute addGatewayRoute(String id, GatewayRouteBaseProps props)public GatewayRoute AddGatewayRoute(string id, GatewayRouteBaseProps props)func AddGatewayRoute(Id *string, Props GatewayRouteBaseProps) GatewayRoute#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).
fromVirtualGatewayArn(scope: Construct, id: string, virtualGatewayArn: string): IVirtualGateway@staticmethod def from_virtual_gateway_arn(scope: Construct, id: str, virtual_gateway_arn: str) -> IVirtualGatewaypublic static IVirtualGateway fromVirtualGatewayArn(Construct scope, String id, String virtualGatewayArn)public static IVirtualGateway FromVirtualGatewayArn(Construct scope, string id, string virtualGatewayArn)func FromVirtualGatewayArn(Scope Construct, Id *string, VirtualGatewayArn *string) IVirtualGatewaystatic#fromVirtualGatewayAttributes(scope: Construct, id: string, attrs: VirtualGatewayAttributes): IVirtualGateway@staticmethod def from_virtual_gateway_attributes(scope: Construct, id: str, attrs: VirtualGatewayAttributes) -> IVirtualGatewaypublic static IVirtualGateway fromVirtualGatewayAttributes(Construct scope, String id, VirtualGatewayAttributes attrs)public static IVirtualGateway FromVirtualGatewayAttributes(Construct scope, string id, VirtualGatewayAttributes attrs)func FromVirtualGatewayAttributes(Scope Construct, Id *string, Attrs VirtualGatewayAttributes) IVirtualGatewaystatic#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.