AWS::ServiceDiscovery::Service - AWS CloudFormation

AWS::ServiceDiscovery::Service

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

Syntax

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

JSON

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

YAML

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

Properties

Description

The description of the service.

Required: No

Type: String

Maximum: 1024

Update requires: No interruption

DnsConfig

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.

Important

The record types of a service can only be changed by deleting the service and recreating it with a new Dnsconfig.

Required: No

Type: DnsConfig

Update requires: No interruption

HealthCheckConfig

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

HealthCheckCustomConfig

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

Important

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

Required: No

Type: HealthCheckCustomConfig

Update requires: Replacement

Name

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

NamespaceId

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

Important

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

Tags

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: Array of Tag

Minimum: 0

Maximum: 200

Update requires: Updates are not supported.

Type

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

Required: No

Type: String

Allowed values: HTTP

Update requires: Replacement

Return values

Ref

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.

Fn::GetAtt

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.

Arn

The Amazon Resource Name (ARN) of the service.

Id

The ID of the service.

Name

The name that you assigned to the service.

Examples

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.

JSON

{ "Resources": { "Service": { "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" } } } }

YAML

Resources: Service: 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