Skip to content

PrivateDnsNamespace

Source: src/AWS/CloudMap/PrivateDnsNamespace.ts

An AWS Cloud Map private DNS namespace — the DNS-based service registry that ECS Service Connect and serviceRegistries point at. Services registered in the namespace are discoverable inside the associated VPC via DNS ({service}.{namespace}) and from anywhere via the DiscoverInstances API.

Namespace creation and deletion are asynchronous — the provider polls the Cloud Map operations API (bounded) until they complete, which typically takes 30-60 seconds.

Private DNS Namespace in a VPC

import * as AWS from "alchemy/AWS";
const vpc = yield* AWS.EC2.Vpc("AppVpc", { cidrBlock: "10.0.0.0/16" });
const namespace = yield* AWS.CloudMap.PrivateDnsNamespace("AppNamespace", {
name: "internal.example.com",
vpc: vpc.vpcId,
});

Namespace with SOA TTL and Description

const namespace = yield* AWS.CloudMap.PrivateDnsNamespace("AppNamespace", {
name: "internal.example.com",
vpc: vpc.vpcId,
description: "service discovery for the app tier",
ttl: "60 seconds",
});
const service = yield* AWS.CloudMap.Service("Backend", {
namespaceId: namespace.namespaceId,
dnsRecords: [{ type: "A", ttl: "10 seconds" }],
routingPolicy: "MULTIVALUE",
});