Service
Source:
src/AWS/CloudMap/Service.ts
An AWS Cloud Map service — a named entry in a namespace that instances
register against. For DNS namespaces, Cloud Map creates the configured DNS
records per registered instance; every service is also queryable via the
DiscoverInstances API. This is what ECS serviceRegistries[].registryArn
consumes.
Creating Services
Section titled “Creating Services”DNS Service with A Records
import * as AWS from "alchemy/AWS";
const namespace = yield* AWS.CloudMap.PrivateDnsNamespace("AppNamespace", { name: "internal.example.com", vpc: vpc.vpcId,});
const service = yield* AWS.CloudMap.Service("Backend", { namespaceId: namespace.namespaceId, dnsRecords: [{ type: "A", ttl: "10 seconds" }], routingPolicy: "MULTIVALUE",});API-only Service in an HTTP Namespace
const namespace = yield* AWS.CloudMap.HttpNamespace("AppNamespace");const service = yield* AWS.CloudMap.Service("Backend", { namespaceId: namespace.namespaceId,});Service with Custom Health Checks
const service = yield* AWS.CloudMap.Service("Backend", { namespaceId: namespace.namespaceId, dnsRecords: [{ type: "SRV", ttl: "10 seconds" }], healthCheckCustomConfig: {},});Service with Custom Attributes
const service = yield* AWS.CloudMap.Service("Backend", { namespaceId: namespace.namespaceId, attributes: { tier: "backend", version: "2" },});Discovering Instances
Section titled “Discovering Instances”// initconst discover = yield* AWS.CloudMap.DiscoverInstances(service);
// runtimeconst { Instances } = yield* discover({ HealthStatus: "HEALTHY" });