Skip to content
GitHubXDiscordRSS

Service

Learn how to create, update, and manage AWS ServiceDiscovery Services using Alchemy Cloud Control.

The Service resource lets you manage AWS ServiceDiscovery Services for discovering and connecting to your application resources.

Create a basic service with required properties and a common optional property for DNS configuration.

import AWS from "alchemy/aws/control";
const basicService = await AWS.ServiceDiscovery.Service("basicService", {
name: "myService",
type: "HTTP",
namespaceId: "ns-123456",
dnsConfig: {
namespaceId: "ns-123456",
routingPolicy: "MULTIVALUE",
dnsRecords: [
{
type: "A",
ttl: 60
}
]
}
});

Configure a service with health check settings and custom attributes for enhanced monitoring.

const advancedService = await AWS.ServiceDiscovery.Service("advancedService", {
name: "advancedService",
type: "HTTP",
namespaceId: "ns-123456",
healthCheckConfig: {
type: "HTTP",
resourcePath: "/health",
failureThreshold: 3
},
serviceAttributes: {
"customAttr1": "value1",
"customAttr2": "value2"
}
});

Create a service that specifies a custom health check configuration to monitor application health.

const customHealthCheckService = await AWS.ServiceDiscovery.Service("customHealthCheckService", {
name: "customHealthService",
type: "HTTP",
namespaceId: "ns-123456",
healthCheckCustomConfig: {
failureThreshold: 2,
healthyThreshold: 3
},
dnsConfig: {
namespaceId: "ns-123456",
routingPolicy: "WEIGHTED",
dnsRecords: [
{
type: "A",
ttl: 60
}
]
}
});

Create a service and add tags for better resource organization and management.

const taggedService = await AWS.ServiceDiscovery.Service("taggedService", {
name: "taggedService",
type: "HTTP",
namespaceId: "ns-123456",
tags: [
{
key: "Environment",
value: "Production"
},
{
key: "Team",
value: "Engineering"
}
]
});