PrivateDnsNamespace L2 construct
Define a Service Discovery HTTP Namespace.
Example
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({
port: 8081,
healthCheck: appmesh.HealthCheck.http({
healthyThreshold: 3,
interval: Duration.seconds(5), // minimum
path: '/health-check-path',
timeout: Duration.seconds(2), // minimum
unhealthyThreshold: 2,
}),
})],
accessLog: appmesh.AccessLog.fromFilePath('/dev/stdout'),
});
# mesh: appmesh.Mesh
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(
port=8081,
health_check=appmesh.HealthCheck.http(
healthy_threshold=3,
interval=Duration.seconds(5), # minimum
path="/health-check-path",
timeout=Duration.seconds(2), # minimum
unhealthy_threshold=2
)
)],
access_log=appmesh.AccessLog.from_file_path("/dev/stdout")
)
Mesh mesh;
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()
.port(8081)
.healthCheck(HealthCheck.http(HttpHealthCheckOptions.builder()
.healthyThreshold(3)
.interval(Duration.seconds(5)) // minimum
.path("/health-check-path")
.timeout(Duration.seconds(2)) // minimum
.unhealthyThreshold(2)
.build()))
.build())))
.accessLog(AccessLog.fromFilePath("/dev/stdout"))
.build());
// Install: dotnet add package Amazon.CDK.Lib
Mesh mesh;
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 {
Port = 8081,
HealthCheck = HealthCheck.Http(new HttpHealthCheckOptions {
HealthyThreshold = 3,
Interval = Duration.Seconds(5), // minimum
Path = "/health-check-path",
Timeout = Duration.Seconds(2), // minimum
UnhealthyThreshold = 2
})
}) },
AccessLog = AccessLog.FromFilePath("/dev/stdout")
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var mesh Mesh
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{
Port: jsii.Number(8081),
HealthCheck: appmesh.HealthCheck_Http(&HttpHealthCheckOptions{
HealthyThreshold: jsii.Number(3),
Interval: awscdk.Duration_Seconds(jsii.Number(5)),
// minimum
Path: jsii.String("/health-check-path"),
Timeout: awscdk.Duration_*Seconds(jsii.Number(2)),
// minimum
UnhealthyThreshold: jsii.Number(2),
}),
}),
},
AccessLog: appmesh.AccessLog_FromFilePath(jsii.String("/dev/stdout")),
})
Initializer
new PrivateDnsNamespace(scope: Construct, id: string, props: PrivateDnsNamespaceProps)
PrivateDnsNamespace(scope: Construct, id: str, props: PrivateDnsNamespaceProps)
new PrivateDnsNamespace(Construct scope, String id, PrivateDnsNamespaceProps props)
new PrivateDnsNamespace(Construct scope, string id, PrivateDnsNamespaceProps props)
NewPrivateDnsNamespace(Scope Construct, Id *string, Props PrivateDnsNamespaceProps)
Construct Props
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.
namespaceHostedZoneIdstringnamespace_hosted_zone_idstrnamespaceHostedZoneIdStringNamespaceHostedZoneIdstringNamespaceHostedZoneId*stringrequired#namespaceNamestringnamespace_namestrnamespaceNameStringNamespaceNamestringNamespaceName*stringrequired#privateDnsNamespaceArnstringprivate_dns_namespace_arnstrprivateDnsNamespaceArnStringPrivateDnsNamespaceArnstringPrivateDnsNamespaceArn*stringrequired#privateDnsNamespaceIdstringprivate_dns_namespace_idstrprivateDnsNamespaceIdStringPrivateDnsNamespaceIdstringPrivateDnsNamespaceId*stringrequired#privateDnsNamespaceNamestringprivate_dns_namespace_namestrprivateDnsNamespaceNameStringPrivateDnsNamespaceNamestringPrivateDnsNamespaceName*stringrequired#privateDnsNamespaceRefPrivateDnsNamespaceReferenceprivate_dns_namespace_refPrivateDnsNamespaceReferenceprivateDnsNamespaceRefPrivateDnsNamespaceReferencePrivateDnsNamespaceRefPrivateDnsNamespaceReferencePrivateDnsNamespaceRefPrivateDnsNamespaceReferencerequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#Methods
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).
createService(id: string, props?: DnsServiceProps): Servicedef create_service(self, id: str, props: typing.Optional[DnsServiceProps] = None) -> Servicepublic Service createService(String id, DnsServiceProps props)public Service CreateService(string id, DnsServiceProps? props = null)func CreateService(Id *string, Props DnsServiceProps) Service#fromPrivateDnsNamespaceAttributes(scope: Construct, id: string, attrs: PrivateDnsNamespaceAttributes): IPrivateDnsNamespace@staticmethod def from_private_dns_namespace_attributes(scope: Construct, id: str, attrs: PrivateDnsNamespaceAttributes) -> IPrivateDnsNamespacepublic static IPrivateDnsNamespace fromPrivateDnsNamespaceAttributes(Construct scope, String id, PrivateDnsNamespaceAttributes attrs)public static IPrivateDnsNamespace FromPrivateDnsNamespaceAttributes(Construct scope, string id, PrivateDnsNamespaceAttributes attrs)func FromPrivateDnsNamespaceAttributes(Scope Construct, Id *string, Attrs PrivateDnsNamespaceAttributes) IPrivateDnsNamespacestatic#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.