You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.
Class: Aws::Synthetics::Client
- Inherits:
-
Seahorse::Client::Base
- Object
- Seahorse::Client::Base
- Aws::Synthetics::Client
- Defined in:
- (unknown)
Overview
An API client for Synthetics. To construct a client, you need to configure a :region
and :credentials
.
synthetics = Aws::Synthetics::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::Synthetics::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::Synthetics::Client
constructor
Constructs an API client.
API Operations collapse
-
#create_canary(options = {}) ⇒ Types::CreateCanaryResponse
Creates a canary.
-
#delete_canary(options = {}) ⇒ Struct
Permanently deletes the specified canary.
When you delete a canary, resources used and created by the canary are not automatically deleted.
-
#describe_canaries(options = {}) ⇒ Types::DescribeCanariesResponse
This operation returns a list of the canaries in your account, along with full details about each canary.
This operation does not have resource-level authorization, so if a user is able to use
DescribeCanaries
, the user can see all of the canaries in the account. -
#describe_canaries_last_run(options = {}) ⇒ Types::DescribeCanariesLastRunResponse
Use this operation to see information from the most recent run of each canary that you have created.
.
-
#describe_runtime_versions(options = {}) ⇒ Types::DescribeRuntimeVersionsResponse
Returns a list of Synthetics canary runtime versions.
-
#get_canary(options = {}) ⇒ Types::GetCanaryResponse
Retrieves complete information about one canary.
-
#get_canary_runs(options = {}) ⇒ Types::GetCanaryRunsResponse
Retrieves a list of runs for a specified canary.
.
-
#list_tags_for_resource(options = {}) ⇒ Types::ListTagsForResourceResponse
Displays the tags associated with a canary.
.
-
#start_canary(options = {}) ⇒ Struct
Use this operation to run a canary that has already been created.
-
#stop_canary(options = {}) ⇒ Struct
Stops the canary to prevent all future runs.
-
#tag_resource(options = {}) ⇒ Struct
Assigns one or more tags (key-value pairs) to the specified canary.
-
#untag_resource(options = {}) ⇒ Struct
Removes one or more tags from the specified canary.
.
-
#update_canary(options = {}) ⇒ Struct
Use this operation to change the settings of a canary that has already been created.
You can't use this operation to update the tags of an existing canary.
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::Synthetics::Client
Constructs an API client.
Instance Method Details
#create_canary(options = {}) ⇒ Types::CreateCanaryResponse
Creates a canary. Canaries are scripts that monitor your endpoints and APIs from the outside-in. Canaries help you check the availability and latency of your web services and troubleshoot anomalies by investigating load time data, screenshots of the UI, logs, and metrics. You can set up a canary to run continuously or just once.
Do not use CreateCanary
to modify an existing canary. Use UpdateCanary instead.
To create canaries, you must have the CloudWatchSyntheticsFullAccess
policy. If you are creating a new IAM role for the canary, you also need the the iam:CreateRole
, iam:CreatePolicy
and iam:AttachRolePolicy
permissions. For more information, see Necessary Roles and Permissions.
Do not include secrets or proprietary information in your canary names. The canary name makes up part of the Amazon Resource Name (ARN) for the canary, and the ARN is included in outbound calls over the internet. For more information, see Security Considerations for Synthetics Canaries.
#delete_canary(options = {}) ⇒ Struct
Permanently deletes the specified canary.
When you delete a canary, resources used and created by the canary are not automatically deleted. After you delete a canary that you do not intend to use again, you should also delete the following:
-
The Lambda functions and layers used by this canary. These have the prefix
cwsyn-MyCanaryName
. -
The CloudWatch alarms created for this canary. These alarms have a name of
Synthetics-SharpDrop-Alarm-MyCanaryName
. -
Amazon S3 objects and buckets, such as the canary's artifact location.
-
IAM roles created for the canary. If they were created in the console, these roles have the name
role/service-role/CloudWatchSyntheticsRole-MyCanaryName
. -
CloudWatch Logs log groups created for the canary. These logs groups have the name
/aws/lambda/cwsyn-MyCanaryName
.
Before you delete a canary, you might want to use GetCanary
to display the information about this canary. Make note of the information returned by this operation so that you can delete these resources after you delete the canary.
#describe_canaries(options = {}) ⇒ Types::DescribeCanariesResponse
This operation returns a list of the canaries in your account, along with full details about each canary.
This operation does not have resource-level authorization, so if a user is able to use DescribeCanaries
, the user can see all of the canaries in the account. A deny policy can only be used to restrict access to all canaries. It cannot be used on specific resources.
#describe_canaries_last_run(options = {}) ⇒ Types::DescribeCanariesLastRunResponse
Use this operation to see information from the most recent run of each canary that you have created.
#describe_runtime_versions(options = {}) ⇒ Types::DescribeRuntimeVersionsResponse
Returns a list of Synthetics canary runtime versions. For more information, see Canary Runtime Versions.
#get_canary(options = {}) ⇒ Types::GetCanaryResponse
Retrieves complete information about one canary. You must specify the name of the canary that you want. To get a list of canaries and their names, use DescribeCanaries.
#get_canary_runs(options = {}) ⇒ Types::GetCanaryRunsResponse
Retrieves a list of runs for a specified canary.
#list_tags_for_resource(options = {}) ⇒ Types::ListTagsForResourceResponse
Displays the tags associated with a canary.
#start_canary(options = {}) ⇒ Struct
Use this operation to run a canary that has already been created. The frequency of the canary runs is determined by the value of the canary's Schedule
. To see a canary's schedule, use GetCanary.
#stop_canary(options = {}) ⇒ Struct
Stops the canary to prevent all future runs. If the canary is currently running, Synthetics stops waiting for the current run of the specified canary to complete. The run that is in progress completes on its own, publishes metrics, and uploads artifacts, but it is not recorded in Synthetics as a completed run.
You can use StartCanary
to start it running again with the canary’s current schedule at any point in the future.
#tag_resource(options = {}) ⇒ Struct
Assigns one or more tags (key-value pairs) to the specified canary.
Tags can help you organize and categorize your resources. You can also use them to scope user permissions, by granting a user permission to access or change only resources with certain tag values.
Tags don't have any semantic meaning to AWS and are interpreted strictly as strings of characters.
You can use the TagResource
action with a canary that already has tags. If you specify a new tag key for the alarm, this tag is appended to the list of tags associated with the alarm. If you specify a tag key that is already associated with the alarm, the new tag value that you specify replaces the previous value for that tag.
You can associate as many as 50 tags with a canary.
#untag_resource(options = {}) ⇒ Struct
Removes one or more tags from the specified canary.
#update_canary(options = {}) ⇒ Struct
Use this operation to change the settings of a canary that has already been created.
You can't use this operation to update the tags of an existing canary. To change the tags of an existing canary, use TagResource.
#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: |
---|