Note

You are viewing the documentation for an older version of boto (boto2).

Boto3, the next version of Boto, is now stable and recommended for general use. It can be used side-by-side with Boto in the same project, so it is easy to start using Boto3 in your existing projects as well as new projects. Going forward, API updates and all new feature work will be focused on Boto3.

For more information, see the documentation for boto3.

CloudTrail

boto.cloudtrail

boto.cloudtrail.connect_to_region(region_name, **kw_params)
boto.cloudtrail.regions()

Get all available regions for the AWS Cloudtrail service.

Return type:list
Returns:A list of boto.regioninfo.RegionInfo

boto.cloudtrail.layer1

class boto.cloudtrail.layer1.CloudTrailConnection(**kwargs)

AWS CloudTrail This is the CloudTrail API Reference. It provides descriptions of actions, data types, common parameters, and common errors for CloudTrail.

CloudTrail is a web service that records AWS API calls for your AWS account and delivers log files to an Amazon S3 bucket. The recorded information includes the identity of the user, the start time of the AWS API call, the source IP address, the request parameters, and the response elements returned by the service.

As an alternative to using the API, you can use one of the AWS SDKs, which consist of libraries and sample code for various programming languages and platforms (Java, Ruby, .NET, iOS, Android, etc.). The SDKs provide a convenient way to create programmatic access to AWSCloudTrail. For example, the SDKs take care of cryptographically signing requests, managing errors, and retrying requests automatically. For information about the AWS SDKs, including how to download and install them, see the `Tools for Amazon Web Services page`_.

See the CloudTrail User Guide for information about the data that is included with each AWS API call listed in the log files.

APIVersion = '2013-11-01'
DefaultRegionEndpoint = 'cloudtrail.us-east-1.amazonaws.com'
DefaultRegionName = 'us-east-1'
ResponseError

alias of JSONResponseError

ServiceName = 'CloudTrail'
TargetPrefix = 'com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101'
create_trail(name, s3_bucket_name, s3_key_prefix=None, sns_topic_name=None, include_global_service_events=None, cloud_watch_logs_log_group_arn=None, cloud_watch_logs_role_arn=None)

From the command line, use create-subscription.

Creates a trail that specifies the settings for delivery of log data to an Amazon S3 bucket.

Parameters:
  • name (string) – Specifies the name of the trail.
  • s3_bucket_name (string) – Specifies the name of the Amazon S3 bucket designated for publishing log files.
  • s3_key_prefix (string) – Specifies the Amazon S3 key prefix that precedes the name of the bucket you have designated for log file delivery.
  • sns_topic_name (string) – Specifies the name of the Amazon SNS topic defined for notification of log file delivery.
  • include_global_service_events (boolean) – Specifies whether the trail is publishing events from global services such as IAM to the log files.
  • 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 users log group.
delete_trail(name)

Deletes a trail.

Parameters:name (string) – The name of a trail to be deleted.
describe_trails(trail_name_list=None)

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

Parameters:trail_name_list (list) – The trail returned.
get_trail_status(name)

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.

Parameters:name (string) – The name of the trail for which you are requesting the current status.
lookup_events(lookup_attributes=None, start_time=None, end_time=None, max_results=None, next_token=None)

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 five different attributes: time range (defined by a start time and end time), user name, event name, resource type, and resource name. All attributes are optional. The maximum number of attributes that can be specified in any one lookup request are time range and one other attribute. 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.

Parameters:
  • lookup_attributes (list) – Contains a list of lookup attributes. Currently the list can contain only one item.
  • start_time (timestamp) – 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 (timestamp) – 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.
make_request(action, body)
start_logging(name)

Starts the recording of AWS API calls and log file delivery for a trail.

Parameters:name (string) – The name of the trail for which CloudTrail logs AWS API calls.
stop_logging(name)

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.

Parameters:name (string) – Communicates to CloudTrail the name of the trail for which to stop logging AWS API calls.
update_trail(name, s3_bucket_name=None, s3_key_prefix=None, sns_topic_name=None, include_global_service_events=None, cloud_watch_logs_log_group_arn=None, cloud_watch_logs_role_arn=None)

From the command line, use update-subscription.

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.

Parameters:
  • name (string) – Specifies the name of the trail.
  • s3_bucket_name (string) – Specifies the name of the Amazon S3 bucket designated for publishing log files.
  • s3_key_prefix (string) – Specifies the Amazon S3 key prefix that precedes the name of the bucket you have designated for log file delivery.
  • sns_topic_name (string) – Specifies the name of the Amazon SNS topic defined for notification of log file delivery.
  • include_global_service_events (boolean) – Specifies whether the trail is publishing events from global services such as IAM to the log files.
  • 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 users log group.

boto.cloudtrail.exceptions

Exceptions that are specific to the cloudtrail module.

exception boto.cloudtrail.exceptions.CloudWatchLogsDeliveryUnavailableException(status, reason, body=None, *args)
exception boto.cloudtrail.exceptions.InsufficientS3BucketPolicyException(status, reason, body=None, *args)

Raised when the S3 bucket does not allow Cloudtrail to write files into the prefix.

exception boto.cloudtrail.exceptions.InsufficientSnsTopicPolicyException(status, reason, body=None, *args)

Raised when the SNS topic does not allow Cloudtrail to post messages.

exception boto.cloudtrail.exceptions.InternalErrorException(status, reason, body=None, *args)

Raised when there was an internal Cloudtrail error.

exception boto.cloudtrail.exceptions.InvalidCloudWatchLogsLogGroupArnException(status, reason, body=None, *args)
exception boto.cloudtrail.exceptions.InvalidCloudWatchLogsRoleArnException(status, reason, body=None, *args)
exception boto.cloudtrail.exceptions.InvalidLookupAttributesException(status, reason, body=None, *args)
exception boto.cloudtrail.exceptions.InvalidMaxResultsException(status, reason, body=None, *args)
exception boto.cloudtrail.exceptions.InvalidNextTokenException(status, reason, body=None, *args)
exception boto.cloudtrail.exceptions.InvalidS3BucketNameException(status, reason, body=None, *args)

Raised when an invalid S3 bucket name is passed to Cloudtrail.

exception boto.cloudtrail.exceptions.InvalidS3PrefixException(status, reason, body=None, *args)

Raised when an invalid key prefix is given.

exception boto.cloudtrail.exceptions.InvalidSnsTopicNameException(status, reason, body=None, *args)

Raised when an invalid SNS topic name is passed to Cloudtrail.

exception boto.cloudtrail.exceptions.InvalidTimeRangeException(status, reason, body=None, *args)
exception boto.cloudtrail.exceptions.InvalidTrailNameException(status, reason, body=None, *args)

Raised when the trail name is invalid.

exception boto.cloudtrail.exceptions.MaximumNumberOfTrailsExceededException(status, reason, body=None, *args)

Raised when no more trails can be created.

exception boto.cloudtrail.exceptions.S3BucketDoesNotExistException(status, reason, body=None, *args)

Raised when the given S3 bucket does not exist.

exception boto.cloudtrail.exceptions.TrailAlreadyExistsException(status, reason, body=None, *args)

Raised when the given trail name already exists.

exception boto.cloudtrail.exceptions.TrailNotFoundException(status, reason, body=None, *args)

Raised when the given trail name is not found.

exception boto.cloudtrail.exceptions.TrailNotProvidedException(status, reason, body=None, *args)

Raised when no trail name was provided.