AWS::ServiceDiscovery::Service - AWS CloudFormation


A complex type that contains information about a service, which defines the configuration of 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


To declare this entity in your AWS CloudFormation template, use the following syntax:


{ "Type" : "AWS::ServiceDiscovery::Service", "Properties" : { "Description" : String, "DnsConfig" : DnsConfig, "HealthCheckConfig" : HealthCheckConfig, "HealthCheckCustomConfig" : HealthCheckCustomConfig, "Name" : String, "NamespaceId" : String, "Tags" : [ Tag, ... ] } }


Type: AWS::ServiceDiscovery::Service Properties: Description: String DnsConfig: DnsConfig HealthCheckConfig: HealthCheckConfig HealthCheckCustomConfig: HealthCheckCustomConfig Name: String NamespaceId: String Tags: - Tag



The description of the service.

Required: No

Type: String

Maximum: 1024

Update requires: No interruption


A complex type that contains information about the Route 53 DNS records that you want AWS Cloud Map to create when you register an instance.

Required: No

Type: DnsConfig

Update requires: No interruption


Public DNS and HTTP namespaces only. A complex type that contains settings for an optional health check. If you specify settings for a health check, AWS Cloud Map associates the health check with the records that you specify in DnsConfig.

For information about the charges for health checks, see Amazon Route 53 Pricing.

Required: No

Type: HealthCheckConfig

Update requires: No interruption


A complex type that contains information about an optional custom health check.


If you specify a health check configuration, you can specify either HealthCheckCustomConfig or HealthCheckConfig but not both.

Required: No

Type: HealthCheckCustomConfig

Update requires: Replacement


The name of the service.

Required: No

Type: String

Pattern: ((?=^.{1,127}$)^([a-zA-Z0-9_][a-zA-Z0-9-_]{0,61}[a-zA-Z0-9_]|[a-zA-Z0-9])(\.([a-zA-Z0-9_][a-zA-Z0-9-_]{0,61}[a-zA-Z0-9_]|[a-zA-Z0-9]))*$)|(^\.$)

Update requires: Replacement


The ID of the namespace that was used to create the service.


You must specify a value for NamespaceId either for the service properties or for DnsConfig. Don't specify a value in both places.

Required: No

Type: String

Maximum: 64

Update requires: Replacement


The tags for the service. Each tag consists of a key and an optional value, both of which you define. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.

Required: No

Type: List of Tag

Maximum: 200

Update requires: Updates are not supported.

Return values


When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the value of Id for the service, such as srv-e4anhexample0004.

For more information about using the Ref function, see Ref.


The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.


The Amazon Resource Name (ARN) of the service.


The ID of the service.


The name that you assigned to the service.


Create a service

The following example creates a service based on a public DNS namespace. The service includes settings for Amazon Route 53 A and AAAA records that have a routing policy of WEIGHTED. It also includes a Route 53 health check.


{ "Type" : "AWS::ServiceDiscovery::Service", "Properties" : { "Description" : "Service based on a public DNS namespace", "DnsConfig" : { "DnsRecords" : [ { "Type" : "A", "TTL" : 60 }, { "Type" : "AAAA", "TTL" : 60 } ], "RoutingPolicy" : "WEIGHTED" }, "HealthCheckConfig" : { "FailureThreshold" : 3, "ResourcePath" : "/", "Type" : "HTTPS" }, "Name" : "example-public-DNS-service", "NamespaceId" : "ns-e4anhexample0004" } }


Type: 'AWS::ServiceDiscovery::Service' Properties: Description: Service based on a public DNS namespace DnsConfig: DnsRecords: - Type: A TTL: 60 - Type: AAAA TTL: 60 RoutingPolicy: WEIGHTED HealthCheckConfig: FailureThreshold: 3 ResourcePath: / Type: HTTPS Name: example-public-DNS-service NamespaceId: ns-e4anhexample0004

See also