createService

Creates a service. This action defines the configuration for the following entities:

  • For public and private DNS namespaces, one of the following combinations of DNS records in Amazon Route 53:

    • A

    • AAAA

    • A and AAAA

    • SRV

    • CNAME

  • Optionally, a health check

After you create the service, you can submit a RegisterInstance request, and Cloud Map uses the values in the configuration to create the specified entities.

For the current quota on the number of instances that you can register using the same namespace and using the same service, see Cloud Map quotas in the Cloud Map Developer Guide.

Samples

import aws.sdk.kotlin.services.servicediscovery.model.DnsConfig
import aws.sdk.kotlin.services.servicediscovery.model.DnsRecord
import aws.sdk.kotlin.services.servicediscovery.model.RecordType
import aws.sdk.kotlin.services.servicediscovery.model.RoutingPolicy
fun main() { 
   //sampleStart 
   // Example Create service
val resp = serviceDiscoveryClient.createService {
    name = "myservice"
    namespaceId = "ns-ylexjili4cdxy3xm"
    dnsConfig = DnsConfig {
        namespaceId = "ns-ylexjili4cdxy3xm"
        routingPolicy = RoutingPolicy.fromValue("MULTIVALUE")
        dnsRecords = listOf<DnsRecord>(
            DnsRecord {
                type = RecordType.fromValue("A")
                ttl = 60
            }                
        )
    }
    creatorRequestId = "567c1193-6b00-4308-bd57-ad38a8822d25"
} 
   //sampleEnd
}