This is the new AWS CloudFormation Template Reference Guide. Please update your bookmarks and links. For help getting started with CloudFormation, see the AWS CloudFormation User Guide.
AWS::ServiceDiscovery::Service
A complex type that contains information about the specified service.
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, "ServiceAttributes" :Json, "Tags" :[ Tag, ... ], "Type" :String} }
YAML
Type: AWS::ServiceDiscovery::Service Properties: Description:StringDnsConfig:DnsConfigHealthCheckConfig:HealthCheckConfigHealthCheckCustomConfig:HealthCheckCustomConfigName:StringNamespaceId:StringServiceAttributes:JsonTags:- TagType:String
Properties
Description-
The description of the service.
Required: No
Type: String
Maximum:
1024Update 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
HealthCheckCustomConfigorHealthCheckConfigbut 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 or Amazon Resource Name (ARN) of the namespace that you want to use to create the service. For namespaces shared with your AWS account, specify the namespace ARN. For more information about shared namespaces, see Cross-account AWS Cloud Map namespace sharing in the AWS Cloud Map Developer Guide.
Required: No
Type: String
Maximum:
255Update requires: Replacement
ServiceAttributes-
A complex type that contains information about attributes associated with a specific service.
Required: No
Type: Json
Update requires: No interruption
-
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:
0Maximum:
200Update requires: Updates are not supported.
Type-
If present, specifies that the service instances are only discoverable using the
DiscoverInstancesAPI operation. No DNS records is registered for the service instances. The only valid value isHTTP.Required: No
Type: String
Allowed values:
HTTPUpdate 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
Specify attributes at the service level
This example specifies the port that the client application should use to communicate with the service, as a service attribute. The example also specifies the service revision and that 100% of traffic should be directed to the revision.
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" }, "ServiceAttributes": { "Port": "8080", "Weight": "{'revision-A': '100'}" }, "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 ServiceAttributes: Port: 8080 Weight: {'revision-A': '100'} Name: example-public-DNS-service NamespaceId: ns-e4anhexample0004
See also
-
CreateService in the AWS Cloud Map API Reference