Sélectionner vos préférences de cookies

Nous utilisons des cookies essentiels et des outils similaires qui sont nécessaires au fonctionnement de notre site et à la fourniture de nos services. Nous utilisons des cookies de performance pour collecter des statistiques anonymes afin de comprendre comment les clients utilisent notre site et d’apporter des améliorations. Les cookies essentiels ne peuvent pas être désactivés, mais vous pouvez cliquer sur « Personnaliser » ou « Refuser » pour refuser les cookies de performance.

Si vous êtes d’accord, AWS et les tiers approuvés utiliseront également des cookies pour fournir des fonctionnalités utiles au site, mémoriser vos préférences et afficher du contenu pertinent, y compris des publicités pertinentes. Pour accepter ou refuser tous les cookies non essentiels, cliquez sur « Accepter » ou « Refuser ». Pour effectuer des choix plus détaillés, cliquez sur « Personnaliser ».

AWS::ServiceDiscovery::Service

Mode de mise au point

Sur cette page

AWS::ServiceDiscovery::Service - AWS CloudFormation
Cette page n'a pas été traduite dans votre langue. Demande de traduction
Filtrer la vue

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, "ServiceAttributes" : Json, "Tags" : [ Tag, ... ], "Type" : String } }

YAML

Type: AWS::ServiceDiscovery::Service Properties: Description: String DnsConfig: DnsConfig HealthCheckConfig: HealthCheckConfig HealthCheckCustomConfig: HealthCheckCustomConfig Name: String NamespaceId: String ServiceAttributes: Json 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

ServiceAttributes

A string map that contains the following information for the service:

  • The attributes that apply to the service

  • For each attribute, the applicable value.

You can specify a total of 30 attributes.

Required: No

Type: Json

Update requires: No interruption

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

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

Rubrique suivante :

DnsConfig

Rubrique précédente :

Tag
ConfidentialitéConditions d'utilisation du sitePréférences de cookies
© 2025, Amazon Web Services, Inc. ou ses affiliés. Tous droits réservés.