You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::ServiceDiscovery::Client

Inherits:
Seahorse::Client::Base show all
Defined in:
(unknown)

Overview

An API client for AWS Cloud Map. To construct a client, you need to configure a :region and :credentials.

servicediscovery = Aws::ServiceDiscovery::Client.new(
  region: region_name,
  credentials: credentials,
  # ...
)

See #initialize for a full list of supported configuration options.

Region

You can configure a default region in the following locations:

  • ENV['AWS_REGION']
  • Aws.config[:region]

Go here for a list of supported regions.

Credentials

Default credentials are loaded automatically from the following locations:

  • ENV['AWS_ACCESS_KEY_ID'] and ENV['AWS_SECRET_ACCESS_KEY']
  • Aws.config[:credentials]
  • The shared credentials ini file at ~/.aws/credentials (more information)
  • From an instance profile when running on EC2

You can also construct a credentials object from one of the following classes:

Alternatively, you configure credentials with :access_key_id and :secret_access_key:

# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))

Aws::ServiceDiscovery::Client.new(
  access_key_id: creds['access_key_id'],
  secret_access_key: creds['secret_access_key']
)

Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Base

#config, #handlers

Constructor collapse

API Operations collapse

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Base

add_plugin, api, #build_request, clear_plugins, define, new, #operation, #operation_names, plugins, remove_plugin, set_api, set_plugins

Methods included from Seahorse::Client::HandlerBuilder

#handle, #handle_request, #handle_response

Constructor Details

#initialize(options = {}) ⇒ Aws::ServiceDiscovery::Client

Constructs an API client.

Options Hash (options):

  • :access_key_id (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :active_endpoint_cache (Boolean)

    When set to true, a thread polling for endpoints will be running in the background every 60 secs (default). Defaults to false. See Plugins::EndpointDiscovery for more details.

  • :convert_params (Boolean) — default: true

    When true, an attempt is made to coerce request parameters into the required types. See Plugins::ParamConverter for more details.

  • :credentials (required, Credentials)

    Your AWS credentials. The following locations will be searched in order for credentials:

    • :access_key_id, :secret_access_key, and :session_token options
    • ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
    • HOME/.aws/credentials shared credentials file
    • EC2 instance profile credentials See Plugins::RequestSigner for more details.
  • :disable_host_prefix_injection (Boolean)

    Set to true to disable SDK automatically adding host prefix to default service endpoint when available. See Plugins::EndpointPattern for more details.

  • :endpoint (String)

    A default endpoint is constructed from the :region. See Plugins::RegionalEndpoint for more details.

  • :endpoint_cache_max_entries (Integer)

    Used for the maximum size limit of the LRU cache storing endpoints data for endpoint discovery enabled operations. Defaults to 1000. See Plugins::EndpointDiscovery for more details.

  • :endpoint_cache_max_threads (Integer)

    Used for the maximum threads in use for polling endpoints to be cached, defaults to 10. See Plugins::EndpointDiscovery for more details.

  • :endpoint_cache_poll_interval (Integer)

    When :endpoint_discovery and :active_endpoint_cache is enabled, Use this option to config the time interval in seconds for making requests fetching endpoints information. Defaults to 60 sec. See Plugins::EndpointDiscovery for more details.

  • :endpoint_discovery (Boolean)

    When set to true, endpoint discovery will be enabled for operations when available. Defaults to false. See Plugins::EndpointDiscovery for more details.

  • :http_continue_timeout (Float) — default: 1

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_idle_timeout (Integer) — default: 5

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_open_timeout (Integer) — default: 15

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_proxy (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_read_timeout (Integer) — default: 60

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_wire_trace (Boolean) — default: false

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :log_level (Symbol) — default: :info

    The log level to send messages to the logger at. See Plugins::Logging for more details.

  • :log_formatter (Logging::LogFormatter)

    The log formatter. Defaults to Seahorse::Client::Logging::Formatter.default. See Plugins::Logging for more details.

  • :logger (Logger) — default: nil

    The Logger instance to send log messages to. If this option is not set, logging will be disabled. See Plugins::Logging for more details.

  • :profile (String)

    Used when loading credentials from the shared credentials file at HOME/.aws/credentials. When not specified, 'default' is used. See Plugins::RequestSigner for more details.

  • :raise_response_errors (Boolean) — default: true

    When true, response errors are raised. See Seahorse::Client::Plugins::RaiseResponseErrors for more details.

  • :region (required, String)

    The AWS region to connect to. The region is used to construct the client endpoint. Defaults to ENV['AWS_REGION']. Also checks AMAZON_REGION and AWS_DEFAULT_REGION. See Plugins::RegionalEndpoint for more details.

  • :retry_limit (Integer) — default: 3

    The maximum number of times to retry failed requests. Only ~ 500 level server errors and certain ~ 400 level client errors are retried. Generally, these are throttling errors, data checksum errors, networking errors, timeout errors and auth errors from expired credentials. See Plugins::RetryErrors for more details.

  • :secret_access_key (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :session_token (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :simple_json (Boolean) — default: false

    Disables request parameter conversion, validation, and formatting. Also disable response data type conversions. This option is useful when you want to ensure the highest level of performance by avoiding overhead of walking request parameters and response data structures.

    When :simple_json is enabled, the request parameters hash must be formatted exactly as the DynamoDB API expects. See Plugins::Protocols::JsonRpc for more details.

  • :ssl_ca_bundle (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_directory (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_store (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_verify_peer (Boolean) — default: true

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :stub_responses (Boolean) — default: false

    Causes the client to return stubbed responses. By default fake responses are generated and returned. You can specify the response data to return or errors to raise by calling ClientStubs#stub_responses. See ClientStubs for more information.

    Please note When response stubbing is enabled, no HTTP requests are made, and retries are disabled. See Plugins::StubResponses for more details.

  • :validate_params (Boolean) — default: true

    When true, request parameters are validated before sending the request. See Plugins::ParamValidator for more details.

Instance Method Details

#create_http_namespace(options = {}) ⇒ Types::CreateHttpNamespaceResponse

Creates an HTTP namespace. Service instances that you register using an HTTP namespace can be discovered using a DiscoverInstances request but can't be discovered using DNS.

For the current quota on the number of namespaces that you can create using the same AWS account, see AWS Cloud Map quotas in the AWS Cloud Map Developer Guide.

Examples:

Example: CreateHttpNamespace example


# This example creates an HTTP namespace.

resp = client.create_http_namespace({
  creator_request_id: "example-creator-request-id-0001", 
  description: "Example.com AWS Cloud Map HTTP Namespace", 
  name: "example-http.com", 
})

# resp.to_h outputs the following:
{
  operation_id: "httpvoqozuhfet5kzxoxg-a-response-example", 
}

Request syntax with placeholder values


resp = client.create_http_namespace({
  name: "NamespaceName", # required
  creator_request_id: "ResourceId",
  description: "ResourceDescription",
  tags: [
    {
      key: "TagKey", # required
      value: "TagValue", # required
    },
  ],
})

Response structure


resp.operation_id #=> String

Options Hash (options):

  • :name (required, String)

    The name that you want to assign to this namespace.

  • :creator_request_id (String)

    This parameter will be auto-filled on your behalf with a random UUIDv4 when no value is provided. A unique string that identifies the request and that allows failed CreateHttpNamespace requests to be retried without the risk of executing the operation twice. CreatorRequestId can be any unique string, for example, a date/time stamp.

  • :description (String)

    A description for the namespace.

  • :tags (Array<Types::Tag>)

    The tags to add to the namespace. 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.

Returns:

See Also:

#create_private_dns_namespace(options = {}) ⇒ Types::CreatePrivateDnsNamespaceResponse

Creates a private namespace based on DNS, which will be visible only inside a specified Amazon VPC. The namespace defines your service naming scheme. For example, if you name your namespace example.com and name your service backend, the resulting DNS name for the service will be backend.example.com. For the current quota on the number of namespaces that you can create using the same AWS account, see AWS Cloud Map Limits in the AWS Cloud Map Developer Guide.

Examples:

Example: Example: Create private DNS namespace


# Example: Create private DNS namespace

resp = client.create_private_dns_namespace({
  creator_request_id: "eedd6892-50f3-41b2-8af9-611d6e1d1a8c", 
  name: "example.com", 
  vpc: "vpc-1c56417b", 
})

# resp.to_h outputs the following:
{
  operation_id: "gv4g5meo7ndmeh4fqskygvk23d2fijwa-k9302yzd", 
}

Request syntax with placeholder values


resp = client.create_private_dns_namespace({
  name: "NamespaceName", # required
  creator_request_id: "ResourceId",
  description: "ResourceDescription",
  vpc: "ResourceId", # required
  tags: [
    {
      key: "TagKey", # required
      value: "TagValue", # required
    },
  ],
})

Response structure


resp.operation_id #=> String

Options Hash (options):

  • :name (required, String)

    The name that you want to assign to this namespace. When you create a private DNS namespace, AWS Cloud Map automatically creates an Amazon Route 53 private hosted zone that has the same name as the namespace.

  • :creator_request_id (String)

    This parameter will be auto-filled on your behalf with a random UUIDv4 when no value is provided. A unique string that identifies the request and that allows failed CreatePrivateDnsNamespace requests to be retried without the risk of executing the operation twice. CreatorRequestId can be any unique string, for example, a date/time stamp.

  • :description (String)

    A description for the namespace.

  • :vpc (required, String)

    The ID of the Amazon VPC that you want to associate the namespace with.

  • :tags (Array<Types::Tag>)

    The tags to add to the namespace. 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.

Returns:

See Also:

#create_public_dns_namespace(options = {}) ⇒ Types::CreatePublicDnsNamespaceResponse

Creates a public namespace based on DNS, which will be visible on the internet. The namespace defines your service naming scheme. For example, if you name your namespace example.com and name your service backend, the resulting DNS name for the service will be backend.example.com. For the current quota on the number of namespaces that you can create using the same AWS account, see AWS Cloud Map Limits in the AWS Cloud Map Developer Guide.

Examples:

Example: CreatePublicDnsNamespace example


# This example creates a public namespace based on DNS.

resp = client.create_public_dns_namespace({
  creator_request_id: "example-creator-request-id-0003", 
  description: "Example.com AWS Cloud Map Public DNS Namespace", 
  name: "example-public-dns.com", 
})

# resp.to_h outputs the following:
{
  operation_id: "dns2voqozuhfet5kzxoxg-a-response-example", 
}

Request syntax with placeholder values


resp = client.create_public_dns_namespace({
  name: "NamespaceName", # required
  creator_request_id: "ResourceId",
  description: "ResourceDescription",
  tags: [
    {
      key: "TagKey", # required
      value: "TagValue", # required
    },
  ],
})

Response structure


resp.operation_id #=> String

Options Hash (options):

  • :name (required, String)

    The name that you want to assign to this namespace.

  • :creator_request_id (String)

    This parameter will be auto-filled on your behalf with a random UUIDv4 when no value is provided. A unique string that identifies the request and that allows failed CreatePublicDnsNamespace requests to be retried without the risk of executing the operation twice. CreatorRequestId can be any unique string, for example, a date/time stamp.

  • :description (String)

    A description for the namespace.

  • :tags (Array<Types::Tag>)

    The tags to add to the namespace. 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.

Returns:

See Also:

#create_service(options = {}) ⇒ Types::CreateServiceResponse

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 and AAAA

    • SRV

    • CNAME

  • Optionally, a health check

After you create the service, you can submit a RegisterInstance request, and AWS Cloud Map uses the values in the configuration to create the specified entities.

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.

Examples:

Example: Example: Create service


# Example: Create service

resp = client.create_service({
  creator_request_id: "567c1193-6b00-4308-bd57-ad38a8822d25", 
  dns_config: {
    dns_records: [
      {
        ttl: 60, 
        type: "A", 
      }, 
    ], 
    namespace_id: "ns-ylexjili4cdxy3xm", 
    routing_policy: "MULTIVALUE", 
  }, 
  name: "myservice", 
  namespace_id: "ns-ylexjili4cdxy3xm", 
})

# resp.to_h outputs the following:
{
  service: {
    arn: "arn:aws:servicediscovery:us-west-2:123456789012:service/srv-p5zdwlg5uvvzjita", 
    create_date: Time.parse(1587081768.334), 
    creator_request_id: "567c1193-6b00-4308-bd57-ad38a8822d25", 
    dns_config: {
      dns_records: [
        {
          ttl: 60, 
          type: "A", 
        }, 
      ], 
      namespace_id: "ns-ylexjili4cdxy3xm", 
      routing_policy: "MULTIVALUE", 
    }, 
    id: "srv-p5zdwlg5uvvzjita", 
    name: "myservice", 
    namespace_id: "ns-ylexjili4cdxy3xm", 
  }, 
}

Request syntax with placeholder values


resp = client.create_service({
  name: "ServiceName", # required
  namespace_id: "ResourceId",
  creator_request_id: "ResourceId",
  description: "ResourceDescription",
  dns_config: {
    namespace_id: "ResourceId",
    routing_policy: "MULTIVALUE", # accepts MULTIVALUE, WEIGHTED
    dns_records: [ # required
      {
        type: "SRV", # required, accepts SRV, A, AAAA, CNAME
        ttl: 1, # required
      },
    ],
  },
  health_check_config: {
    type: "HTTP", # required, accepts HTTP, HTTPS, TCP
    resource_path: "ResourcePath",
    failure_threshold: 1,
  },
  health_check_custom_config: {
    failure_threshold: 1,
  },
  tags: [
    {
      key: "TagKey", # required
      value: "TagValue", # required
    },
  ],
})

Response structure


resp.service.id #=> String
resp.service.arn #=> String
resp.service.name #=> String
resp.service.namespace_id #=> String
resp.service.description #=> String
resp.service.instance_count #=> Integer
resp.service.dns_config.namespace_id #=> String
resp.service.dns_config.routing_policy #=> String, one of "MULTIVALUE", "WEIGHTED"
resp.service.dns_config.dns_records #=> Array
resp.service.dns_config.dns_records[0].type #=> String, one of "SRV", "A", "AAAA", "CNAME"
resp.service.dns_config.dns_records[0].ttl #=> Integer
resp.service.health_check_config.type #=> String, one of "HTTP", "HTTPS", "TCP"
resp.service.health_check_config.resource_path #=> String
resp.service.health_check_config.failure_threshold #=> Integer
resp.service.health_check_custom_config.failure_threshold #=> Integer
resp.service.create_date #=> Time
resp.service.creator_request_id #=> String

Options Hash (options):

  • :name (required, String)

    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

    When you register an instance, AWS Cloud Map creates an SRV record and assigns a name to the record by concatenating the service name and the namespace name, for example:

    _exampleservice._tcp.example.com

  • :namespace_id (String)

    The ID of the namespace that you want to use to create the service.

  • :creator_request_id (String)

    This parameter will be auto-filled on your behalf with a random UUIDv4 when no value is provided. 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.

  • :description (String)

    A description for the service.

  • :dns_config (Types::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.

  • :health_check_config (Types::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.

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

    For information about the charges for health checks, see AWS Cloud Map Pricing.

  • :health_check_custom_config (Types::HealthCheckCustomConfig)

    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.

    You can\'t add, update, or delete a HealthCheckCustomConfig configuration from an existing service.

  • :tags (Array<Types::Tag>)

    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.

Returns:

See Also:

#delete_namespace(options = {}) ⇒ Types::DeleteNamespaceResponse

Deletes a namespace from the current account. If the namespace still contains one or more services, the request fails.

Examples:

Example: Example: Delete namespace


# Example: Delete namespace

resp = client.delete_namespace({
  id: "ns-ylexjili4cdxy3xm", 
})

# resp.to_h outputs the following:
{
  operation_id: "gv4g5meo7ndmeh4fqskygvk23d2fijwa-k98y6drk", 
}

Request syntax with placeholder values


resp = client.delete_namespace({
  id: "ResourceId", # required
})

Response structure


resp.operation_id #=> String

Options Hash (options):

  • :id (required, String)

    The ID of the namespace that you want to delete.

Returns:

See Also:

#delete_service(options = {}) ⇒ Struct

Deletes a specified service. If the service still contains one or more registered instances, the request fails.

Examples:

Example: Example: Delete service


# Example: Delete service

resp = client.delete_service({
  id: "srv-p5zdwlg5uvvzjita", 
})

# resp.to_h outputs the following:
{
}

Request syntax with placeholder values


resp = client.delete_service({
  id: "ResourceId", # required
})

Options Hash (options):

  • :id (required, String)

    The ID of the service that you want to delete.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#deregister_instance(options = {}) ⇒ Types::DeregisterInstanceResponse

Deletes the Amazon Route 53 DNS records and health check, if any, that AWS Cloud Map created for the specified instance.

Examples:

Example: Example: Deregister a service instance


# Example: Deregister a service instance

resp = client.deregister_instance({
  instance_id: "myservice-53", 
  service_id: "srv-p5zdwlg5uvvzjita", 
})

# resp.to_h outputs the following:
{
  operation_id: "4yejorelbukcjzpnr6tlmrghsjwpngf4-k98rnaiq", 
}

Request syntax with placeholder values


resp = client.deregister_instance({
  service_id: "ResourceId", # required
  instance_id: "ResourceId", # required
})

Response structure


resp.operation_id #=> String

Options Hash (options):

  • :service_id (required, String)

    The ID of the service that the instance is associated with.

  • :instance_id (required, String)

    The value that you specified for Id in the RegisterInstance request.

Returns:

See Also:

#discover_instances(options = {}) ⇒ Types::DiscoverInstancesResponse

Discovers registered instances for a specified namespace and service. You can use DiscoverInstances to discover instances for any type of namespace. For public and private DNS namespaces, you can also use DNS queries to discover instances.

Examples:

Example: Example: Discover registered instances


# Example: Discover registered instances

resp = client.discover_instances({
  health_status: "ALL", 
  max_results: 10, 
  namespace_name: "example.com", 
  service_name: "myservice", 
})

# resp.to_h outputs the following:
{
  instances: [
    {
      attributes: {
        "AWS_INSTANCE_IPV4" => "172.2.1.3", 
        "AWS_INSTANCE_PORT" => "808", 
      }, 
      health_status: "UNKNOWN", 
      instance_id: "myservice-53", 
      namespace_name: "example.com", 
      service_name: "myservice", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.discover_instances({
  namespace_name: "NamespaceName", # required
  service_name: "ServiceName", # required
  max_results: 1,
  query_parameters: {
    "AttrKey" => "AttrValue",
  },
  optional_parameters: {
    "AttrKey" => "AttrValue",
  },
  health_status: "HEALTHY", # accepts HEALTHY, UNHEALTHY, ALL
})

Response structure


resp.instances #=> Array
resp.instances[0].instance_id #=> String
resp.instances[0].namespace_name #=> String
resp.instances[0].service_name #=> String
resp.instances[0].health_status #=> String, one of "HEALTHY", "UNHEALTHY", "UNKNOWN"
resp.instances[0].attributes #=> Hash
resp.instances[0].attributes["AttrKey"] #=> String

Options Hash (options):

  • :namespace_name (required, String)

    The name of the namespace that you specified when you registered the instance.

  • :service_name (required, String)

    The name of the service that you specified when you registered the instance.

  • :max_results (Integer)

    The maximum number of instances that you want AWS Cloud Map to return in the response to a DiscoverInstances request. If you don\'t specify a value for MaxResults, AWS Cloud Map returns up to 100 instances.

  • :query_parameters (Hash<String,String>)

    Filters to scope the results based on custom attributes for the instance. For example, {version=v1, az=1a}. Only instances that match all the specified key-value pairs will be returned.

  • :optional_parameters (Hash<String,String>)

    Opportunistic filters to scope the results based on custom attributes. If there are instances that match both the filters specified in both the QueryParameters parameter and this parameter, they are returned. Otherwise, these filters are ignored and only instances that match the filters specified in the QueryParameters parameter are returned.

  • :health_status (String)

    The health status of the instances that you want to discover.

Returns:

See Also:

#get_instance(options = {}) ⇒ Types::GetInstanceResponse

Gets information about a specified instance.

Examples:

Example: GetInstance example


# This example gets information about a specified instance.

resp = client.get_instance({
  instance_id: "i-abcd1234", 
  service_id: "srv-e4anhexample0004", 
})

# resp.to_h outputs the following:
{
  instance: {
    attributes: {
      "AWS_INSTANCE_IPV4" => "192.0.2.44", 
      "AWS_INSTANCE_PORT" => "80", 
      "color" => "green", 
      "region" => "us-west-2", 
      "stage" => "beta", 
    }, 
    id: "i-abcd1234", 
  }, 
}

Request syntax with placeholder values


resp = client.get_instance({
  service_id: "ResourceId", # required
  instance_id: "ResourceId", # required
})

Response structure


resp.instance.id #=> String
resp.instance.creator_request_id #=> String
resp.instance.attributes #=> Hash
resp.instance.attributes["AttrKey"] #=> String

Options Hash (options):

  • :service_id (required, String)

    The ID of the service that the instance is associated with.

  • :instance_id (required, String)

    The ID of the instance that you want to get information about.

Returns:

See Also:

#get_instances_health_status(options = {}) ⇒ Types::GetInstancesHealthStatusResponse

Gets the current health status (Healthy, Unhealthy, or Unknown) of one or more instances that are associated with a specified service.

There is a brief delay between when you register an instance and when the health status for the instance is available.

Examples:

Example: GetInstancesHealthStatus example


# This example gets the current health status of one or more instances that are associate with a specified service.

resp = client.get_instances_health_status({
  service_id: "srv-e4anhexample0004", 
})

# resp.to_h outputs the following:
{
  status: {
    "i-abcd1234" => "HEALTHY", 
    "i-abcd1235" => "UNHEALTHY", 
  }, 
}

Request syntax with placeholder values


resp = client.get_instances_health_status({
  service_id: "ResourceId", # required
  instances: ["ResourceId"],
  max_results: 1,
  next_token: "NextToken",
})

Response structure


resp.status #=> Hash
resp.status["ResourceId"] #=> String, one of "HEALTHY", "UNHEALTHY", "UNKNOWN"
resp.next_token #=> String

Options Hash (options):

  • :service_id (required, String)

    The ID of the service that the instance is associated with.

  • :instances (Array<String>)

    An array that contains the IDs of all the instances that you want to get the health status for.

    If you omit Instances, AWS Cloud Map returns the health status for all the instances that are associated with the specified service.

    To get the IDs for the instances that you\'ve registered by using a specified service, submit a ListInstances request.

  • :max_results (Integer)

    The maximum number of instances that you want AWS Cloud Map to return in the response to a GetInstancesHealthStatus request. If you don\'t specify a value for MaxResults, AWS Cloud Map returns up to 100 instances.

  • :next_token (String)

    For the first GetInstancesHealthStatus request, omit this value.

    If more than MaxResults instances match the specified criteria, you can submit another GetInstancesHealthStatus request to get the next group of results. Specify the value of NextToken from the previous response in the next request.

Returns:

See Also:

#get_namespace(options = {}) ⇒ Types::GetNamespaceResponse

Gets information about a namespace.

Examples:

Example: GetNamespace example


# This example gets information about a specified namespace.

resp = client.get_namespace({
  id: "ns-e4anhexample0004", 
})

# resp.to_h outputs the following:
{
  namespace: {
    arn: "arn:aws:servicediscovery:us-west-2: 123456789120:namespace/ns-e1tpmexample0001", 
    create_date: Time.parse("20181118T211712Z"), 
    creator_request_id: "example-creator-request-id-0001", 
    description: "Example.com AWS Cloud Map HTTP Namespace", 
    id: "ns-e1tpmexample0001", 
    name: "example-http.com", 
    properties: {
      dns_properties: {
      }, 
      http_properties: {
        http_name: "example-http.com", 
      }, 
    }, 
    type: "HTTP", 
  }, 
}

Request syntax with placeholder values


resp = client.get_namespace({
  id: "ResourceId", # required
})

Response structure


resp.namespace.id #=> String
resp.namespace.arn #=> String
resp.namespace.name #=> String
resp.namespace.type #=> String, one of "DNS_PUBLIC", "DNS_PRIVATE", "HTTP"
resp.namespace.description #=> String
resp.namespace.service_count #=> Integer
resp.namespace.properties.dns_properties.hosted_zone_id #=> String
resp.namespace.properties.http_properties.http_name #=> String
resp.namespace.create_date #=> Time
resp.namespace.creator_request_id #=> String

Options Hash (options):

  • :id (required, String)

    The ID of the namespace that you want to get information about.

Returns:

See Also:

#get_operation(options = {}) ⇒ Types::GetOperationResponse

Gets information about any operation that returns an operation ID in the response, such as a CreateService request.

To get a list of operations that match specified criteria, see ListOperations.

Examples:

Example: Example: Get operation result


# Example: Get operation result

resp = client.get_operation({
  operation_id: "gv4g5meo7ndmeh4fqskygvk23d2fijwa-k9302yzd", 
})

# resp.to_h outputs the following:
{
  operation: {
    create_date: Time.parse(1587055860.121), 
    id: "gv4g5meo7ndmeh4fqskygvk23d2fijwa-k9302yzd", 
    status: "SUCCESS", 
    targets: {
      "NAMESPACE" => "ns-ylexjili4cdxy3xm", 
    }, 
    type: "CREATE_NAMESPACE", 
    update_date: Time.parse(1587055900.469), 
  }, 
}

Request syntax with placeholder values


resp = client.get_operation({
  operation_id: "ResourceId", # required
})

Response structure


resp.operation.id #=> String
resp.operation.type #=> String, one of "CREATE_NAMESPACE", "DELETE_NAMESPACE", "UPDATE_SERVICE", "REGISTER_INSTANCE", "DEREGISTER_INSTANCE"
resp.operation.status #=> String, one of "SUBMITTED", "PENDING", "SUCCESS", "FAIL"
resp.operation.error_message #=> String
resp.operation.error_code #=> String
resp.operation.create_date #=> Time
resp.operation.update_date #=> Time
resp.operation.targets #=> Hash
resp.operation.targets["OperationTargetType"] #=> String

Options Hash (options):

  • :operation_id (required, String)

    The ID of the operation that you want to get more information about.

Returns:

See Also:

#get_service(options = {}) ⇒ Types::GetServiceResponse

Gets the settings for a specified service.

Examples:

Example: GetService Example


# This example gets the settings for a specified service.

resp = client.get_service({
  id: "srv-e4anhexample0004", 
})

# resp.to_h outputs the following:
{
  service: {
    arn: "arn:aws:servicediscovery:us-west-2:123456789120:service/srv-e4anhexample0004", 
    create_date: Time.parse("20181118T211707Z"), 
    creator_request_id: "example-creator-request-id-0004", 
    description: "Example.com AWS Cloud Map HTTP Service", 
    health_check_config: {
      failure_threshold: 3, 
      resource_path: "/", 
      type: "HTTPS", 
    }, 
    id: "srv-e4anhexample0004", 
    name: "example-http-service", 
    namespace_id: "ns-e4anhexample0004", 
  }, 
}

Request syntax with placeholder values


resp = client.get_service({
  id: "ResourceId", # required
})

Response structure


resp.service.id #=> String
resp.service.arn #=> String
resp.service.name #=> String
resp.service.namespace_id #=> String
resp.service.description #=> String
resp.service.instance_count #=> Integer
resp.service.dns_config.namespace_id #=> String
resp.service.dns_config.routing_policy #=> String, one of "MULTIVALUE", "WEIGHTED"
resp.service.dns_config.dns_records #=> Array
resp.service.dns_config.dns_records[0].type #=> String, one of "SRV", "A", "AAAA", "CNAME"
resp.service.dns_config.dns_records[0].ttl #=> Integer
resp.service.health_check_config.type #=> String, one of "HTTP", "HTTPS", "TCP"
resp.service.health_check_config.resource_path #=> String
resp.service.health_check_config.failure_threshold #=> Integer
resp.service.health_check_custom_config.failure_threshold #=> Integer
resp.service.create_date #=> Time
resp.service.creator_request_id #=> String

Options Hash (options):

  • :id (required, String)

    The ID of the service that you want to get settings for.

Returns:

See Also:

#list_instances(options = {}) ⇒ Types::ListInstancesResponse

Lists summary information about the instances that you registered by using a specified service.

Examples:

Example: Example: List service instances


# Example: List service instances

resp = client.list_instances({
  service_id: "srv-qzpwvt2tfqcegapy", 
})

# resp.to_h outputs the following:
{
  instances: [
    {
      attributes: {
        "AWS_INSTANCE_IPV4" => "172.2.1.3", 
        "AWS_INSTANCE_PORT" => "808", 
      }, 
      id: "i-06bdabbae60f65a4e", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_instances({
  service_id: "ResourceId", # required
  next_token: "NextToken",
  max_results: 1,
})

Response structure


resp.instances #=> Array
resp.instances[0].id #=> String
resp.instances[0].attributes #=> Hash
resp.instances[0].attributes["AttrKey"] #=> String
resp.next_token #=> String

Options Hash (options):

  • :service_id (required, String)

    The ID of the service that you want to list instances for.

  • :next_token (String)

    For the first ListInstances request, omit this value.

    If more than MaxResults instances match the specified criteria, you can submit another ListInstances request to get the next group of results. Specify the value of NextToken from the previous response in the next request.

  • :max_results (Integer)

    The maximum number of instances that you want AWS Cloud Map to return in the response to a ListInstances request. If you don\'t specify a value for MaxResults, AWS Cloud Map returns up to 100 instances.

Returns:

See Also:

#list_namespaces(options = {}) ⇒ Types::ListNamespacesResponse

Lists summary information about the namespaces that were created by the current AWS account.

Examples:

Example: Example: List namespaces


# Example: List namespaces

resp = client.list_namespaces({
})

# resp.to_h outputs the following:
{
  namespaces: [
    {
      arn: "arn:aws:servicediscovery:us-west-2:123456789012:namespace/ns-a3ccy2e7e3a7rile", 
      create_date: Time.parse(1585354387.357), 
      id: "ns-a3ccy2e7e3a7rile", 
      name: "local", 
      properties: {
        dns_properties: {
          hosted_zone_id: "Z06752353VBUDTC32S84S", 
        }, 
        http_properties: {
          http_name: "local", 
        }, 
      }, 
      type: "DNS_PRIVATE", 
    }, 
    {
      arn: "arn:aws:servicediscovery:us-west-2:123456789012:namespace/ns-pocfyjtrsmwtvcxx", 
      create_date: Time.parse(1586468974.698), 
      description: "My second namespace", 
      id: "ns-pocfyjtrsmwtvcxx", 
      name: "My-second-namespace", 
      properties: {
        dns_properties: {
        }, 
        http_properties: {
          http_name: "My-second-namespace", 
        }, 
      }, 
      type: "HTTP", 
    }, 
    {
      arn: "arn:aws:servicediscovery:us-west-2:123456789012:namespace/ns-ylexjili4cdxy3xm", 
      create_date: Time.parse(1587055896.798), 
      id: "ns-ylexjili4cdxy3xm", 
      name: "example.com", 
      properties: {
        dns_properties: {
          hosted_zone_id: "Z09983722P0QME1B3KC8I", 
        }, 
        http_properties: {
          http_name: "example.com", 
        }, 
      }, 
      type: "DNS_PRIVATE", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_namespaces({
  next_token: "NextToken",
  max_results: 1,
  filters: [
    {
      name: "TYPE", # required, accepts TYPE
      values: ["FilterValue"], # required
      condition: "EQ", # accepts EQ, IN, BETWEEN
    },
  ],
})

Response structure


resp.namespaces #=> Array
resp.namespaces[0].id #=> String
resp.namespaces[0].arn #=> String
resp.namespaces[0].name #=> String
resp.namespaces[0].type #=> String, one of "DNS_PUBLIC", "DNS_PRIVATE", "HTTP"
resp.namespaces[0].description #=> String
resp.namespaces[0].service_count #=> Integer
resp.namespaces[0].properties.dns_properties.hosted_zone_id #=> String
resp.namespaces[0].properties.http_properties.http_name #=> String
resp.namespaces[0].create_date #=> Time
resp.next_token #=> String

Options Hash (options):

  • :next_token (String)

    For the first ListNamespaces request, omit this value.

    If the response contains NextToken, submit another ListNamespaces request to get the next group of results. Specify the value of NextToken from the previous response in the next request.

    AWS Cloud Map gets MaxResults namespaces and then filters them based on the specified criteria. It\'s possible that no namespaces in the first MaxResults namespaces matched the specified criteria but that subsequent groups of MaxResults namespaces do contain namespaces that match the criteria.

  • :max_results (Integer)

    The maximum number of namespaces that you want AWS Cloud Map to return in the response to a ListNamespaces request. If you don\'t specify a value for MaxResults, AWS Cloud Map returns up to 100 namespaces.

  • :filters (Array<Types::NamespaceFilter>)

    A complex type that contains specifications for the namespaces that you want to list.

    If you specify more than one filter, a namespace must match all filters to be returned by ListNamespaces.

Returns:

See Also:

#list_operations(options = {}) ⇒ Types::ListOperationsResponse

Lists operations that match the criteria that you specify.

Examples:

Example: ListOperations Example


# This example gets the operations that have a STATUS of either PENDING or SUCCESS.

resp = client.list_operations({
  filters: [
    {
      condition: "IN", 
      name: "STATUS", 
      values: [
        "PENDING", 
        "SUCCESS", 
      ], 
    }, 
  ], 
})

# resp.to_h outputs the following:
{
  operations: [
    {
      id: "76yy8ovhpdz0plmjzbsnqgnrqvpv2qdt-kexample", 
      status: "SUCCESS", 
    }, 
    {
      id: "prysnyzpji3u2ciy45nke83x2zanl7yk-dexample", 
      status: "SUCCESS", 
    }, 
    {
      id: "ko4ekftir7kzlbechsh7xvcdgcpk66gh-7example", 
      status: "PENDING", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_operations({
  next_token: "NextToken",
  max_results: 1,
  filters: [
    {
      name: "NAMESPACE_ID", # required, accepts NAMESPACE_ID, SERVICE_ID, STATUS, TYPE, UPDATE_DATE
      values: ["FilterValue"], # required
      condition: "EQ", # accepts EQ, IN, BETWEEN
    },
  ],
})

Response structure


resp.operations #=> Array
resp.operations[0].id #=> String
resp.operations[0].status #=> String, one of "SUBMITTED", "PENDING", "SUCCESS", "FAIL"
resp.next_token #=> String

Options Hash (options):

  • :next_token (String)

    For the first ListOperations request, omit this value.

    If the response contains NextToken, submit another ListOperations request to get the next group of results. Specify the value of NextToken from the previous response in the next request.

    AWS Cloud Map gets MaxResults operations and then filters them based on the specified criteria. It\'s possible that no operations in the first MaxResults operations matched the specified criteria but that subsequent groups of MaxResults operations do contain operations that match the criteria.

  • :max_results (Integer)

    The maximum number of items that you want AWS Cloud Map to return in the response to a ListOperations request. If you don\'t specify a value for MaxResults, AWS Cloud Map returns up to 100 operations.

  • :filters (Array<Types::OperationFilter>)

    A complex type that contains specifications for the operations that you want to list, for example, operations that you started between a specified start date and end date.

    If you specify more than one filter, an operation must match all filters to be returned by ListOperations.

Returns:

See Also:

#list_services(options = {}) ⇒ Types::ListServicesResponse

Lists summary information for all the services that are associated with one or more specified namespaces.

Examples:

Example: Example: List services


# Example: List services

resp = client.list_services({
})

# resp.to_h outputs the following:
{
  services: [
    {
      arn: "arn:aws:servicediscovery:us-west-2:123456789012:service/srv-p5zdwlg5uvvzjita", 
      create_date: Time.parse(1587081768.334), 
      dns_config: {
        dns_records: [
          {
            ttl: 60, 
            type: "A", 
          }, 
        ], 
        routing_policy: "MULTIVALUE", 
      }, 
      id: "srv-p5zdwlg5uvvzjita", 
      name: "myservice", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_services({
  next_token: "NextToken",
  max_results: 1,
  filters: [
    {
      name: "NAMESPACE_ID", # required, accepts NAMESPACE_ID
      values: ["FilterValue"], # required
      condition: "EQ", # accepts EQ, IN, BETWEEN
    },
  ],
})

Response structure


resp.services #=> Array
resp.services[0].id #=> String
resp.services[0].arn #=> String
resp.services[0].name #=> String
resp.services[0].description #=> String
resp.services[0].instance_count #=> Integer
resp.services[0].dns_config.namespace_id #=> String
resp.services[0].dns_config.routing_policy #=> String, one of "MULTIVALUE", "WEIGHTED"
resp.services[0].dns_config.dns_records #=> Array
resp.services[0].dns_config.dns_records[0].type #=> String, one of "SRV", "A", "AAAA", "CNAME"
resp.services[0].dns_config.dns_records[0].ttl #=> Integer
resp.services[0].health_check_config.type #=> String, one of "HTTP", "HTTPS", "TCP"
resp.services[0].health_check_config.resource_path #=> String
resp.services[0].health_check_config.failure_threshold #=> Integer
resp.services[0].health_check_custom_config.failure_threshold #=> Integer
resp.services[0].create_date #=> Time
resp.next_token #=> String

Options Hash (options):

  • :next_token (String)

    For the first ListServices request, omit this value.

    If the response contains NextToken, submit another ListServices request to get the next group of results. Specify the value of NextToken from the previous response in the next request.

    AWS Cloud Map gets MaxResults services and then filters them based on the specified criteria. It\'s possible that no services in the first MaxResults services matched the specified criteria but that subsequent groups of MaxResults services do contain services that match the criteria.

  • :max_results (Integer)

    The maximum number of services that you want AWS Cloud Map to return in the response to a ListServices request. If you don\'t specify a value for MaxResults, AWS Cloud Map returns up to 100 services.

  • :filters (Array<Types::ServiceFilter>)

    A complex type that contains specifications for the namespaces that you want to list services for.

    If you specify more than one filter, an operation must match all filters to be returned by ListServices.

Returns:

See Also:

#list_tags_for_resource(options = {}) ⇒ Types::ListTagsForResourceResponse

Lists tags for the specified resource.

Examples:

Example: ListTagsForResource example


# This example lists the tags of a resource.

resp = client.list_tags_for_resource({
  resource_arn: "arn:aws:servicediscovery:us-east-1:123456789012:namespace/ns-ylexjili4cdxy3xm", 
})

# resp.to_h outputs the following:
{
  tags: [
    {
      key: "Project", 
      value: "Zeta", 
    }, 
    {
      key: "Department", 
      value: "Engineering", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_tags_for_resource({
  resource_arn: "AmazonResourceName", # required
})

Response structure


resp.tags #=> Array
resp.tags[0].key #=> String
resp.tags[0].value #=> String

Options Hash (options):

  • :resource_arn (required, String)

    The Amazon Resource Name (ARN) of the resource that you want to retrieve tags for.

Returns:

See Also:

#register_instance(options = {}) ⇒ Types::RegisterInstanceResponse

Creates or updates one or more records and, optionally, creates a health check based on the settings in a specified service. When you submit a RegisterInstance request, the following occurs:

  • For each DNS record that you define in the service that is specified by ServiceId, a record is created or updated in the hosted zone that is associated with the corresponding namespace.

  • If the service includes HealthCheckConfig, a health check is created based on the settings in the health check configuration.

  • The health check, if any, is associated with each of the new or updated records.

One RegisterInstance request must complete before you can submit another request and specify the same service ID and instance ID.

For more information, see CreateService.

When AWS Cloud Map receives a DNS query for the specified DNS name, it returns the applicable value:

  • If the health check is healthy: returns all the records

  • If the health check is unhealthy: returns the applicable value for the last healthy instance

  • If you didn't specify a health check configuration: returns all the records

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.

Examples:

Example: Example: Register Instance


# Example: Register Instance

resp = client.register_instance({
  attributes: {
    "AWS_INSTANCE_IPV4" => "172.2.1.3", 
    "AWS_INSTANCE_PORT" => "808", 
  }, 
  creator_request_id: "7a48a98a-72e6-4849-bfa7-1a458e030d7b", 
  instance_id: "myservice-53", 
  service_id: "srv-p5zdwlg5uvvzjita", 
})

# resp.to_h outputs the following:
{
  operation_id: "4yejorelbukcjzpnr6tlmrghsjwpngf4-k95yg2u7", 
}

Request syntax with placeholder values


resp = client.register_instance({
  service_id: "ResourceId", # required
  instance_id: "ResourceId", # required
  creator_request_id: "ResourceId",
  attributes: { # required
    "AttrKey" => "AttrValue",
  },
})

Response structure


resp.operation_id #=> String

Options Hash (options):

  • :service_id (required, String)

    The ID of the service that you want to use for settings for the instance.

  • :instance_id (required, String)

    An identifier that you want to associate with the instance. Note the following:

    • If the service that is specified by ServiceId includes settings for an SRV record, the value of InstanceId is automatically included as part of the value for the SRV record. For more information, see DnsRecord > Type.

    • You can use this value to update an existing instance.

    • To register a new instance, you must specify a value that is unique among instances that you register by using the same service.

    • If you specify an existing InstanceId and ServiceId, AWS Cloud Map updates the existing DNS records, if any. If there\'s also an existing health check, AWS Cloud Map deletes the old health check and creates a new one.

      The health check isn\'t deleted immediately, so it will still appear for a while if you submit a ListHealthChecks request, for example.

  • :creator_request_id (String)

    This parameter will be auto-filled on your behalf with a random UUIDv4 when no value is provided. A unique string that identifies the request and that allows failed RegisterInstance requests to be retried without the risk of executing the operation twice. You must use a unique CreatorRequestId string every time you submit a RegisterInstance request if you\'re registering additional instances for the same namespace and service. CreatorRequestId can be any unique string, for example, a date/time stamp.

  • :attributes (required, Hash<String,String>)

    A string map that contains the following information for the service that you specify in ServiceId:

    • The attributes that apply to the records that are defined in the service.

    • For each attribute, the applicable value.

    Supported attribute keys include the following:

    AWS_ALIAS_DNS_NAME

    If you want AWS Cloud Map to create an Amazon Route 53 alias record that routes traffic to an Elastic Load Balancing load balancer, specify the DNS name that is associated with the load balancer. For information about how to get the DNS name, see \"DNSName\" in the topic AliasTarget in the Route 53 API Reference.

    Note the following:

    • The configuration for the service that is specified by ServiceId must include settings for an A record, an AAAA record, or both.

    • In the service that is specified by ServiceId, the value of RoutingPolicy must be WEIGHTED.

    • If the service that is specified by ServiceId includes HealthCheckConfig settings, AWS Cloud Map will create the Route 53 health check, but it won\'t associate the health check with the alias record.

    • Auto naming currently doesn\'t support creating alias records that route traffic to AWS resources other than Elastic Load Balancing load balancers.

    • If you specify a value for AWS_ALIAS_DNS_NAME, don\'t specify values for any of the AWS_INSTANCE attributes.

    AWS_EC2_INSTANCE_ID

    HTTP namespaces only. The Amazon EC2 instance ID for the instance. If the AWS_EC2_INSTANCE_ID attribute is specified, then the only other attribute that can be specified is AWS_INIT_HEALTH_STATUS. When the AWS_EC2_INSTANCE_ID attribute is specified, then the AWS_INSTANCE_IPV4 attribute will be filled out with the primary private IPv4 address.

    AWS_INIT_HEALTH_STATUS

    If the service configuration includes HealthCheckCustomConfig, you can optionally use AWS_INIT_HEALTH_STATUS to specify the initial status of the custom health check, HEALTHY or UNHEALTHY. If you don\'t specify a value for AWS_INIT_HEALTH_STATUS, the initial status is HEALTHY.

    AWS_INSTANCE_CNAME

    If the service configuration includes a CNAME record, the domain name that you want Route 53 to return in response to DNS queries, for example, example.com.

    This value is required if the service specified by ServiceId includes settings for an CNAME record.

    AWS_INSTANCE_IPV4

    If the service configuration includes an A record, the IPv4 address that you want Route 53 to return in response to DNS queries, for example, 192.0.2.44.

    This value is required if the service specified by ServiceId includes settings for an A record. If the service includes settings for an SRV record, you must specify a value for AWS_INSTANCE_IPV4, AWS_INSTANCE_IPV6, or both.

    AWS_INSTANCE_IPV6

    If the service configuration includes an AAAA record, the IPv6 address that you want Route 53 to return in response to DNS queries, for example, 2001:0db8:85a3:0000:0000:abcd:0001:2345.

    This value is required if the service specified by ServiceId includes settings for an AAAA record. If the service includes settings for an SRV record, you must specify a value for AWS_INSTANCE_IPV4, AWS_INSTANCE_IPV6, or both.

    AWS_INSTANCE_PORT

    If the service includes an SRV record, the value that you want Route 53 to return for the port.

    If the service includes HealthCheckConfig, the port on the endpoint that you want Route 53 to send requests to.

    This value is required if you specified settings for an SRV record or a Route 53 health check when you created the service.

    Custom attributes

    You can add up to 30 custom attributes. For each key-value pair, the maximum length of the attribute name is 255 characters, and the maximum length of the attribute value is 1,024 characters. The total size of all provided attributes (sum of all keys and values) must not exceed 5,000 characters.

Returns:

See Also:

#tag_resource(options = {}) ⇒ Struct

Adds one or more tags to the specified resource.

Examples:

Example: TagResource example


# This example adds "Department" and "Project" tags to a resource.

resp = client.tag_resource({
  resource_arn: "arn:aws:servicediscovery:us-east-1:123456789012:namespace/ns-ylexjili4cdxy3xm", 
  tags: [
    {
      key: "Department", 
      value: "Engineering", 
    }, 
    {
      key: "Project", 
      value: "Zeta", 
    }, 
  ], 
})

# resp.to_h outputs the following:
{
}

Request syntax with placeholder values


resp = client.tag_resource({
  resource_arn: "AmazonResourceName", # required
  tags: [ # required
    {
      key: "TagKey", # required
      value: "TagValue", # required
    },
  ],
})

Options Hash (options):

  • :resource_arn (required, String)

    The Amazon Resource Name (ARN) of the resource that you want to retrieve tags for.

  • :tags (required, Array<Types::Tag>)

    The tags to add to the specified resource. Specifying the tag key is required. You can set the value of a tag to an empty string, but you can\'t set the value of a tag to null.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#untag_resource(options = {}) ⇒ Struct

Removes one or more tags from the specified resource.

Examples:

Example: UntagResource example


# This example removes the "Department" and "Project" tags from a resource.

resp = client.untag_resource({
  resource_arn: "arn:aws:servicediscovery:us-east-1:123456789012:namespace/ns-ylexjili4cdxy3xm", 
  tag_keys: [
    "Project", 
    "Department", 
  ], 
})

# resp.to_h outputs the following:
{
}

Request syntax with placeholder values


resp = client.untag_resource({
  resource_arn: "AmazonResourceName", # required
  tag_keys: ["TagKey"], # required
})

Options Hash (options):

  • :resource_arn (required, String)

    The Amazon Resource Name (ARN) of the resource that you want to retrieve tags for.

  • :tag_keys (required, Array<String>)

    The tag keys to remove from the specified resource.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#update_instance_custom_health_status(options = {}) ⇒ Struct

Submits a request to change the health status of a custom health check to healthy or unhealthy.

You can use UpdateInstanceCustomHealthStatus to change the status only for custom health checks, which you define using HealthCheckCustomConfig when you create a service. You can't use it to change the status for Route 53 health checks, which you define using HealthCheckConfig.

For more information, see HealthCheckCustomConfig.

Examples:

Example: UpdateInstanceCustomHealthStatus Example


# This example submits a request to change the health status of an instance associated with a service with a custom health check to HEALTHY.

resp = client.update_instance_custom_health_status({
  instance_id: "i-abcd1234", 
  service_id: "srv-e4anhexample0004", 
  status: "HEALTHY", 
})

Request syntax with placeholder values


resp = client.update_instance_custom_health_status({
  service_id: "ResourceId", # required
  instance_id: "ResourceId", # required
  status: "HEALTHY", # required, accepts HEALTHY, UNHEALTHY
})

Options Hash (options):

  • :service_id (required, String)

    The ID of the service that includes the configuration for the custom health check that you want to change the status for.

  • :instance_id (required, String)

    The ID of the instance that you want to change the health status for.

  • :status (required, String)

    The new status of the instance, HEALTHY or UNHEALTHY.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#update_service(options = {}) ⇒ Types::UpdateServiceResponse

Submits a request to perform the following operations:

  • Update the TTL setting for existing DnsRecords configurations

  • Add, update, or delete HealthCheckConfig for a specified service

    You can't add, update, or delete a HealthCheckCustomConfig configuration.

For public and private DNS namespaces, note the following:

  • If you omit any existing DnsRecords or HealthCheckConfig configurations from an UpdateService request, the configurations are deleted from the service.

  • If you omit an existing HealthCheckCustomConfig configuration from an UpdateService request, the configuration is not deleted from the service.

When you update settings for a service, AWS Cloud Map also updates the corresponding settings in all the records and health checks that were created by using the specified service.

Examples:

Example: UpdateService Example


# This example submits a request to replace the DnsConfig and HealthCheckConfig settings of a specified service.

resp = client.update_service({
  id: "srv-e4anhexample0004", 
  service: {
    dns_config: {
      dns_records: [
        {
          ttl: 60, 
          type: "A", 
        }, 
      ], 
    }, 
    health_check_config: {
      failure_threshold: 2, 
      resource_path: "/", 
      type: "HTTP", 
    }, 
  }, 
})

# resp.to_h outputs the following:
{
  operation_id: "m35hsdrkxwjffm3xef4bxyy6vc3ewakx-jdn3y5g5", 
}

Request syntax with placeholder values


resp = client.update_service({
  id: "ResourceId", # required
  service: { # required
    description: "ResourceDescription",
    dns_config: {
      dns_records: [ # required
        {
          type: "SRV", # required, accepts SRV, A, AAAA, CNAME
          ttl: 1, # required
        },
      ],
    },
    health_check_config: {
      type: "HTTP", # required, accepts HTTP, HTTPS, TCP
      resource_path: "ResourcePath",
      failure_threshold: 1,
    },
  },
})

Response structure


resp.operation_id #=> String

Options Hash (options):

  • :id (required, String)

    The ID of the service that you want to update.

  • :service (required, Types::ServiceChange)

    A complex type that contains the new settings for the service.

Returns:

See Also:

#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean

Waiters polls an API operation until a resource enters a desired state.

Basic Usage

Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.

# polls in a loop, sleeping between attempts client.waiter_until(waiter_name, params)

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You configure waiters by passing a block to #wait_until:

# poll for ~25 seconds
client.wait_until(...) do |w|
  w.max_attempts = 5
  w.delay = 5
end

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
client.wait_until(...) do |w|

  # disable max attempts
  w.max_attempts = nil

  # poll for 1 hour, instead of a number of attempts
  w.before_wait do |attempts, response|
    throw :failure if Time.now - started_at > 3600
  end

end

Handling Errors

When a waiter is successful, it returns true. When a waiter fails, it raises an error. All errors raised extend from Waiters::Errors::WaiterFailed.

begin
  client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

Parameters:

  • waiter_name (Symbol)

    The name of the waiter. See #waiter_names for a full list of supported waiters.

  • params (Hash) (defaults to: {})

    Additional request parameters. See the #waiter_names for a list of supported waiters and what request they call. The called request determines the list of accepted parameters.

Yield Parameters:

Returns:

  • (Boolean)

    Returns true if the waiter was successful.

Raises:

  • (Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

  • (Errors::TooManyAttemptsError)

    Raised when the configured maximum number of attempts have been made, and the waiter is not yet successful.

  • (Errors::UnexpectedError)

    Raised when an error is encounted while polling for a resource that is not expected.

  • (Errors::NoSuchWaiterError)

    Raised when you request to wait for an unknown state.

#waiter_namesArray<Symbol>

Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:

Waiter NameClient MethodDefault Delay:Default Max Attempts:

Returns:

  • (Array<Symbol>)

    the list of supported waiters.