updateService
Submits a request to perform the following operations:
Update the TTL setting for existing
DnsRecords
configurationsAdd, update, or delete
HealthCheckConfig
for a specified serviceYou can't add, update, or delete aHealthCheckCustomConfig
configuration.
For public and private DNS namespaces, note the following:
If you omit any existing
DnsRecords
orHealthCheckConfig
configurations from anUpdateService
request, the configurations are deleted from the service.If you omit an existing
HealthCheckCustomConfig
configuration from anUpdateService
request, the configuration isn't deleted from the service.
You can't call UpdateService
and update settings in the following scenarios:
When the service is associated with an HTTP namespace
When the service is associated with a shared namespace and contains instances that were registered by Amazon Web Services accounts other than the account making the
UpdateService
call When you update settings for a service, Cloud Map also updates the corresponding settings in all the records and health checks that were created by using the specified service.
Samples
import aws.sdk.kotlin.services.servicediscovery.model.DnsConfigChange
import aws.sdk.kotlin.services.servicediscovery.model.DnsRecord
import aws.sdk.kotlin.services.servicediscovery.model.HealthCheckConfig
import aws.sdk.kotlin.services.servicediscovery.model.HealthCheckType
import aws.sdk.kotlin.services.servicediscovery.model.RecordType
import aws.sdk.kotlin.services.servicediscovery.model.ServiceChange
fun main() {
//sampleStart
// This example submits a request to replace the DnsConfig and HealthCheckConfig settings of a
// specified service.
val resp = serviceDiscoveryClient.updateService {
id = "srv-e4anhexample0004"
service = ServiceChange {
healthCheckConfig = HealthCheckConfig {
type = HealthCheckType.fromValue("HTTP")
resourcePath = "/"
failureThreshold = 2
}
dnsConfig = DnsConfigChange {
dnsRecords = listOf<DnsRecord>(
DnsRecord {
type = RecordType.fromValue("A")
ttl = 60
}
)
}
}
}
//sampleEnd
}
import aws.sdk.kotlin.services.servicediscovery.model.DnsConfigChange
import aws.sdk.kotlin.services.servicediscovery.model.DnsRecord
import aws.sdk.kotlin.services.servicediscovery.model.HealthCheckConfig
import aws.sdk.kotlin.services.servicediscovery.model.HealthCheckType
import aws.sdk.kotlin.services.servicediscovery.model.RecordType
import aws.sdk.kotlin.services.servicediscovery.model.ServiceChange
fun main() {
//sampleStart
// This example updates a service using a service ARN instead of service ID. This is useful for
// updating services associated with shared namespaces.
val resp = serviceDiscoveryClient.updateService {
id = "arn:aws:servicediscovery:us-west-2:123456789012:service/srv-e4anhexample0004"
service = ServiceChange {
description = "Updated service description for shared namespace"
}
}
//sampleEnd
}