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

Class: Aws::CloudTrail::Client

Inherits:
Seahorse::Client::Base show all
Includes:
Aws::ClientStubs
Defined in:
gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Base

#config, #handlers

API Operations collapse

Instance Method Summary collapse

Methods included from Aws::ClientStubs

#api_requests, #stub_data, #stub_responses

Methods inherited from Seahorse::Client::Base

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

Methods included from Seahorse::Client::HandlerBuilder

#handle, #handle_request, #handle_response

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client

Parameters:

  • options (Hash)

Options Hash (options):

  • :credentials (required, Aws::CredentialProvider)

    Your AWS credentials. This can be an instance of any one of the following classes:

    • Aws::Credentials - Used for configuring static, non-refreshing credentials.

    • Aws::InstanceProfileCredentials - Used for loading credentials from an EC2 IMDS on an EC2 instance.

    • Aws::SharedCredentials - Used for loading credentials from a shared file, such as ~/.aws/config.

    • Aws::AssumeRoleCredentials - Used when you need to assume a role.

    When :credentials are not configured directly, the following locations will be searched for credentials:

    • Aws.config[:credentials]
    • The :access_key_id, :secret_access_key, and :session_token options.
    • ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
    • ~/.aws/credentials
    • ~/.aws/config
    • EC2 IMDS instance profile - When used by default, the timeouts are very aggressive. Construct and pass an instance of Aws::InstanceProfileCredentails to enable retries and extended timeouts.
  • :region (required, String)

    The AWS region to connect to. The configured :region is used to determine the service :endpoint. When not passed, a default :region is search for in the following locations:

    • Aws.config[:region]
    • ENV['AWS_REGION']
    • ENV['AMAZON_REGION']
    • ENV['AWS_DEFAULT_REGION']
    • ~/.aws/credentials
    • ~/.aws/config
  • :access_key_id (String)
  • :active_endpoint_cache (Boolean) — default: false

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

  • :client_side_monitoring (Boolean) — default: false

    When true, client-side metrics will be collected for all API requests from this client.

  • :client_side_monitoring_client_id (String) — default: ""

    Allows you to provide an identifier for this client which will be attached to all generated client side metrics. Defaults to an empty string.

  • :client_side_monitoring_port (Integer) — default: 31000

    Required for publishing client metrics. The port that the client side monitoring agent is running on, where client metrics will be published via UDP.

  • :client_side_monitoring_publisher (Aws::ClientSideMonitoring::Publisher) — default: Aws::ClientSideMonitoring::Publisher

    Allows you to provide a custom client-side monitoring publisher class. By default, will use the Client Side Monitoring Agent Publisher.

  • :convert_params (Boolean) — default: true

    When true, an attempt is made to coerce request parameters into the required types.

  • :endpoint (String)

    The client endpoint is normally constructed from the :region option. You should only configure an :endpoint when connecting to test endpoints. This should be avalid HTTP(S) URI.

  • :endpoint_cache_max_entries (Integer) — default: 1000

    Used for the maximum size limit of the LRU cache storing endpoints data for endpoint discovery enabled operations. Defaults to 1000.

  • :endpoint_cache_max_threads (Integer) — default: 10

    Used for the maximum threads in use for polling endpoints to be cached, defaults to 10.

  • :endpoint_cache_poll_interval (Integer) — default: 60

    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.

  • :endpoint_discovery (Boolean) — default: false

    When set to true, endpoint discovery will be enabled for operations when available. Defaults to false.

  • :log_formatter (Aws::Log::Formatter) — default: Aws::Log::Formatter.default

    The log formatter.

  • :log_level (Symbol) — default: :info

    The log level to send messages to the :logger at.

  • :logger (Logger)

    The Logger instance to send log messages to. If this option is not set, logging will be disabled.

  • :profile (String) — default: "default"

    Used when loading credentials from the shared credentials file at HOME/.aws/credentials. When not specified, 'default' is used.

  • :retry_base_delay (Float) — default: 0.3

    The base delay in seconds used by the default backoff function.

  • :retry_jitter (Symbol) — default: :none

    A delay randomiser function used by the default backoff function. Some predefined functions can be referenced by name - :none, :equal, :full, otherwise a Proc that takes and returns a number.

    @see https://www.awsarchitectureblog.com/2015/03/backoff.html

  • :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.

  • :retry_max_delay (Integer) — default: 0

    The maximum number of seconds to delay between retries (0 for no limit) used by the default backoff function.

  • :secret_access_key (String)
  • :session_token (String)
  • :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.

  • :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.

  • :validate_params (Boolean) — default: true

    When true, request parameters are validated before sending the request.



206
207
208
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 206

def initialize(*args)
  super
end

Instance Method Details

#add_tags(params = {}) ⇒ 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",
    },
  ],
})

Parameters:

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

    ({})

Options Hash (params):

  • :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-2: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:



246
247
248
249
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 246

def add_tags(params = {}, options = {})
  req = build_request(:add_tags, params)
  req.send_request(options)
end

#create_trail(params = {}) ⇒ 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 #=> Boolean
resp.is_multi_region_trail #=> Boolean
resp.trail_arn #=> String
resp.log_file_validation_enabled #=> Boolean
resp.cloud_watch_logs_log_group_arn #=> String
resp.cloud_watch_logs_role_arn #=> String
resp.kms_key_id #=> String

Parameters:

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

    ({})

Options Hash (params):

  • :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-2:123456789012:alias/MyAliasName

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

    • 12345678-1234-1234-1234-123456789012

Returns:

See Also:



392
393
394
395
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 392

def create_trail(params = {}, options = {})
  req = build_request(:create_trail, params)
  req.send_request(options)
end

#delete_trail(params = {}) ⇒ 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
})

Parameters:

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

    ({})

Options Hash (params):

  • :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-2:123456789012:trail/MyTrail

Returns:

  • (Struct)

    Returns an empty response.

See Also:



419
420
421
422
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 419

def delete_trail(params = {}, options = {})
  req = build_request(:delete_trail, params)
  req.send_request(options)
end

#describe_trails(params = {}) ⇒ 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 #=> Boolean
resp.trail_list[0].is_multi_region_trail #=> Boolean
resp.trail_list[0].home_region #=> String
resp.trail_list[0].trail_arn #=> String
resp.trail_list[0].log_file_validation_enabled #=> Boolean
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 #=> Boolean

Parameters:

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

    ({})

Options Hash (params):

  • :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-2: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:



488
489
490
491
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 488

def describe_trails(params = {}, options = {})
  req = build_request(:describe_trails, params)
  req.send_request(options)
end

#get_event_selectors(params = {}) ⇒ 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:

  • If your event selector includes read-only events, write-only events, or all events. This applies to both management events and data events.

  • If your event selector includes management events.

  • If your event selector includes data events, the Amazon S3 objects or AWS Lambda functions that you are logging for data events.

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 #=> Boolean
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

Parameters:

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

    ({})

Options Hash (params):

  • :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 not valid.

    • 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-2:123456789012:trail/MyTrail

Returns:

See Also:



559
560
561
562
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 559

def get_event_selectors(params = {}, options = {})
  req = build_request(:get_event_selectors, params)
  req.send_request(options)
end

#get_trail_status(params = {}) ⇒ 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 #=> Boolean
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

Parameters:

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

    ({})

Options Hash (params):

  • :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-2:123456789012:trail/MyTrail

Returns:

See Also:



629
630
631
632
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 629

def get_trail_status(params = {}, options = {})
  req = build_request(:get_trail_status, params)
  req.send_request(options)
end

#list_public_keys(params = {}) ⇒ 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 #=> String
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

Parameters:

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

    ({})

Options Hash (params):

  • :start_time (Time, DateTime, Date, Integer, String)

    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, DateTime, Date, Integer, String)

    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:



685
686
687
688
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 685

def list_public_keys(params = {}, options = {})
  req = build_request(:list_public_keys, params)
  req.send_request(options)
end

#list_tags(params = {}) ⇒ 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

Parameters:

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

    ({})

Options Hash (params):

  • :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-2:123456789012:trail/MyTrail

  • :next_token (String)

    Reserved for future use.

Returns:

See Also:



726
727
728
729
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 726

def list_tags(params = {}, options = {})
  req = build_request(:list_tags, params)
  req.send_request(options)
end

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

Looks up management events captured by CloudTrail. Events for a region can be looked up in that region during the last 90 days. Lookup supports the following attributes:

  • AWS access key

  • Event ID

  • Event name

  • Event source

  • Read only

  • Resource name

  • Resource type

  • User name

All attributes are optional. The default number of results returned is 50, 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, ReadOnly, Username, ResourceType, ResourceName, EventSource, AccessKeyId
      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].read_only #=> String
resp.events[0].access_key_id #=> 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

Parameters:

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

    ({})

Options Hash (params):

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

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

  • :start_time (Time, DateTime, Date, Integer, String)

    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, DateTime, Date, Integer, String)

    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 50.

  • :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:



831
832
833
834
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 831

def lookup_events(params = {}, options = {})
  req = build_request(:lookup_events, params)
  req.send_request(options)
end

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

Configures an event selector for your trail. Use event selectors to further specify the management and data event settings for your trail. By default, trails created without specific event selectors will be configured to log all read and write management events, and no 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 and Limits in AWS CloudTrail 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 #=> Boolean
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

Parameters:

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

    ({})

Options Hash (params):

  • :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-2: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:



939
940
941
942
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 939

def put_event_selectors(params = {}, options = {})
  req = build_request(:put_event_selectors, params)
  req.send_request(options)
end

#remove_tags(params = {}) ⇒ 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",
    },
  ],
})

Parameters:

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

    ({})

Options Hash (params):

  • :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-2:123456789012:trail/MyTrail

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

    Specifies a list of tags to be removed.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



973
974
975
976
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 973

def remove_tags(params = {}, options = {})
  req = build_request(:remove_tags, params)
  req.send_request(options)
end

#start_logging(params = {}) ⇒ 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
})

Parameters:

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

    ({})

Options Hash (params):

  • :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-2:123456789012:trail/MyTrail

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1002
1003
1004
1005
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 1002

def start_logging(params = {}, options = {})
  req = build_request(:start_logging, params)
  req.send_request(options)
end

#stop_logging(params = {}) ⇒ 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
})

Parameters:

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

    ({})

Options Hash (params):

  • :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-2:123456789012:trail/MyTrail

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1035
1036
1037
1038
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 1035

def stop_logging(params = {}, options = {})
  req = build_request(:stop_logging, params)
  req.send_request(options)
end

#update_trail(params = {}) ⇒ 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 #=> Boolean
resp.is_multi_region_trail #=> Boolean
resp.trail_arn #=> String
resp.log_file_validation_enabled #=> Boolean
resp.cloud_watch_logs_log_group_arn #=> String
resp.cloud_watch_logs_role_arn #=> String
resp.kms_key_id #=> String

Parameters:

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

    ({})

Options Hash (params):

  • :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-2: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-2:123456789012:alias/MyAliasName

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

    • 12345678-1234-1234-1234-123456789012

Returns:

See Also:



1194
1195
1196
1197
# File 'gems/aws-sdk-cloudtrail/lib/aws-sdk-cloudtrail/client.rb', line 1194

def update_trail(params = {}, options = {})
  req = build_request(:update_trail, params)
  req.send_request(options)
end