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
- Object
- Seahorse::Client::Base
- Aws::ServiceDiscovery::Client
- 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']
andENV['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
Constructor collapse
-
#initialize(options = {}) ⇒ Aws::ServiceDiscovery::Client
constructor
Constructs an API client.
API Operations collapse
-
#create_http_namespace(options = {}) ⇒ Types::CreateHttpNamespaceResponse
Creates an HTTP namespace.
-
#create_private_dns_namespace(options = {}) ⇒ Types::CreatePrivateDnsNamespaceResponse
Creates a private namespace based on DNS, which will be visible only inside a specified Amazon VPC.
-
#create_public_dns_namespace(options = {}) ⇒ Types::CreatePublicDnsNamespaceResponse
Creates a public namespace based on DNS, which will be visible on the internet.
-
#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
andAAAA
-
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.
. -
-
#delete_namespace(options = {}) ⇒ Types::DeleteNamespaceResponse
Deletes a namespace from the current account.
-
#delete_service(options = {}) ⇒ Struct
Deletes a specified service.
-
#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.
.
-
#discover_instances(options = {}) ⇒ Types::DiscoverInstancesResponse
Discovers registered instances for a specified namespace and service.
-
#get_instance(options = {}) ⇒ Types::GetInstanceResponse
Gets information about a specified instance.
.
-
#get_instances_health_status(options = {}) ⇒ Types::GetInstancesHealthStatusResponse
Gets the current health status (
Healthy
,Unhealthy
, orUnknown
) 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.
-
#get_namespace(options = {}) ⇒ Types::GetNamespaceResponse
Gets information about a namespace.
.
-
#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.
-
#get_service(options = {}) ⇒ Types::GetServiceResponse
Gets the settings for a specified service.
.
-
#list_instances(options = {}) ⇒ Types::ListInstancesResponse
Lists summary information about the instances that you registered by using a specified service.
.
-
#list_namespaces(options = {}) ⇒ Types::ListNamespacesResponse
Lists summary information about the namespaces that were created by the current AWS account.
.
-
#list_operations(options = {}) ⇒ Types::ListOperationsResponse
Lists operations that match the criteria that you specify.
.
-
#list_services(options = {}) ⇒ Types::ListServicesResponse
Lists summary information for all the services that are associated with one or more specified namespaces.
.
-
#list_tags_for_resource(options = {}) ⇒ Types::ListTagsForResourceResponse
Lists tags for the specified resource.
.
-
#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.
-
#tag_resource(options = {}) ⇒ Struct
Adds one or more tags to the specified resource.
.
-
#untag_resource(options = {}) ⇒ Struct
Removes one or more tags from the specified resource.
.
-
#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 usingHealthCheckCustomConfig
when you create a service. -
#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 serviceYou can't add, update, or delete a
HealthCheckCustomConfig
configuration.
For public and private DNS namespaces, note the following:
-
If you omit any existing
DnsRecords
orHealthCheckConfig
configurations from anUpdateService
request, the configurations are deleted from the service. -
If you omit an existing
HealthCheckCustomConfig
configuration from anUpdateService
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.
. -
Instance Method Summary collapse
-
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean
Waiters polls an API operation until a resource enters a desired state.
-
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters.
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.
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.
#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.
#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.
#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
andAAAA
-
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.
#delete_namespace(options = {}) ⇒ Types::DeleteNamespaceResponse
Deletes a namespace from the current account. If the namespace still contains one or more services, the request fails.
#delete_service(options = {}) ⇒ Struct
Deletes a specified service. If the service still contains one or more registered instances, the request fails.
#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.
#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.
#get_instance(options = {}) ⇒ Types::GetInstanceResponse
Gets information about a specified instance.
#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.
#get_namespace(options = {}) ⇒ Types::GetNamespaceResponse
Gets information about a namespace.
#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.
#get_service(options = {}) ⇒ Types::GetServiceResponse
Gets the settings for a specified service.
#list_instances(options = {}) ⇒ Types::ListInstancesResponse
Lists summary information about the instances that you registered by using a specified service.
#list_namespaces(options = {}) ⇒ Types::ListNamespacesResponse
Lists summary information about the namespaces that were created by the current AWS account.
#list_operations(options = {}) ⇒ Types::ListOperationsResponse
Lists operations that match the criteria that you specify.
#list_services(options = {}) ⇒ Types::ListServicesResponse
Lists summary information for all the services that are associated with one or more specified namespaces.
#list_tags_for_resource(options = {}) ⇒ Types::ListTagsForResourceResponse
Lists tags for the specified resource.
#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.
#tag_resource(options = {}) ⇒ Struct
Adds one or more tags to the specified resource.
#untag_resource(options = {}) ⇒ Struct
Removes one or more tags from the specified resource.
#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.
#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 serviceYou can't add, update, or delete a
HealthCheckCustomConfig
configuration.
For public and private DNS namespaces, note the following:
-
If you omit any existing
DnsRecords
orHealthCheckConfig
configurations from anUpdateService
request, the configurations are deleted from the service. -
If you omit an existing
HealthCheckCustomConfig
configuration from anUpdateService
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.
#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
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:
Waiter Name | Client Method | Default Delay: | Default Max Attempts: |
---|