createService method
- required String name,
- String? creatorRequestId,
- String? description,
- DnsConfig? dnsConfig,
- HealthCheckConfig? healthCheckConfig,
- HealthCheckCustomConfig? healthCheckCustomConfig,
- String? namespaceId,
- List<
Tag> ? tags,
Creates a service, which 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
andAAAA
-
SRV
-
CNAME
-
- Optionally, a health check
For the current quota on the number of instances that you can register using the same namespace and using the same service, see AWS Cloud Map Limits in the AWS Cloud Map Developer Guide.
May throw InvalidInput. May throw ResourceLimitExceeded. May throw NamespaceNotFound. May throw ServiceAlreadyExists. May throw TooManyTagsException.
Parameter name
:
The name that you want to assign to the service.
If you want AWS Cloud Map to create an SRV
record when you
register an instance, and if you're using a system that requires a
specific SRV
format, such as HAProxy, specify the following for
Name
:
-
Start the name with an underscore (_), such as
_exampleservice
-
End the name with ._protocol, such as
._tcp
SRV
record and assigns a name to the record by concatenating the service name
and the namespace name, for example:
_exampleservice._tcp.example.com
Parameter creatorRequestId
:
A unique string that identifies the request and that allows failed
CreateService
requests to be retried without the risk of
executing the operation twice. CreatorRequestId
can be any
unique string, for example, a date/time stamp.
Parameter description
:
A description for the service.
Parameter dnsConfig
:
A complex type that contains information about the Amazon Route 53 records
that you want AWS Cloud Map to create when you register an instance.
Parameter healthCheckConfig
:
Public DNS and HTTP namespaces only. A complex type that contains
settings for an optional Route 53 health check. If you specify settings
for a health check, AWS Cloud Map associates the health check with all the
Route 53 DNS records that you specify in DnsConfig
.
For information about the charges for health checks, see AWS Cloud Map Pricing.
Parameter healthCheckCustomConfig
:
A complex type that contains information about an optional custom health
check.
You can't add, update, or delete a HealthCheckCustomConfig
configuration from an existing service.
Parameter namespaceId
:
The ID of the namespace that you want to use to create the service.
Parameter tags
:
The tags to add to 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.
Implementation
Future<CreateServiceResponse> createService({
required String name,
String? creatorRequestId,
String? description,
DnsConfig? dnsConfig,
HealthCheckConfig? healthCheckConfig,
HealthCheckCustomConfig? healthCheckCustomConfig,
String? namespaceId,
List<Tag>? tags,
}) async {
ArgumentError.checkNotNull(name, 'name');
_s.validateStringLength(
'creatorRequestId',
creatorRequestId,
0,
64,
);
_s.validateStringLength(
'description',
description,
0,
1024,
);
_s.validateStringLength(
'namespaceId',
namespaceId,
0,
64,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Route53AutoNaming_v20170314.CreateService'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'Name': name,
'CreatorRequestId': creatorRequestId ?? _s.generateIdempotencyToken(),
if (description != null) 'Description': description,
if (dnsConfig != null) 'DnsConfig': dnsConfig,
if (healthCheckConfig != null) 'HealthCheckConfig': healthCheckConfig,
if (healthCheckCustomConfig != null)
'HealthCheckCustomConfig': healthCheckCustomConfig,
if (namespaceId != null) 'NamespaceId': namespaceId,
if (tags != null) 'Tags': tags,
},
);
return CreateServiceResponse.fromJson(jsonResponse.body);
}