AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

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

Class: Aws::ResourceGroups::Client

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

Overview

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

resourcegroups = Aws::ResourceGroups::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::ResourceGroups::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::ResourceGroups::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.

  • :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_group(options = {}) ⇒ Types::CreateGroupOutput

Creates a resource group with the specified name and description. You can optionally include a resource query, or a service configuration.

Examples:

Request syntax with placeholder values


resp = client.create_group({
  name: "GroupName", # required
  description: "Description",
  resource_query: {
    type: "TAG_FILTERS_1_0", # required, accepts TAG_FILTERS_1_0, CLOUDFORMATION_STACK_1_0
    query: "Query", # required
  },
  tags: {
    "TagKey" => "TagValue",
  },
  configuration: [
    {
      type: "GroupConfigurationType", # required
      parameters: [
        {
          name: "GroupConfigurationParameterName", # required
          values: ["GroupConfigurationParameterValue"],
        },
      ],
    },
  ],
})

Response structure


resp.group.group_arn #=> String
resp.group.name #=> String
resp.group.description #=> String
resp.resource_query.type #=> String, one of "TAG_FILTERS_1_0", "CLOUDFORMATION_STACK_1_0"
resp.resource_query.query #=> String
resp.tags #=> Hash
resp.tags["TagKey"] #=> String
resp.group_configuration.configuration #=> Array
resp.group_configuration.configuration[0].type #=> String
resp.group_configuration.configuration[0].parameters #=> Array
resp.group_configuration.configuration[0].parameters[0].name #=> String
resp.group_configuration.configuration[0].parameters[0].values #=> Array
resp.group_configuration.configuration[0].parameters[0].values[0] #=> String
resp.group_configuration.proposed_configuration #=> Array
resp.group_configuration.proposed_configuration[0].type #=> String
resp.group_configuration.proposed_configuration[0].parameters #=> Array
resp.group_configuration.proposed_configuration[0].parameters[0].name #=> String
resp.group_configuration.proposed_configuration[0].parameters[0].values #=> Array
resp.group_configuration.proposed_configuration[0].parameters[0].values[0] #=> String
resp.group_configuration.status #=> String, one of "UPDATING", "UPDATE_COMPLETE", "UPDATE_FAILED"
resp.group_configuration.failure_reason #=> String

Options Hash (options):

  • :name (required, String)

    The name of the group, which is the identifier of the group in other operations. You can\'t change the name of a resource group after you create it. A resource group name can consist of letters, numbers, hyphens, periods, and underscores. The name cannot start with AWS or aws; these are reserved. A resource group name must be unique within each AWS Region in your AWS account.

  • :description (String)

    The description of the resource group. Descriptions can consist of letters, numbers, hyphens, underscores, periods, and spaces.

  • :resource_query (Types::ResourceQuery)

    The resource query that determines which AWS resources are members of this group.

    You can specify either a ResourceQuery or a Configuration, but not both.

  • :tags (Hash<String,String>)

    The tags to add to the group. A tag is key-value pair string.

  • :configuration (Array<Types::GroupConfigurationItem>)

    A configuration associates the resource group with an AWS service and specifies how the service can interact with the resources in the group. A configuration is an array of GroupConfigurationItem elements.

    You can specify either a Configuration or a ResourceQuery in a group, but not both.

Returns:

See Also:

#delete_group(options = {}) ⇒ Types::DeleteGroupOutput

Deletes the specified resource group. Deleting a resource group does not delete any resources that are members of the group; it only deletes the group structure.

Examples:

Request syntax with placeholder values


resp = client.delete_group({
  group_name: "GroupName",
  group: "GroupString",
})

Response structure


resp.group.group_arn #=> String
resp.group.name #=> String
resp.group.description #=> String

Options Hash (options):

  • :group_name (String)

    Don\'t use this parameter. Use Group instead.

  • :group (String)

    The name or the ARN of the resource group to delete.

Returns:

See Also:

#get_group(options = {}) ⇒ Types::GetGroupOutput

Returns information about a specified resource group.

Examples:

Request syntax with placeholder values


resp = client.get_group({
  group_name: "GroupName",
  group: "GroupString",
})

Response structure


resp.group.group_arn #=> String
resp.group.name #=> String
resp.group.description #=> String

Options Hash (options):

  • :group_name (String)

    Don\'t use this parameter. Use Group instead.

  • :group (String)

    The name or the ARN of the resource group to retrieve.

Returns:

See Also:

#get_group_configuration(options = {}) ⇒ Types::GetGroupConfigurationOutput

Returns the service configuration associated with the specified resource group. AWS Resource Groups supports configurations for the following resource group types:

Examples:

Request syntax with placeholder values


resp = client.get_group_configuration({
  group: "GroupString",
})

Response structure


resp.group_configuration.configuration #=> Array
resp.group_configuration.configuration[0].type #=> String
resp.group_configuration.configuration[0].parameters #=> Array
resp.group_configuration.configuration[0].parameters[0].name #=> String
resp.group_configuration.configuration[0].parameters[0].values #=> Array
resp.group_configuration.configuration[0].parameters[0].values[0] #=> String
resp.group_configuration.proposed_configuration #=> Array
resp.group_configuration.proposed_configuration[0].type #=> String
resp.group_configuration.proposed_configuration[0].parameters #=> Array
resp.group_configuration.proposed_configuration[0].parameters[0].name #=> String
resp.group_configuration.proposed_configuration[0].parameters[0].values #=> Array
resp.group_configuration.proposed_configuration[0].parameters[0].values[0] #=> String
resp.group_configuration.status #=> String, one of "UPDATING", "UPDATE_COMPLETE", "UPDATE_FAILED"
resp.group_configuration.failure_reason #=> String

Options Hash (options):

  • :group (String)

    The name or the ARN of the resource group.

Returns:

See Also:

#get_group_query(options = {}) ⇒ Types::GetGroupQueryOutput

Retrieves the resource query associated with the specified resource group.

Examples:

Request syntax with placeholder values


resp = client.get_group_query({
  group_name: "GroupName",
  group: "GroupString",
})

Response structure


resp.group_query.group_name #=> String
resp.group_query.resource_query.type #=> String, one of "TAG_FILTERS_1_0", "CLOUDFORMATION_STACK_1_0"
resp.group_query.resource_query.query #=> String

Options Hash (options):

  • :group_name (String)

    Don\'t use this parameter. Use Group instead.

  • :group (String)

    The name or the ARN of the resource group to query.

Returns:

See Also:

#get_tags(options = {}) ⇒ Types::GetTagsOutput

Returns a list of tags that are associated with a resource group, specified by an ARN.

Examples:

Request syntax with placeholder values


resp = client.get_tags({
  arn: "GroupArn", # required
})

Response structure


resp.arn #=> String
resp.tags #=> Hash
resp.tags["TagKey"] #=> String

Options Hash (options):

  • :arn (required, String)

    The ARN of the resource group whose tags you want to retrieve.

Returns:

See Also:

#group_resources(options = {}) ⇒ Types::GroupResourcesOutput

Adds the specified resources to the specified group.

Examples:

Request syntax with placeholder values


resp = client.group_resources({
  group: "GroupString", # required
  resource_arns: ["ResourceArn"], # required
})

Response structure


resp.succeeded #=> Array
resp.succeeded[0] #=> String
resp.failed #=> Array
resp.failed[0].resource_arn #=> String
resp.failed[0].error_message #=> String
resp.failed[0].error_code #=> String

Options Hash (options):

  • :group (required, String)

    The name or the ARN of the resource group to add resources to.

  • :resource_arns (required, Array<String>)

    The list of ARNs for resources to be added to the group.

Returns:

See Also:

#list_group_resources(options = {}) ⇒ Types::ListGroupResourcesOutput

Returns a list of ARNs of the resources that are members of a specified resource group.

Examples:

Request syntax with placeholder values


resp = client.list_group_resources({
  group_name: "GroupName",
  group: "GroupString",
  filters: [
    {
      name: "resource-type", # required, accepts resource-type
      values: ["ResourceFilterValue"], # required
    },
  ],
  max_results: 1,
  next_token: "NextToken",
})

Response structure


resp.resource_identifiers #=> Array
resp.resource_identifiers[0].resource_arn #=> String
resp.resource_identifiers[0].resource_type #=> String
resp.next_token #=> String
resp.query_errors #=> Array
resp.query_errors[0].error_code #=> String, one of "CLOUDFORMATION_STACK_INACTIVE", "CLOUDFORMATION_STACK_NOT_EXISTING"
resp.query_errors[0].message #=> String

Options Hash (options):

  • :group_name (String)

    Don\'t use this parameter. Use Group instead.

  • :group (String)

    The name or the ARN of the resource group

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

    Filters, formatted as ResourceFilter objects, that you want to apply to a ListGroupResources operation. Filters the results to include only those of the specified resource types.

    • resource-type - Filter resources by their type. Specify up to five resource types in the format AWS::ServiceCode::ResourceType. For example, AWS::EC2::Instance, or AWS::S3::Bucket.

    ^

    When you specify a resource-type filter for ListGroupResources, AWS Resource Groups validates your filter resource types against the types that are defined in the query associated with the group. For example, if a group contains only S3 buckets because its query specifies only that resource type, but your resource-type filter includes EC2 instances, AWS Resource Groups does not filter for EC2 instances. In this case, a ListGroupResources request returns a BadRequestException error with a message similar to the following:

    The resource types specified as filters in the request are not valid.

    The error includes a list of resource types that failed the validation because they are not part of the query associated with the group. This validation doesn\'t occur when the group query specifies AWS::AllSupported, because a group based on such a query can contain any of the allowed resource types for the query type (tag-based or AWS CloudFormation stack-based queries).

  • :max_results (Integer)

    The total number of results that you want included on each page of the response. If you do not include this parameter, it defaults to a value that is specific to the operation. If additional items exist beyond the maximum you specify, the NextToken response element is present and has a value (is not null). Include that value as the NextToken request parameter in the next call to the operation to get the next part of the results. Note that the service might return fewer results than the maximum even when there are more results available. You should check NextToken after every operation to ensure that you receive all of the results.

  • :next_token (String)

    The parameter for receiving additional results if you receive a NextToken response in a previous request. A NextToken response indicates that more output is available. Set this parameter to the value provided by a previous call\'s NextToken response to indicate where the output should continue from.

Returns:

See Also:

#list_groups(options = {}) ⇒ Types::ListGroupsOutput

Returns a list of existing resource groups in your account.

Examples:

Request syntax with placeholder values


resp = client.list_groups({
  filters: [
    {
      name: "resource-type", # required, accepts resource-type, configuration-type
      values: ["GroupFilterValue"], # required
    },
  ],
  max_results: 1,
  next_token: "NextToken",
})

Response structure


resp.group_identifiers #=> Array
resp.group_identifiers[0].group_name #=> String
resp.group_identifiers[0].group_arn #=> String
resp.groups #=> Array
resp.groups[0].group_arn #=> String
resp.groups[0].name #=> String
resp.groups[0].description #=> String
resp.next_token #=> String

Options Hash (options):

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

    Filters, formatted as GroupFilter objects, that you want to apply to a ListGroups operation.

    • resource-type - Filter the results to include only those of the specified resource types. Specify up to five resource types in the format AWS::ServiceCode::ResourceType. For example, AWS::EC2::Instance, or AWS::S3::Bucket.

    • configuration-type - Filter the results to include only those groups that have the specified configuration types attached. The current supported values are:

      • AWS:EC2::CapacityReservationPool

      ^

  • :max_results (Integer)

    The total number of results that you want included on each page of the response. If you do not include this parameter, it defaults to a value that is specific to the operation. If additional items exist beyond the maximum you specify, the NextToken response element is present and has a value (is not null). Include that value as the NextToken request parameter in the next call to the operation to get the next part of the results. Note that the service might return fewer results than the maximum even when there are more results available. You should check NextToken after every operation to ensure that you receive all of the results.

  • :next_token (String)

    The parameter for receiving additional results if you receive a NextToken response in a previous request. A NextToken response indicates that more output is available. Set this parameter to the value provided by a previous call\'s NextToken response to indicate where the output should continue from.

Returns:

See Also:

#search_resources(options = {}) ⇒ Types::SearchResourcesOutput

Returns a list of AWS resource identifiers that matches the specified query. The query uses the same format as a resource query in a CreateGroup or UpdateGroupQuery operation.

Examples:

Request syntax with placeholder values


resp = client.search_resources({
  resource_query: { # required
    type: "TAG_FILTERS_1_0", # required, accepts TAG_FILTERS_1_0, CLOUDFORMATION_STACK_1_0
    query: "Query", # required
  },
  max_results: 1,
  next_token: "NextToken",
})

Response structure


resp.resource_identifiers #=> Array
resp.resource_identifiers[0].resource_arn #=> String
resp.resource_identifiers[0].resource_type #=> String
resp.next_token #=> String
resp.query_errors #=> Array
resp.query_errors[0].error_code #=> String, one of "CLOUDFORMATION_STACK_INACTIVE", "CLOUDFORMATION_STACK_NOT_EXISTING"
resp.query_errors[0].message #=> String

Options Hash (options):

  • :resource_query (required, Types::ResourceQuery)

    The search query, using the same formats that are supported for resource group definition. For more information, see CreateGroup.

  • :max_results (Integer)

    The total number of results that you want included on each page of the response. If you do not include this parameter, it defaults to a value that is specific to the operation. If additional items exist beyond the maximum you specify, the NextToken response element is present and has a value (is not null). Include that value as the NextToken request parameter in the next call to the operation to get the next part of the results. Note that the service might return fewer results than the maximum even when there are more results available. You should check NextToken after every operation to ensure that you receive all of the results.

  • :next_token (String)

    The parameter for receiving additional results if you receive a NextToken response in a previous request. A NextToken response indicates that more output is available. Set this parameter to the value provided by a previous call\'s NextToken response to indicate where the output should continue from.

Returns:

See Also:

#tag(options = {}) ⇒ Types::TagOutput

Adds tags to a resource group with the specified ARN. Existing tags on a resource group are not changed if they are not specified in the request parameters.

Do not store personally identifiable information (PII) or other confidential or sensitive information in tags. We use tags to provide you with billing and administration services. Tags are not intended to be used for private or sensitive data.

Examples:

Request syntax with placeholder values


resp = client.tag({
  arn: "GroupArn", # required
  tags: { # required
    "TagKey" => "TagValue",
  },
})

Response structure


resp.arn #=> String
resp.tags #=> Hash
resp.tags["TagKey"] #=> String

Options Hash (options):

  • :arn (required, String)

    The ARN of the resource group to which to add tags.

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

    The tags to add to the specified resource group. A tag is a string-to-string map of key-value pairs.

Returns:

See Also:

#ungroup_resources(options = {}) ⇒ Types::UngroupResourcesOutput

Removes the specified resources from the specified group.

Examples:

Request syntax with placeholder values


resp = client.ungroup_resources({
  group: "GroupString", # required
  resource_arns: ["ResourceArn"], # required
})

Response structure


resp.succeeded #=> Array
resp.succeeded[0] #=> String
resp.failed #=> Array
resp.failed[0].resource_arn #=> String
resp.failed[0].error_message #=> String
resp.failed[0].error_code #=> String

Options Hash (options):

  • :group (required, String)

    The name or the ARN of the resource group from which to remove the resources.

  • :resource_arns (required, Array<String>)

    The ARNs of the resources to be removed from the group.

Returns:

See Also:

#untag(options = {}) ⇒ Types::UntagOutput

Deletes tags from a specified resource group.

Examples:

Request syntax with placeholder values


resp = client.untag({
  arn: "GroupArn", # required
  keys: ["TagKey"], # required
})

Response structure


resp.arn #=> String
resp.keys #=> Array
resp.keys[0] #=> String

Options Hash (options):

  • :arn (required, String)

    The ARN of the resource group from which to remove tags. The command removed both the specified keys and any values associated with those keys.

  • :keys (required, Array<String>)

    The keys of the tags to be removed.

Returns:

See Also:

#update_group(options = {}) ⇒ Types::UpdateGroupOutput

Updates the description for an existing group. You cannot update the name of a resource group.

Examples:

Request syntax with placeholder values


resp = client.update_group({
  group_name: "GroupName",
  group: "GroupString",
  description: "Description",
})

Response structure


resp.group.group_arn #=> String
resp.group.name #=> String
resp.group.description #=> String

Options Hash (options):

  • :group_name (String)

    Don\'t use this parameter. Use Group instead.

  • :group (String)

    The name or the ARN of the resource group to modify.

  • :description (String)

    The new description that you want to update the resource group with. Descriptions can contain letters, numbers, hyphens, underscores, periods, and spaces.

Returns:

See Also:

#update_group_query(options = {}) ⇒ Types::UpdateGroupQueryOutput

Updates the resource query of a group.

Examples:

Request syntax with placeholder values


resp = client.update_group_query({
  group_name: "GroupName",
  group: "GroupString",
  resource_query: { # required
    type: "TAG_FILTERS_1_0", # required, accepts TAG_FILTERS_1_0, CLOUDFORMATION_STACK_1_0
    query: "Query", # required
  },
})

Response structure


resp.group_query.group_name #=> String
resp.group_query.resource_query.type #=> String, one of "TAG_FILTERS_1_0", "CLOUDFORMATION_STACK_1_0"
resp.group_query.resource_query.query #=> String

Options Hash (options):

  • :group_name (String)

    Don\'t use this parameter. Use Group instead.

  • :group (String)

    The name or the ARN of the resource group to query.

  • :resource_query (required, Types::ResourceQuery)

    The resource query to determine which AWS resources are members of this resource group.

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.