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

Class: Aws::CloudTrail::Client

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

Overview

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

cloudtrail = Aws::CloudTrail::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::CloudTrail::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::CloudTrail::Client

Constructs an API client.

Options Hash (options):

  • :access_key_id (String)

    Used to set credentials statically. See Plugins::RequestSigner 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.
  • :endpoint (String)

    A default endpoint is constructed from the :region. See Plugins::RegionalEndpoint 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 Aws::ClientStubs#stub_responses. See Aws::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

#add_tags(options = {}) ⇒ Struct

Adds one or more tags to a trail, up to a limit of 50. Tags must be unique per trail. Overwrites an existing tag's value when a new value is specified for an existing tag key. If you specify a key without a value, the tag will be created with the specified key and a value of null. You can tag a trail that applies to all regions only from the region in which the trail was created (that is, from its home region).

Examples:

Request syntax with placeholder values


resp = client.add_tags({
  resource_id: "String", # required
  tags_list: [
    {
      key: "String", # required
      value: "String",
    },
  ],
})

Options Hash (options):

  • :resource_id (required, String)

    Specifies the ARN of the trail to which one or more tags will be added. The format of a trail ARN is:

    arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail

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

    Contains a list of CloudTrail tags, up to a limit of 50

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#create_trail(options = {}) ⇒ Types::CreateTrailResponse

Creates a trail that specifies the settings for delivery of log data to an Amazon S3 bucket. A maximum of five trails can exist in a region, irrespective of the region in which they were created.

Examples:

Request syntax with placeholder values


resp = client.create_trail({
  name: "String", # required
  s3_bucket_name: "String", # required
  s3_key_prefix: "String",
  sns_topic_name: "String",
  include_global_service_events: false,
  is_multi_region_trail: false,
  enable_log_file_validation: false,
  cloud_watch_logs_log_group_arn: "String",
  cloud_watch_logs_role_arn: "String",
  kms_key_id: "String",
})

Response structure


resp.name #=> String
resp.s3_bucket_name #=> String
resp.s3_key_prefix #=> String
resp.sns_topic_name #=> String
resp.sns_topic_arn #=> String
resp.include_global_service_events #=> true/false
resp.is_multi_region_trail #=> true/false
resp.trail_arn #=> String
resp.log_file_validation_enabled #=> true/false
resp.cloud_watch_logs_log_group_arn #=> String
resp.cloud_watch_logs_role_arn #=> String
resp.kms_key_id #=> String

Options Hash (options):

  • :name (required, String)

    Specifies the name of the trail. The name must meet the following requirements:

    • Contain only ASCII letters (a-z, A-Z), numbers (0-9), periods (.), underscores (_), or dashes (-)

    • Start with a letter or number, and end with a letter or number

    • Be between 3 and 128 characters

    • Have no adjacent periods, underscores or dashes. Names like my-_namespace and my--namespace are invalid.

    • Not be in IP address format (for example, 192.168.5.4)

  • :s3_bucket_name (required, String)

    Specifies the name of the Amazon S3 bucket designated for publishing log files. See Amazon S3 Bucket Naming Requirements.

  • :s3_key_prefix (String)

    Specifies the Amazon S3 key prefix that comes after the name of the bucket you have designated for log file delivery. For more information, see Finding Your CloudTrail Log Files. The maximum length is 200 characters.

  • :sns_topic_name (String)

    Specifies the name of the Amazon SNS topic defined for notification of log file delivery. The maximum length is 256 characters.

  • :include_global_service_events (Boolean)

    Specifies whether the trail is publishing events from global services such as IAM to the log files.

  • :is_multi_region_trail (Boolean)

    Specifies whether the trail is created in the current region or in all regions. The default is false.

  • :enable_log_file_validation (Boolean)

    Specifies whether log file integrity validation is enabled. The default is false.

    When you disable log file integrity validation, the chain of digest files is broken after one hour. CloudTrail will not create digest files for log files that were delivered during a period in which log file integrity validation was disabled. For example, if you enable log file integrity validation at noon on January 1, disable it at noon on January 2, and re-enable it at noon on January 10, digest files will not be created for the log files delivered from noon on January 2 to noon on January 10. The same applies whenever you stop CloudTrail logging or delete a trail.

  • :cloud_watch_logs_log_group_arn (String)

    Specifies a log group name using an Amazon Resource Name (ARN), a unique identifier that represents the log group to which CloudTrail logs will be delivered. Not required unless you specify CloudWatchLogsRoleArn.

  • :cloud_watch_logs_role_arn (String)

    Specifies the role for the CloudWatch Logs endpoint to assume to write to a user\'s log group.

  • :kms_key_id (String)

    Specifies the KMS key ID to use to encrypt the logs delivered by CloudTrail. The value can be an alias name prefixed by \"alias/\", a fully specified ARN to an alias, a fully specified ARN to a key, or a globally unique identifier.

    Examples:

    • alias/MyAliasName

    • arn:aws:kms:us-east-1:123456789012:alias/MyAliasName

    • arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012

    • 12345678-1234-1234-1234-123456789012

Returns:

See Also:

#delete_trail(options = {}) ⇒ Struct

Deletes a trail. This operation must be called from the region in which the trail was created. DeleteTrail cannot be called on the shadow trails (replicated trails in other regions) of a trail that is enabled in all regions.

Examples:

Request syntax with placeholder values


resp = client.delete_trail({
  name: "String", # required
})

Options Hash (options):

  • :name (required, String)

    Specifies the name or the CloudTrail ARN of the trail to be deleted. The format of a trail ARN is: arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#describe_trails(options = {}) ⇒ Types::DescribeTrailsResponse

Retrieves settings for the trail associated with the current region for your account.

Examples:

Request syntax with placeholder values


resp = client.describe_trails({
  trail_name_list: ["String"],
  include_shadow_trails: false,
})

Response structure


resp.trail_list #=> Array
resp.trail_list[0].name #=> String
resp.trail_list[0].s3_bucket_name #=> String
resp.trail_list[0].s3_key_prefix #=> String
resp.trail_list[0].sns_topic_name #=> String
resp.trail_list[0].sns_topic_arn #=> String
resp.trail_list[0].include_global_service_events #=> true/false
resp.trail_list[0].is_multi_region_trail #=> true/false
resp.trail_list[0].home_region #=> String
resp.trail_list[0].trail_arn #=> String
resp.trail_list[0].log_file_validation_enabled #=> true/false
resp.trail_list[0].cloud_watch_logs_log_group_arn #=> String
resp.trail_list[0].cloud_watch_logs_role_arn #=> String
resp.trail_list[0].kms_key_id #=> String
resp.trail_list[0].has_custom_event_selectors #=> true/false

Options Hash (options):

  • :trail_name_list (Array<String>)

    Specifies a list of trail names, trail ARNs, or both, of the trails to describe. The format of a trail ARN is:

    arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail

    If an empty list is specified, information for the trail in the current region is returned.

    • If an empty list is specified and IncludeShadowTrails is false, then information for all trails in the current region is returned.

    • If an empty list is specified and IncludeShadowTrails is null or true, then information for all trails in the current region and any associated shadow trails in other regions is returned.

    If one or more trail names are specified, information is returned only if the names match the names of trails belonging only to the current region. To return information about a trail in another region, you must specify its trail ARN.

  • :include_shadow_trails (Boolean)

    Specifies whether to include shadow trails in the response. A shadow trail is the replication in a region of a trail that was created in a different region. The default is true.

Returns:

See Also:

#get_event_selectors(options = {}) ⇒ Types::GetEventSelectorsResponse

Describes the settings for the event selectors that you configured for your trail. The information returned for your event selectors includes the following:

  • The S3 objects that you are logging for data events.

  • If your event selector includes management events.

  • If your event selector includes read-only events, write-only events, or all.

For more information, see Logging Data and Management Events for Trails in the AWS CloudTrail User Guide.

Examples:

Request syntax with placeholder values


resp = client.get_event_selectors({
  trail_name: "String", # required
})

Response structure


resp.trail_arn #=> String
resp.event_selectors #=> Array
resp.event_selectors[0].read_write_type #=> String, one of "ReadOnly", "WriteOnly", "All"
resp.event_selectors[0].include_management_events #=> true/false
resp.event_selectors[0].data_resources #=> Array
resp.event_selectors[0].data_resources[0].type #=> String
resp.event_selectors[0].data_resources[0].values #=> Array
resp.event_selectors[0].data_resources[0].values[0] #=> String

Options Hash (options):

  • :trail_name (required, String)

    Specifies the name of the trail or trail ARN. If you specify a trail name, the string must meet the following requirements:

    • Contain only ASCII letters (a-z, A-Z), numbers (0-9), periods (.), underscores (_), or dashes (-)

    • Start with a letter or number, and end with a letter or number

    • Be between 3 and 128 characters

    • Have no adjacent periods, underscores or dashes. Names like my-_namespace and my--namespace are invalid.

    • Not be in IP address format (for example, 192.168.5.4)

    If you specify a trail ARN, it must be in the format:

    arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail

Returns:

See Also:

#get_trail_status(options = {}) ⇒ Types::GetTrailStatusResponse

Returns a JSON-formatted list of information about the specified trail. Fields include information on delivery errors, Amazon SNS and Amazon S3 errors, and start and stop logging times for each trail. This operation returns trail status from a single region. To return trail status from all regions, you must call the operation on each region.

Examples:

Request syntax with placeholder values


resp = client.get_trail_status({
  name: "String", # required
})

Response structure


resp.is_logging #=> true/false
resp.latest_delivery_error #=> String
resp.latest_notification_error #=> String
resp.latest_delivery_time #=> Time
resp.latest_notification_time #=> Time
resp.start_logging_time #=> Time
resp.stop_logging_time #=> Time
resp.latest_cloud_watch_logs_delivery_error #=> String
resp.latest_cloud_watch_logs_delivery_time #=> Time
resp.latest_digest_delivery_time #=> Time
resp.latest_digest_delivery_error #=> String
resp.latest_delivery_attempt_time #=> String
resp.latest_notification_attempt_time #=> String
resp.latest_notification_attempt_succeeded #=> String
resp.latest_delivery_attempt_succeeded #=> String
resp.time_logging_started #=> String
resp.time_logging_stopped #=> String

Options Hash (options):

  • :name (required, String)

    Specifies the name or the CloudTrail ARN of the trail for which you are requesting status. To get the status of a shadow trail (a replication of the trail in another region), you must specify its ARN. The format of a trail ARN is:

    arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail

Returns:

See Also:

#list_public_keys(options = {}) ⇒ Types::ListPublicKeysResponse

Returns all public keys whose private keys were used to sign the digest files within the specified time range. The public key is needed to validate digest files that were signed with its corresponding private key.

CloudTrail uses different private/public key pairs per region. Each digest file is signed with a private key unique to its region. Therefore, when you validate a digest file from a particular region, you must look in the same region for its corresponding public key.

Examples:

Request syntax with placeholder values


resp = client.list_public_keys({
  start_time: Time.now,
  end_time: Time.now,
  next_token: "String",
})

Response structure


resp.public_key_list #=> Array
resp.public_key_list[0].value #=> IO
resp.public_key_list[0].validity_start_time #=> Time
resp.public_key_list[0].validity_end_time #=> Time
resp.public_key_list[0].fingerprint #=> String
resp.next_token #=> String

Options Hash (options):

  • :start_time (Time)

    Optionally specifies, in UTC, the start of the time range to look up public keys for CloudTrail digest files. If not specified, the current time is used, and the current public key is returned.

  • :end_time (Time)

    Optionally specifies, in UTC, the end of the time range to look up public keys for CloudTrail digest files. If not specified, the current time is used.

  • :next_token (String)

    Reserved for future use.

Returns:

See Also:

#list_tags(options = {}) ⇒ Types::ListTagsResponse

Lists the tags for the trail in the current region.

Examples:

Request syntax with placeholder values


resp = client.list_tags({
  resource_id_list: ["String"], # required
  next_token: "String",
})

Response structure


resp.resource_tag_list #=> Array
resp.resource_tag_list[0].resource_id #=> String
resp.resource_tag_list[0].tags_list #=> Array
resp.resource_tag_list[0].tags_list[0].key #=> String
resp.resource_tag_list[0].tags_list[0].value #=> String
resp.next_token #=> String

Options Hash (options):

  • :resource_id_list (required, Array<String>)

    Specifies a list of trail ARNs whose tags will be listed. The list has a limit of 20 ARNs. The format of a trail ARN is:

    arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail

  • :next_token (String)

    Reserved for future use.

Returns:

See Also:

#lookup_events(options = {}) ⇒ Types::LookupEventsResponse

Looks up API activity events captured by CloudTrail that create, update, or delete resources in your account. Events for a region can be looked up for the times in which you had CloudTrail turned on in that region during the last seven days. Lookup supports the following attributes:

  • Event ID

  • Event name

  • Event source

  • Resource name

  • Resource type

  • User name

All attributes are optional. The default number of results returned is 10, with a maximum of 50 possible. The response includes a token that you can use to get the next page of results.

The rate of lookup requests is limited to one per second per account. If this limit is exceeded, a throttling error occurs.

Events that occurred during the selected time range will not be available for lookup if CloudTrail logging was not enabled when the events occurred.

Examples:

Request syntax with placeholder values


resp = client.lookup_events({
  lookup_attributes: [
    {
      attribute_key: "EventId", # required, accepts EventId, EventName, Username, ResourceType, ResourceName, EventSource
      attribute_value: "String", # required
    },
  ],
  start_time: Time.now,
  end_time: Time.now,
  max_results: 1,
  next_token: "NextToken",
})

Response structure


resp.events #=> Array
resp.events[0].event_id #=> String
resp.events[0].event_name #=> String
resp.events[0].event_time #=> Time
resp.events[0].event_source #=> String
resp.events[0].username #=> String
resp.events[0].resources #=> Array
resp.events[0].resources[0].resource_type #=> String
resp.events[0].resources[0].resource_name #=> String
resp.events[0].cloud_trail_event #=> String
resp.next_token #=> String

Options Hash (options):

  • :lookup_attributes (Array<Types::LookupAttribute>)

    Contains a list of lookup attributes. Currently the list can contain only one item.

  • :start_time (Time)

    Specifies that only events that occur after or at the specified time are returned. If the specified start time is after the specified end time, an error is returned.

  • :end_time (Time)

    Specifies that only events that occur before or at the specified time are returned. If the specified end time is before the specified start time, an error is returned.

  • :max_results (Integer)

    The number of events to return. Possible values are 1 through 50. The default is 10.

  • :next_token (String)

    The token to use to get the next page of results after a previous API call. This token must be passed in with the same parameters that were specified in the the original call. For example, if the original call specified an AttributeKey of \'Username\' with a value of \'root\', the call with NextToken should include those same parameters.

Returns:

See Also:

#put_event_selectors(options = {}) ⇒ Types::PutEventSelectorsResponse

Configures an event selector for your trail. Use event selectors to specify whether you want your trail to log management and/or data events. When an event occurs in your account, CloudTrail evaluates the event selectors in all trails. For each trail, if the event matches any event selector, the trail processes and logs the event. If the event doesn't match any event selector, the trail doesn't log the event.

Example

  1. You create an event selector for a trail and specify that you want write-only events.

  2. The EC2 GetConsoleOutput and RunInstances API operations occur in your account.

  3. CloudTrail evaluates whether the events match your event selectors.

  4. The RunInstances is a write-only event and it matches your event selector. The trail logs the event.

  5. The GetConsoleOutput is a read-only event but it doesn't match your event selector. The trail doesn't log the event.

The PutEventSelectors operation must be called from the region in which the trail was created; otherwise, an InvalidHomeRegionException is thrown.

You can configure up to five event selectors for each trail. For more information, see Logging Data and Management Events for Trails in the AWS CloudTrail User Guide.

Examples:

Request syntax with placeholder values


resp = client.put_event_selectors({
  trail_name: "String", # required
  event_selectors: [ # required
    {
      read_write_type: "ReadOnly", # accepts ReadOnly, WriteOnly, All
      include_management_events: false,
      data_resources: [
        {
          type: "String",
          values: ["String"],
        },
      ],
    },
  ],
})

Response structure


resp.trail_arn #=> String
resp.event_selectors #=> Array
resp.event_selectors[0].read_write_type #=> String, one of "ReadOnly", "WriteOnly", "All"
resp.event_selectors[0].include_management_events #=> true/false
resp.event_selectors[0].data_resources #=> Array
resp.event_selectors[0].data_resources[0].type #=> String
resp.event_selectors[0].data_resources[0].values #=> Array
resp.event_selectors[0].data_resources[0].values[0] #=> String

Options Hash (options):

  • :trail_name (required, String)

    Specifies the name of the trail or trail ARN. If you specify a trail name, the string must meet the following requirements:

    • Contain only ASCII letters (a-z, A-Z), numbers (0-9), periods (.), underscores (_), or dashes (-)

    • Start with a letter or number, and end with a letter or number

    • Be between 3 and 128 characters

    • Have no adjacent periods, underscores or dashes. Names like my-_namespace and my--namespace are invalid.

    • Not be in IP address format (for example, 192.168.5.4)

    If you specify a trail ARN, it must be in the format:

    arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail

  • :event_selectors (required, Array<Types::EventSelector>)

    Specifies the settings for your event selectors. You can configure up to five event selectors for a trail.

Returns:

See Also:

#remove_tags(options = {}) ⇒ Struct

Removes the specified tags from a trail.

Examples:

Request syntax with placeholder values


resp = client.remove_tags({
  resource_id: "String", # required
  tags_list: [
    {
      key: "String", # required
      value: "String",
    },
  ],
})

Options Hash (options):

  • :resource_id (required, String)

    Specifies the ARN of the trail from which tags should be removed. The format of a trail ARN is:

    arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail

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

    Specifies a list of tags to be removed.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#start_logging(options = {}) ⇒ Struct

Starts the recording of AWS API calls and log file delivery for a trail. For a trail that is enabled in all regions, this operation must be called from the region in which the trail was created. This operation cannot be called on the shadow trails (replicated trails in other regions) of a trail that is enabled in all regions.

Examples:

Request syntax with placeholder values


resp = client.start_logging({
  name: "String", # required
})

Options Hash (options):

  • :name (required, String)

    Specifies the name or the CloudTrail ARN of the trail for which CloudTrail logs AWS API calls. The format of a trail ARN is:

    arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#stop_logging(options = {}) ⇒ Struct

Suspends the recording of AWS API calls and log file delivery for the specified trail. Under most circumstances, there is no need to use this action. You can update a trail without stopping it first. This action is the only way to stop recording. For a trail enabled in all regions, this operation must be called from the region in which the trail was created, or an InvalidHomeRegionException will occur. This operation cannot be called on the shadow trails (replicated trails in other regions) of a trail enabled in all regions.

Examples:

Request syntax with placeholder values


resp = client.stop_logging({
  name: "String", # required
})

Options Hash (options):

  • :name (required, String)

    Specifies the name or the CloudTrail ARN of the trail for which CloudTrail will stop logging AWS API calls. The format of a trail ARN is:

    arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#update_trail(options = {}) ⇒ Types::UpdateTrailResponse

Updates the settings that specify delivery of log files. Changes to a trail do not require stopping the CloudTrail service. Use this action to designate an existing bucket for log delivery. If the existing bucket has previously been a target for CloudTrail log files, an IAM policy exists for the bucket. UpdateTrail must be called from the region in which the trail was created; otherwise, an InvalidHomeRegionException is thrown.

Examples:

Request syntax with placeholder values


resp = client.update_trail({
  name: "String", # required
  s3_bucket_name: "String",
  s3_key_prefix: "String",
  sns_topic_name: "String",
  include_global_service_events: false,
  is_multi_region_trail: false,
  enable_log_file_validation: false,
  cloud_watch_logs_log_group_arn: "String",
  cloud_watch_logs_role_arn: "String",
  kms_key_id: "String",
})

Response structure


resp.name #=> String
resp.s3_bucket_name #=> String
resp.s3_key_prefix #=> String
resp.sns_topic_name #=> String
resp.sns_topic_arn #=> String
resp.include_global_service_events #=> true/false
resp.is_multi_region_trail #=> true/false
resp.trail_arn #=> String
resp.log_file_validation_enabled #=> true/false
resp.cloud_watch_logs_log_group_arn #=> String
resp.cloud_watch_logs_role_arn #=> String
resp.kms_key_id #=> String

Options Hash (options):

  • :name (required, String)

    Specifies the name of the trail or trail ARN. If Name is a trail name, the string must meet the following requirements:

    • Contain only ASCII letters (a-z, A-Z), numbers (0-9), periods (.), underscores (_), or dashes (-)

    • Start with a letter or number, and end with a letter or number

    • Be between 3 and 128 characters

    • Have no adjacent periods, underscores or dashes. Names like my-_namespace and my--namespace are invalid.

    • Not be in IP address format (for example, 192.168.5.4)

    If Name is a trail ARN, it must be in the format:

    arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail

  • :s3_bucket_name (String)

    Specifies the name of the Amazon S3 bucket designated for publishing log files. See Amazon S3 Bucket Naming Requirements.

  • :s3_key_prefix (String)

    Specifies the Amazon S3 key prefix that comes after the name of the bucket you have designated for log file delivery. For more information, see Finding Your CloudTrail Log Files. The maximum length is 200 characters.

  • :sns_topic_name (String)

    Specifies the name of the Amazon SNS topic defined for notification of log file delivery. The maximum length is 256 characters.

  • :include_global_service_events (Boolean)

    Specifies whether the trail is publishing events from global services such as IAM to the log files.

  • :is_multi_region_trail (Boolean)

    Specifies whether the trail applies only to the current region or to all regions. The default is false. If the trail exists only in the current region and this value is set to true, shadow trails (replications of the trail) will be created in the other regions. If the trail exists in all regions and this value is set to false, the trail will remain in the region where it was created, and its shadow trails in other regions will be deleted.

  • :enable_log_file_validation (Boolean)

    Specifies whether log file validation is enabled. The default is false.

    When you disable log file integrity validation, the chain of digest files is broken after one hour. CloudTrail will not create digest files for log files that were delivered during a period in which log file integrity validation was disabled. For example, if you enable log file integrity validation at noon on January 1, disable it at noon on January 2, and re-enable it at noon on January 10, digest files will not be created for the log files delivered from noon on January 2 to noon on January 10. The same applies whenever you stop CloudTrail logging or delete a trail.

  • :cloud_watch_logs_log_group_arn (String)

    Specifies a log group name using an Amazon Resource Name (ARN), a unique identifier that represents the log group to which CloudTrail logs will be delivered. Not required unless you specify CloudWatchLogsRoleArn.

  • :cloud_watch_logs_role_arn (String)

    Specifies the role for the CloudWatch Logs endpoint to assume to write to a user\'s log group.

  • :kms_key_id (String)

    Specifies the KMS key ID to use to encrypt the logs delivered by CloudTrail. The value can be an alias name prefixed by \"alias/\", a fully specified ARN to an alias, a fully specified ARN to a key, or a globally unique identifier.

    Examples:

    • alias/MyAliasName

    • arn:aws:kms:us-east-1:123456789012:alias/MyAliasName

    • arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012

    • 12345678-1234-1234-1234-123456789012

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.