v1

latestOpenAPI 3.0.0Apache 2.0 License2026-07-1426158150.9 KB

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.

post/#X-Amz-Target=Route53AutoNaming_v20170314.CreateService

Headers

X-Amz-Target'Route53AutoNaming_v20170314.CreateService' required

Request body

Namestring required
<p>The name that you want to assign to the service.</p> <note> <p>Do not include sensitive information in the name if the namespace is discoverable by public DNS queries.</p> </note> <p>If you want Cloud Map to create an <code>SRV</code> record when you register an instance and you're using a system that requires a specific <code>SRV</code> format, such as <a href="http://www.haproxy.org/">HAProxy</a>, specify the following for <code>Name</code>:</p> <ul> <li> <p>Start the name with an underscore (_), such as <code>_exampleservice</code>.</p> </li> <li> <p>End the name with <i>._protocol</i>, such as <code>._tcp</code>.</p> </li> </ul> <p>When you register an instance, Cloud Map creates an <code>SRV</code> record and assigns a name to the record by concatenating the service name and the namespace name (for example,</p> <p> <code>_exampleservice._tcp.example.com</code>).</p> <note> <p>For services that are accessible by DNS queries, you can't create multiple services with names that differ only by case (such as EXAMPLE and example). Otherwise, these services have the same DNS name and can't be distinguished. However, if you use a namespace that's only accessible by API calls, then you can create services that with names that differ only by case.</p> </note>
NamespaceIdstring

The ID of the namespace that you want to use to create the service. The namespace ID must be specified, but it can be specified either here or in the <code>DnsConfig</code> object.

CreatorRequestIdstring

A unique string that identifies the request and that allows failed <code>CreateService</code> requests to be retried without the risk of running the operation twice. <code>CreatorRequestId</code> can be any unique string (for example, a date/timestamp).

Descriptionstring

A description for the service.

Type'HTTP'

If present, specifies that the service instances are only discoverable using the <code>DiscoverInstances</code> API operation. No DNS records is registered for the service instances. The only valid value is <code>HTTP</code>.

Response

Success

Example response

{
  "Service": {
    "Arn": "arn:aws:servicediscovery:us-west-2:123456789012:service/srv-p5zdwlg5uvvzjita",
    "CreateDate": 1587081768.334,
    "CreatorRequestId": "567c1193-6b00-4308-bd57-ad38a8822d25",
    "DnsConfig": {
      "DnsRecords": [
        {
          "TTL": 60,
          "Type": "A"
        }
      ],
      "NamespaceId": "ns-ylexjili4cdxy3xm",
      "RoutingPolicy": "MULTIVALUE"
    },
    "Id": "srv-p5zdwlg5uvvzjita",
    "Name": "myservice",
    "NamespaceId": "ns-ylexjili4cdxy3xm"
  }
}