Table of Contents
CloudTrail.
Client
¶A low-level client representing 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 Amazon Web Services API calls for your Amazon Web Services account and delivers log files to an Amazon S3 bucket. The recorded information includes the identity of the user, the start time of the Amazon Web Services API call, the source IP address, the request parameters, and the response elements returned by the service.
Note
As an alternative to the API, you can use one of the Amazon Web Services SDKs, which consist of libraries and sample code for various programming languages and platforms (Java, Ruby, .NET, iOS, Android, etc.). The SDKs provide programmatic access to CloudTrail. For example, the SDKs handle cryptographically signing requests, managing errors, and retrying requests automatically. For more information about the Amazon Web Services SDKs, including how to download and install them, see Tools to Build on Amazon Web Services .
See the CloudTrail User Guide for information about the data that is included with each Amazon Web Services API call listed in the log files.
import boto3
client = boto3.client('cloudtrail')
These are the available methods:
add_tags()
can_paginate()
cancel_query()
close()
create_event_data_store()
create_trail()
delete_event_data_store()
delete_trail()
deregister_organization_delegated_admin()
describe_query()
describe_trails()
get_channel()
get_event_data_store()
get_event_selectors()
get_import()
get_insight_selectors()
get_paginator()
get_query_results()
get_trail()
get_trail_status()
get_waiter()
list_channels()
list_event_data_stores()
list_import_failures()
list_imports()
list_public_keys()
list_queries()
list_tags()
list_trails()
lookup_events()
put_event_selectors()
put_insight_selectors()
register_organization_delegated_admin()
remove_tags()
restore_event_data_store()
start_import()
start_logging()
start_query()
stop_import()
stop_logging()
update_event_data_store()
update_trail()
Adds one or more tags to a trail or event data store, up to a limit of 50. Overwrites an existing tag's value when a new value is specified for an existing tag key. Tag key names must be unique for a trail; you cannot have two keys with the same name but different values. 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 or event data store that applies to all Amazon Web Services Regions only from the Region in which the trail or event data store was created (also known as its home region).
See also: AWS API Documentation
Request Syntax
response = client.add_tags(
ResourceId='string',
TagsList=[
{
'Key': 'string',
'Value': 'string'
},
]
)
[REQUIRED]
Specifies the ARN of the trail or event data store 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
[REQUIRED]
Contains a list of tags, up to a limit of 50
A custom key-value pair associated with a resource such as a CloudTrail trail.
The key in a key-value pair. The key must be must be no longer than 128 Unicode characters. The key must be unique for the resource to which it applies.
The value in a key-value pair of a tag. The value must be no longer than 256 Unicode characters.
dict
Response Syntax
{}
Response Structure
(dict) --
Returns the objects or data if successful. Otherwise, returns an error.
Exceptions
CloudTrail.Client.exceptions.ResourceNotFoundException
CloudTrail.Client.exceptions.CloudTrailARNInvalidException
CloudTrail.Client.exceptions.ResourceTypeNotSupportedException
CloudTrail.Client.exceptions.TagsLimitExceededException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.InvalidTagParameterException
CloudTrail.Client.exceptions.InactiveEventDataStoreException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
CloudTrail.Client.exceptions.ConflictException
can_paginate
(operation_name)¶Check if an operation can be paginated.
create_foo
, and you'd normally invoke the
operation as client.create_foo(**kwargs)
, if the
create_foo
operation can be paginated, you can use the
call client.get_paginator("create_foo")
.True
if the operation can be paginated,
False
otherwise.cancel_query
(**kwargs)¶Cancels a query if the query is not in a terminated state, such as CANCELLED
, FAILED
, TIMED_OUT
, or FINISHED
. You must specify an ARN value for EventDataStore
. The ID of the query that you want to cancel is also required. When you run CancelQuery
, the query status might show as CANCELLED
even if the operation is not yet finished.
See also: AWS API Documentation
Request Syntax
response = client.cancel_query(
EventDataStore='string',
QueryId='string'
)
[REQUIRED]
The ID of the query that you want to cancel. The QueryId
comes from the response of a StartQuery
operation.
dict
Response Syntax
{
'QueryId': 'string',
'QueryStatus': 'QUEUED'|'RUNNING'|'FINISHED'|'FAILED'|'CANCELLED'|'TIMED_OUT'
}
Response Structure
(dict) --
QueryId (string) --
The ID of the canceled query.
QueryStatus (string) --
Shows the status of a query after a CancelQuery
request. Typically, the values shown are either RUNNING
or CANCELLED
.
Exceptions
CloudTrail.Client.exceptions.EventDataStoreARNInvalidException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.InactiveEventDataStoreException
CloudTrail.Client.exceptions.InactiveQueryException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.QueryIdNotFoundException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
CloudTrail.Client.exceptions.ConflictException
close
()¶Closes underlying endpoint connections.
create_event_data_store
(**kwargs)¶Creates a new event data store.
See also: AWS API Documentation
Request Syntax
response = client.create_event_data_store(
Name='string',
AdvancedEventSelectors=[
{
'Name': 'string',
'FieldSelectors': [
{
'Field': 'string',
'Equals': [
'string',
],
'StartsWith': [
'string',
],
'EndsWith': [
'string',
],
'NotEquals': [
'string',
],
'NotStartsWith': [
'string',
],
'NotEndsWith': [
'string',
]
},
]
},
],
MultiRegionEnabled=True|False,
OrganizationEnabled=True|False,
RetentionPeriod=123,
TerminationProtectionEnabled=True|False,
TagsList=[
{
'Key': 'string',
'Value': 'string'
},
],
KmsKeyId='string'
)
[REQUIRED]
The name of the event data store.
The advanced event selectors to use to select the events for the data store. For more information about how to use advanced event selectors, see Log events by using advanced event selectors in the CloudTrail User Guide.
Advanced event selectors let you create fine-grained selectors for the following CloudTrail event record fields. They help you control costs by logging only those events that are important to you. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
readOnly
eventSource
eventName
eventCategory
resources.type
resources.ARN
You cannot apply both event selectors and advanced event selectors to a trail.
An optional, descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets".
Contains all selector statements in an advanced event selector.
A single selector statement in an advanced event selector.
A field in an event record on which to filter events to be logged. Supported fields include readOnly
, eventCategory
, eventSource
(for management events), eventName
, resources.type
, and resources.ARN
.
readOnly
** - Optional. Can be set to Equals
a value of true
or false
. If you do not add this field, CloudTrail logs both read
and write
events. A value of true
logs only read
events. A value of false
logs only write
events.eventSource
** - For filtering management events only. This can be set only to NotEquals
kms.amazonaws.com
.eventName
** - Can use any operator. You can use it to filter in or filter out any data event logged to CloudTrail, such as PutBucket
or GetSnapshotBlock
. You can have multiple values for this field, separated by commas.eventCategory
** - This is required. It must be set to Equals
, and the value must be Management
or Data
.resources.type
** - This field is required. resources.type
can only use the Equals
operator, and the value can be one of the following:AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
You can have only one resources.type
field per selector. To log data events on more than one resource type, add another selector.
resources.ARN
** - You can use any operator with resources.ARN
, but if you use Equals
or NotEquals
, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type. For example, if resources.type equals AWS::S3::Object
, the ARN must be in one of the following formats. To log all data events for all objects in a specific S3 bucket, use the StartsWith
operator, and include only the bucket ARN as the matching value. The trailing slash is intentional; do not exclude it. Replace the text between less than and greater than symbols (<>) with resource-specific information.arn:<partition>:s3:::<bucket_name>/
arn:<partition>:s3:::<bucket_name>/<object_path>/
When resources.type
equals AWS::S3::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in one of the following formats. To log events on all objects in an S3 access point, we recommend that you use only the access point ARN, don’t include the object path, and use the StartsWith
or NotStartsWith
operators.
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>/object/<object_path>
When resources.type equals AWS::Lambda::Function
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:lambda:<region>:<account_ID>:function:<function_name>
When resources.type equals AWS::DynamoDB::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>
When resources.type
equals AWS::S3Outposts::Object
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-outposts:<region>:<account_ID>:<object_path>
When resources.type
equals AWS::ManagedBlockchain::Node
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:managedblockchain:<region>:<account_ID>:nodes/<node_ID>
When resources.type
equals AWS::S3ObjectLambda::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-object-lambda:<region>:<account_ID>:accesspoint/<access_point_name>
When resources.type
equals AWS::EC2::Snapshot
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:ec2:<region>::snapshot/<snapshot_ID>
When resources.type
equals AWS::DynamoDB::Stream
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>/stream/<date_time>
When resources.type
equals AWS::Glue::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:glue:<region>:<account_ID>:table/<database_name>/<table_name>
An operator that includes events that match the exact value of the event record field specified as the value of Field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.
An operator that includes events that match the first few characters of the event record field specified as the value of Field
.
An operator that includes events that match the last few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the exact value of the event record field specified as the value of Field
.
An operator that excludes events that match the first few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the last few characters of the event record field specified as the value of Field
.
A list of tags.
A custom key-value pair associated with a resource such as a CloudTrail trail.
The key in a key-value pair. The key must be must be no longer than 128 Unicode characters. The key must be unique for the resource to which it applies.
The value in a key-value pair of a tag. The value must be no longer than 256 Unicode characters.
Specifies the KMS key ID to use to encrypt the events 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.
Warning
Disabling or deleting the KMS key, or removing CloudTrail permissions on the key, prevents CloudTrail from logging events to the event data store, and prevents users from querying the data in the event data store that was encrypted with the key. After you associate an event data store with a KMS key, the KMS key cannot be removed or changed. Before you disable or delete a KMS key that you are using with an event data store, delete or back up your event data store.
CloudTrail also supports KMS multi-Region keys. For more information about multi-Region keys, see Using multi-Region keys in the Key Management Service Developer Guide .
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
dict
Response Syntax
{
'EventDataStoreArn': 'string',
'Name': 'string',
'Status': 'CREATED'|'ENABLED'|'PENDING_DELETION',
'AdvancedEventSelectors': [
{
'Name': 'string',
'FieldSelectors': [
{
'Field': 'string',
'Equals': [
'string',
],
'StartsWith': [
'string',
],
'EndsWith': [
'string',
],
'NotEquals': [
'string',
],
'NotStartsWith': [
'string',
],
'NotEndsWith': [
'string',
]
},
]
},
],
'MultiRegionEnabled': True|False,
'OrganizationEnabled': True|False,
'RetentionPeriod': 123,
'TerminationProtectionEnabled': True|False,
'TagsList': [
{
'Key': 'string',
'Value': 'string'
},
],
'CreatedTimestamp': datetime(2015, 1, 1),
'UpdatedTimestamp': datetime(2015, 1, 1),
'KmsKeyId': 'string'
}
Response Structure
(dict) --
EventDataStoreArn (string) --
The ARN of the event data store.
Name (string) --
The name of the event data store.
Status (string) --
The status of event data store creation.
AdvancedEventSelectors (list) --
The advanced event selectors that were used to select the events for the data store.
(dict) --
Advanced event selectors let you create fine-grained selectors for the following CloudTrail event record fields. They help you control costs by logging only those events that are important to you. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
readOnly
eventSource
eventName
eventCategory
resources.type
resources.ARN
You cannot apply both event selectors and advanced event selectors to a trail.
Name (string) --
An optional, descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets".
FieldSelectors (list) --
Contains all selector statements in an advanced event selector.
(dict) --
A single selector statement in an advanced event selector.
Field (string) --
A field in an event record on which to filter events to be logged. Supported fields include readOnly
, eventCategory
, eventSource
(for management events), eventName
, resources.type
, and resources.ARN
.
readOnly
** - Optional. Can be set to Equals
a value of true
or false
. If you do not add this field, CloudTrail logs both read
and write
events. A value of true
logs only read
events. A value of false
logs only write
events.eventSource
** - For filtering management events only. This can be set only to NotEquals
kms.amazonaws.com
.eventName
** - Can use any operator. You can use it to filter in or filter out any data event logged to CloudTrail, such as PutBucket
or GetSnapshotBlock
. You can have multiple values for this field, separated by commas.eventCategory
** - This is required. It must be set to Equals
, and the value must be Management
or Data
.resources.type
** - This field is required. resources.type
can only use the Equals
operator, and the value can be one of the following:AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
You can have only one resources.type
field per selector. To log data events on more than one resource type, add another selector.
resources.ARN
** - You can use any operator with resources.ARN
, but if you use Equals
or NotEquals
, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type. For example, if resources.type equals AWS::S3::Object
, the ARN must be in one of the following formats. To log all data events for all objects in a specific S3 bucket, use the StartsWith
operator, and include only the bucket ARN as the matching value. The trailing slash is intentional; do not exclude it. Replace the text between less than and greater than symbols (<>) with resource-specific information.arn:<partition>:s3:::<bucket_name>/
arn:<partition>:s3:::<bucket_name>/<object_path>/
When resources.type
equals AWS::S3::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in one of the following formats. To log events on all objects in an S3 access point, we recommend that you use only the access point ARN, don’t include the object path, and use the StartsWith
or NotStartsWith
operators.
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>/object/<object_path>
When resources.type equals AWS::Lambda::Function
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:lambda:<region>:<account_ID>:function:<function_name>
When resources.type equals AWS::DynamoDB::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>
When resources.type
equals AWS::S3Outposts::Object
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-outposts:<region>:<account_ID>:<object_path>
When resources.type
equals AWS::ManagedBlockchain::Node
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:managedblockchain:<region>:<account_ID>:nodes/<node_ID>
When resources.type
equals AWS::S3ObjectLambda::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-object-lambda:<region>:<account_ID>:accesspoint/<access_point_name>
When resources.type
equals AWS::EC2::Snapshot
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:ec2:<region>::snapshot/<snapshot_ID>
When resources.type
equals AWS::DynamoDB::Stream
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>/stream/<date_time>
When resources.type
equals AWS::Glue::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:glue:<region>:<account_ID>:table/<database_name>/<table_name>
Equals (list) --
An operator that includes events that match the exact value of the event record field specified as the value of Field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.
StartsWith (list) --
An operator that includes events that match the first few characters of the event record field specified as the value of Field
.
EndsWith (list) --
An operator that includes events that match the last few characters of the event record field specified as the value of Field
.
NotEquals (list) --
An operator that excludes events that match the exact value of the event record field specified as the value of Field
.
NotStartsWith (list) --
An operator that excludes events that match the first few characters of the event record field specified as the value of Field
.
NotEndsWith (list) --
An operator that excludes events that match the last few characters of the event record field specified as the value of Field
.
MultiRegionEnabled (boolean) --
Indicates whether the event data store collects events from all regions, or only from the region in which it was created.
OrganizationEnabled (boolean) --
Indicates whether an event data store is collecting logged events for an organization in Organizations.
RetentionPeriod (integer) --
The retention period of an event data store, in days.
TerminationProtectionEnabled (boolean) --
Indicates whether termination protection is enabled for the event data store.
TagsList (list) --
A list of tags.
(dict) --
A custom key-value pair associated with a resource such as a CloudTrail trail.
Key (string) --
The key in a key-value pair. The key must be must be no longer than 128 Unicode characters. The key must be unique for the resource to which it applies.
Value (string) --
The value in a key-value pair of a tag. The value must be no longer than 256 Unicode characters.
CreatedTimestamp (datetime) --
The timestamp that shows when the event data store was created.
UpdatedTimestamp (datetime) --
The timestamp that shows when an event data store was updated, if applicable. UpdatedTimestamp
is always either the same or newer than the time shown in CreatedTimestamp
.
KmsKeyId (string) --
Specifies the KMS key ID that encrypts the events delivered by CloudTrail. The value is a fully specified ARN to a KMS key in the following format.
arn:aws:kms:us-east-2:123456789012:key/12345678-1234-1234-1234-123456789012
Exceptions
CloudTrail.Client.exceptions.EventDataStoreAlreadyExistsException
CloudTrail.Client.exceptions.EventDataStoreMaxLimitExceededException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.InvalidTagParameterException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.ConflictException
CloudTrail.Client.exceptions.InsufficientEncryptionPolicyException
CloudTrail.Client.exceptions.InvalidKmsKeyIdException
CloudTrail.Client.exceptions.KmsKeyNotFoundException
CloudTrail.Client.exceptions.KmsException
CloudTrail.Client.exceptions.CloudTrailAccessNotEnabledException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.OrganizationsNotInUseException
CloudTrail.Client.exceptions.OrganizationNotInAllFeaturesModeException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
create_trail
(**kwargs)¶Creates a trail that specifies the settings for delivery of log data to an Amazon S3 bucket.
See also: AWS API Documentation
Request Syntax
response = client.create_trail(
Name='string',
S3BucketName='string',
S3KeyPrefix='string',
SnsTopicName='string',
IncludeGlobalServiceEvents=True|False,
IsMultiRegionTrail=True|False,
EnableLogFileValidation=True|False,
CloudWatchLogsLogGroupArn='string',
CloudWatchLogsRoleArn='string',
KmsKeyId='string',
IsOrganizationTrail=True|False,
TagsList=[
{
'Key': 'string',
'Value': 'string'
},
]
)
[REQUIRED]
Specifies the name of the trail. The name must meet the following requirements:
my-_namespace
and my--namespace
are not valid.[REQUIRED]
Specifies the name of the Amazon S3 bucket designated for publishing log files. See Amazon S3 Bucket Naming Requirements .
Specifies whether log file integrity validation is enabled. The default is false.
Note
When you disable log file integrity validation, the chain of digest files is broken after one hour. CloudTrail does 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.
CloudWatchLogsRoleArn
.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.
CloudTrail also supports KMS multi-Region keys. For more information about multi-Region keys, see Using multi-Region keys in the Key Management Service Developer Guide .
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
A list of tags.
A custom key-value pair associated with a resource such as a CloudTrail trail.
The key in a key-value pair. The key must be must be no longer than 128 Unicode characters. The key must be unique for the resource to which it applies.
The value in a key-value pair of a tag. The value must be no longer than 256 Unicode characters.
dict
Response Syntax
{
'Name': 'string',
'S3BucketName': 'string',
'S3KeyPrefix': 'string',
'SnsTopicName': 'string',
'SnsTopicARN': 'string',
'IncludeGlobalServiceEvents': True|False,
'IsMultiRegionTrail': True|False,
'TrailARN': 'string',
'LogFileValidationEnabled': True|False,
'CloudWatchLogsLogGroupArn': 'string',
'CloudWatchLogsRoleArn': 'string',
'KmsKeyId': 'string',
'IsOrganizationTrail': True|False
}
Response Structure
(dict) --
Returns the objects or data listed below if successful. Otherwise, returns an error.
Name (string) --
Specifies the name of the trail.
S3BucketName (string) --
Specifies the name of the Amazon S3 bucket designated for publishing log files.
S3KeyPrefix (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 .
SnsTopicName (string) --
This field is no longer in use. Use SnsTopicARN.
SnsTopicARN (string) --
Specifies the ARN of the Amazon SNS topic that CloudTrail uses to send notifications when log files are delivered. The format of a topic ARN is:
arn:aws:sns:us-east-2:123456789012:MyTopic
IncludeGlobalServiceEvents (boolean) --
Specifies whether the trail is publishing events from global services such as IAM to the log files.
IsMultiRegionTrail (boolean) --
Specifies whether the trail exists in one region or in all regions.
TrailARN (string) --
Specifies the ARN of the trail that was created. The format of a trail ARN is:
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
LogFileValidationEnabled (boolean) --
Specifies whether log file integrity validation is enabled.
CloudWatchLogsLogGroupArn (string) --
Specifies the Amazon Resource Name (ARN) of the log group to which CloudTrail logs will be delivered.
CloudWatchLogsRoleArn (string) --
Specifies the role for the CloudWatch Logs endpoint to assume to write to a user's log group.
KmsKeyId (string) --
Specifies the KMS key ID that encrypts the events delivered by CloudTrail. The value is a fully specified ARN to a KMS key in the following format.
arn:aws:kms:us-east-2:123456789012:key/12345678-1234-1234-1234-123456789012
IsOrganizationTrail (boolean) --
Specifies whether the trail is an organization trail.
Exceptions
CloudTrail.Client.exceptions.MaximumNumberOfTrailsExceededException
CloudTrail.Client.exceptions.TrailAlreadyExistsException
CloudTrail.Client.exceptions.S3BucketDoesNotExistException
CloudTrail.Client.exceptions.InsufficientS3BucketPolicyException
CloudTrail.Client.exceptions.InsufficientSnsTopicPolicyException
CloudTrail.Client.exceptions.InsufficientEncryptionPolicyException
CloudTrail.Client.exceptions.InvalidS3BucketNameException
CloudTrail.Client.exceptions.InvalidS3PrefixException
CloudTrail.Client.exceptions.InvalidSnsTopicNameException
CloudTrail.Client.exceptions.InvalidKmsKeyIdException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.TrailNotProvidedException
CloudTrail.Client.exceptions.InvalidParameterCombinationException
CloudTrail.Client.exceptions.KmsKeyNotFoundException
CloudTrail.Client.exceptions.KmsKeyDisabledException
CloudTrail.Client.exceptions.KmsException
CloudTrail.Client.exceptions.InvalidCloudWatchLogsLogGroupArnException
CloudTrail.Client.exceptions.InvalidCloudWatchLogsRoleArnException
CloudTrail.Client.exceptions.CloudWatchLogsDeliveryUnavailableException
CloudTrail.Client.exceptions.InvalidTagParameterException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.CloudTrailAccessNotEnabledException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.OrganizationsNotInUseException
CloudTrail.Client.exceptions.OrganizationNotInAllFeaturesModeException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
CloudTrail.Client.exceptions.CloudTrailInvalidClientTokenIdException
CloudTrail.Client.exceptions.ConflictException
delete_event_data_store
(**kwargs)¶Disables the event data store specified by EventDataStore
, which accepts an event data store ARN. After you run DeleteEventDataStore
, the event data store enters a PENDING_DELETION
state, and is automatically deleted after a wait period of seven days. TerminationProtectionEnabled
must be set to False
on the event data store; this operation cannot work if TerminationProtectionEnabled
is True
.
After you run DeleteEventDataStore
on an event data store, you cannot run ListQueries
, DescribeQuery
, or GetQueryResults
on queries that are using an event data store in a PENDING_DELETION
state. An event data store in the PENDING_DELETION
state does not incur costs.
See also: AWS API Documentation
Request Syntax
response = client.delete_event_data_store(
EventDataStore='string'
)
[REQUIRED]
The ARN (or the ID suffix of the ARN) of the event data store to delete.
{}
Response Structure
Exceptions
CloudTrail.Client.exceptions.EventDataStoreARNInvalidException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.EventDataStoreTerminationProtectedException
CloudTrail.Client.exceptions.EventDataStoreHasOngoingImportException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
delete_trail
(**kwargs)¶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.
See also: AWS API Documentation
Request Syntax
response = client.delete_trail(
Name='string'
)
[REQUIRED]
Specifies the name or the CloudTrail ARN of the trail to be deleted. The following is the format of a trail ARN. arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
{}
Response Structure
Returns the objects or data listed below if successful. Otherwise, returns an error.
Exceptions
CloudTrail.Client.exceptions.TrailNotFoundException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.InvalidHomeRegionException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
CloudTrail.Client.exceptions.ConflictException
deregister_organization_delegated_admin
(**kwargs)¶Removes CloudTrail delegated administrator permissions from a member account in an organization.
See also: AWS API Documentation
Request Syntax
response = client.deregister_organization_delegated_admin(
DelegatedAdminAccountId='string'
)
[REQUIRED]
A delegated administrator account ID. This is a member account in an organization that is currently designated as a delegated administrator.
{}
Response Structure
Returns the following response if successful. Otherwise, returns an error.
Exceptions
CloudTrail.Client.exceptions.AccountNotFoundException
CloudTrail.Client.exceptions.AccountNotRegisteredException
CloudTrail.Client.exceptions.CloudTrailAccessNotEnabledException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.NotOrganizationManagementAccountException
CloudTrail.Client.exceptions.OrganizationNotInAllFeaturesModeException
CloudTrail.Client.exceptions.OrganizationsNotInUseException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
describe_query
(**kwargs)¶Returns metadata about a query, including query run time in milliseconds, number of events scanned and matched, and query status. You must specify an ARN for EventDataStore
, and a value for QueryID
.
See also: AWS API Documentation
Request Syntax
response = client.describe_query(
EventDataStore='string',
QueryId='string'
)
[REQUIRED]
The query ID.
dict
Response Syntax
{
'QueryId': 'string',
'QueryString': 'string',
'QueryStatus': 'QUEUED'|'RUNNING'|'FINISHED'|'FAILED'|'CANCELLED'|'TIMED_OUT',
'QueryStatistics': {
'EventsMatched': 123,
'EventsScanned': 123,
'BytesScanned': 123,
'ExecutionTimeInMillis': 123,
'CreationTime': datetime(2015, 1, 1)
},
'ErrorMessage': 'string',
'DeliveryS3Uri': 'string',
'DeliveryStatus': 'SUCCESS'|'FAILED'|'FAILED_SIGNING_FILE'|'PENDING'|'RESOURCE_NOT_FOUND'|'ACCESS_DENIED'|'ACCESS_DENIED_SIGNING_FILE'|'CANCELLED'|'UNKNOWN'
}
Response Structure
(dict) --
QueryId (string) --
The ID of the query.
QueryString (string) --
The SQL code of a query.
QueryStatus (string) --
The status of a query. Values for QueryStatus
include QUEUED
, RUNNING
, FINISHED
, FAILED
, TIMED_OUT
, or CANCELLED
QueryStatistics (dict) --
Metadata about a query, including the number of events that were matched, the total number of events scanned, the query run time in milliseconds, and the query's creation time.
EventsMatched (integer) --
The number of events that matched a query.
EventsScanned (integer) --
The number of events that the query scanned in the event data store.
BytesScanned (integer) --
The total bytes that the query scanned in the event data store. This value matches the number of bytes for which your account is billed for the query, unless the query is still running.
ExecutionTimeInMillis (integer) --
The query's run time, in milliseconds.
CreationTime (datetime) --
The creation time of the query.
ErrorMessage (string) --
The error message returned if a query failed.
DeliveryS3Uri (string) --
The URI for the S3 bucket where CloudTrail delivered query results, if applicable.
DeliveryStatus (string) --
The delivery status.
Exceptions
CloudTrail.Client.exceptions.EventDataStoreARNInvalidException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.InactiveEventDataStoreException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.QueryIdNotFoundException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
describe_trails
(**kwargs)¶Retrieves settings for one or more trails associated with the current region for your account.
See also: AWS API Documentation
Request Syntax
response = client.describe_trails(
trailNameList=[
'string',
],
includeShadowTrails=True|False
)
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.
IncludeShadowTrails
is false, then information for all trails in the current region is returned.Note
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.
dict
Response Syntax
{
'trailList': [
{
'Name': 'string',
'S3BucketName': 'string',
'S3KeyPrefix': 'string',
'SnsTopicName': 'string',
'SnsTopicARN': 'string',
'IncludeGlobalServiceEvents': True|False,
'IsMultiRegionTrail': True|False,
'HomeRegion': 'string',
'TrailARN': 'string',
'LogFileValidationEnabled': True|False,
'CloudWatchLogsLogGroupArn': 'string',
'CloudWatchLogsRoleArn': 'string',
'KmsKeyId': 'string',
'HasCustomEventSelectors': True|False,
'HasInsightSelectors': True|False,
'IsOrganizationTrail': True|False
},
]
}
Response Structure
(dict) --
Returns the objects or data listed below if successful. Otherwise, returns an error.
trailList (list) --
The list of trail objects. Trail objects with string values are only returned if values for the objects exist in a trail's configuration. For example, SNSTopicName
and SNSTopicARN
are only returned in results if a trail is configured to send SNS notifications. Similarly, KMSKeyId
only appears in results if a trail's log files are encrypted with KMS customer managed keys.
(dict) --
The settings for a trail.
Name (string) --
Name of the trail set by calling CreateTrail . The maximum length is 128 characters.
S3BucketName (string) --
Name of the Amazon S3 bucket into which CloudTrail delivers your trail files. See Amazon S3 Bucket Naming Requirements .
S3KeyPrefix (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.
SnsTopicName (string) --
This field is no longer in use. Use SnsTopicARN.
SnsTopicARN (string) --
Specifies the ARN of the Amazon SNS topic that CloudTrail uses to send notifications when log files are delivered. The following is the format of a topic ARN.
arn:aws:sns:us-east-2:123456789012:MyTopic
IncludeGlobalServiceEvents (boolean) --
Set to True to include Amazon Web Services API calls from Amazon Web Services global services such as IAM. Otherwise, False .
IsMultiRegionTrail (boolean) --
Specifies whether the trail exists only in one region or exists in all regions.
HomeRegion (string) --
The region in which the trail was created.
TrailARN (string) --
Specifies the ARN of the trail. The following is the format of a trail ARN.
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
LogFileValidationEnabled (boolean) --
Specifies whether log file validation is enabled.
CloudWatchLogsLogGroupArn (string) --
Specifies an Amazon Resource Name (ARN), a unique identifier that represents the log group to which CloudTrail logs will be delivered.
CloudWatchLogsRoleArn (string) --
Specifies the role for the CloudWatch Logs endpoint to assume to write to a user's log group.
KmsKeyId (string) --
Specifies the KMS key ID that encrypts the logs delivered by CloudTrail. The value is a fully specified ARN to a KMS key in the following format.
arn:aws:kms:us-east-2:123456789012:key/12345678-1234-1234-1234-123456789012
HasCustomEventSelectors (boolean) --
Specifies if the trail has custom event selectors.
HasInsightSelectors (boolean) --
Specifies whether a trail has insight types specified in an InsightSelector
list.
IsOrganizationTrail (boolean) --
Specifies whether the trail is an organization trail.
Exceptions
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
get_channel
(**kwargs)¶Returns information about a specific channel. Amazon Web Services services create service-linked channels to get information about CloudTrail events on your behalf. For more information about service-linked channels, see Viewing service-linked channels for CloudTrail by using the CLI .
See also: AWS API Documentation
Request Syntax
response = client.get_channel(
Channel='string'
)
[REQUIRED]
The ARN or UUID
of a channel.
{
'ChannelArn': 'string',
'Name': 'string',
'Source': 'string',
'SourceConfig': {
'ApplyToAllRegions': True|False,
'AdvancedEventSelectors': [
{
'Name': 'string',
'FieldSelectors': [
{
'Field': 'string',
'Equals': [
'string',
],
'StartsWith': [
'string',
],
'EndsWith': [
'string',
],
'NotEquals': [
'string',
],
'NotStartsWith': [
'string',
],
'NotEndsWith': [
'string',
]
},
]
},
]
},
'Destinations': [
{
'Type': 'EVENT_DATA_STORE'|'AWS_SERVICE',
'Location': 'string'
},
]
}
Response Structure
The ARN of an channel returned by a GetChannel
request.
The name of the CloudTrail channel. For service-linked channels, the value is aws-service-channel/service-name/custom-suffix
where service-name
represents the name of the Amazon Web Services service that created the channel and custom-suffix
represents the suffix generated by the Amazon Web Services service.
The event source for the CloudTrail channel.
Provides information about the advanced event selectors configured for the channel, and whether the channel applies to all regions or a single region.
Specifies whether the channel applies to a single region or to all regions.
The advanced event selectors that are configured for the channel.
Advanced event selectors let you create fine-grained selectors for the following CloudTrail event record fields. They help you control costs by logging only those events that are important to you. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
readOnly
eventSource
eventName
eventCategory
resources.type
resources.ARN
You cannot apply both event selectors and advanced event selectors to a trail.
An optional, descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets".
Contains all selector statements in an advanced event selector.
A single selector statement in an advanced event selector.
A field in an event record on which to filter events to be logged. Supported fields include readOnly
, eventCategory
, eventSource
(for management events), eventName
, resources.type
, and resources.ARN
.
readOnly
** - Optional. Can be set to Equals
a value of true
or false
. If you do not add this field, CloudTrail logs both read
and write
events. A value of true
logs only read
events. A value of false
logs only write
events.eventSource
** - For filtering management events only. This can be set only to NotEquals
kms.amazonaws.com
.eventName
** - Can use any operator. You can use it to filter in or filter out any data event logged to CloudTrail, such as PutBucket
or GetSnapshotBlock
. You can have multiple values for this field, separated by commas.eventCategory
** - This is required. It must be set to Equals
, and the value must be Management
or Data
.resources.type
** - This field is required. resources.type
can only use the Equals
operator, and the value can be one of the following:AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
You can have only one resources.type
field per selector. To log data events on more than one resource type, add another selector.
resources.ARN
** - You can use any operator with resources.ARN
, but if you use Equals
or NotEquals
, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type. For example, if resources.type equals AWS::S3::Object
, the ARN must be in one of the following formats. To log all data events for all objects in a specific S3 bucket, use the StartsWith
operator, and include only the bucket ARN as the matching value. The trailing slash is intentional; do not exclude it. Replace the text between less than and greater than symbols (<>) with resource-specific information.arn:<partition>:s3:::<bucket_name>/
arn:<partition>:s3:::<bucket_name>/<object_path>/
When resources.type
equals AWS::S3::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in one of the following formats. To log events on all objects in an S3 access point, we recommend that you use only the access point ARN, don’t include the object path, and use the StartsWith
or NotStartsWith
operators.
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>/object/<object_path>
When resources.type equals AWS::Lambda::Function
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:lambda:<region>:<account_ID>:function:<function_name>
When resources.type equals AWS::DynamoDB::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>
When resources.type
equals AWS::S3Outposts::Object
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-outposts:<region>:<account_ID>:<object_path>
When resources.type
equals AWS::ManagedBlockchain::Node
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:managedblockchain:<region>:<account_ID>:nodes/<node_ID>
When resources.type
equals AWS::S3ObjectLambda::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-object-lambda:<region>:<account_ID>:accesspoint/<access_point_name>
When resources.type
equals AWS::EC2::Snapshot
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:ec2:<region>::snapshot/<snapshot_ID>
When resources.type
equals AWS::DynamoDB::Stream
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>/stream/<date_time>
When resources.type
equals AWS::Glue::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:glue:<region>:<account_ID>:table/<database_name>/<table_name>
An operator that includes events that match the exact value of the event record field specified as the value of Field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.
An operator that includes events that match the first few characters of the event record field specified as the value of Field
.
An operator that includes events that match the last few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the exact value of the event record field specified as the value of Field
.
An operator that excludes events that match the first few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the last few characters of the event record field specified as the value of Field
.
The Amazon Web Services service that created the service-linked channel.
Contains information about the service where CloudTrail delivers events.
The type of destination for events arriving from a channel. For service-linked channels, the value is AWS_SERVICE
.
For service-linked channels, the value is the name of the Amazon Web Services service.
Exceptions
CloudTrail.Client.exceptions.ChannelARNInvalidException
CloudTrail.Client.exceptions.ChannelNotFoundException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
get_event_data_store
(**kwargs)¶Returns information about an event data store specified as either an ARN or the ID portion of the ARN.
See also: AWS API Documentation
Request Syntax
response = client.get_event_data_store(
EventDataStore='string'
)
[REQUIRED]
The ARN (or ID suffix of the ARN) of the event data store about which you want information.
{
'EventDataStoreArn': 'string',
'Name': 'string',
'Status': 'CREATED'|'ENABLED'|'PENDING_DELETION',
'AdvancedEventSelectors': [
{
'Name': 'string',
'FieldSelectors': [
{
'Field': 'string',
'Equals': [
'string',
],
'StartsWith': [
'string',
],
'EndsWith': [
'string',
],
'NotEquals': [
'string',
],
'NotStartsWith': [
'string',
],
'NotEndsWith': [
'string',
]
},
]
},
],
'MultiRegionEnabled': True|False,
'OrganizationEnabled': True|False,
'RetentionPeriod': 123,
'TerminationProtectionEnabled': True|False,
'CreatedTimestamp': datetime(2015, 1, 1),
'UpdatedTimestamp': datetime(2015, 1, 1),
'KmsKeyId': 'string'
}
Response Structure
The event data store Amazon Resource Number (ARN).
The name of the event data store.
The status of an event data store. Values can be ENABLED
and PENDING_DELETION
.
The advanced event selectors used to select events for the data store.
Advanced event selectors let you create fine-grained selectors for the following CloudTrail event record fields. They help you control costs by logging only those events that are important to you. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
readOnly
eventSource
eventName
eventCategory
resources.type
resources.ARN
You cannot apply both event selectors and advanced event selectors to a trail.
An optional, descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets".
Contains all selector statements in an advanced event selector.
A single selector statement in an advanced event selector.
A field in an event record on which to filter events to be logged. Supported fields include readOnly
, eventCategory
, eventSource
(for management events), eventName
, resources.type
, and resources.ARN
.
readOnly
** - Optional. Can be set to Equals
a value of true
or false
. If you do not add this field, CloudTrail logs both read
and write
events. A value of true
logs only read
events. A value of false
logs only write
events.eventSource
** - For filtering management events only. This can be set only to NotEquals
kms.amazonaws.com
.eventName
** - Can use any operator. You can use it to filter in or filter out any data event logged to CloudTrail, such as PutBucket
or GetSnapshotBlock
. You can have multiple values for this field, separated by commas.eventCategory
** - This is required. It must be set to Equals
, and the value must be Management
or Data
.resources.type
** - This field is required. resources.type
can only use the Equals
operator, and the value can be one of the following:AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
You can have only one resources.type
field per selector. To log data events on more than one resource type, add another selector.
resources.ARN
** - You can use any operator with resources.ARN
, but if you use Equals
or NotEquals
, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type. For example, if resources.type equals AWS::S3::Object
, the ARN must be in one of the following formats. To log all data events for all objects in a specific S3 bucket, use the StartsWith
operator, and include only the bucket ARN as the matching value. The trailing slash is intentional; do not exclude it. Replace the text between less than and greater than symbols (<>) with resource-specific information.arn:<partition>:s3:::<bucket_name>/
arn:<partition>:s3:::<bucket_name>/<object_path>/
When resources.type
equals AWS::S3::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in one of the following formats. To log events on all objects in an S3 access point, we recommend that you use only the access point ARN, don’t include the object path, and use the StartsWith
or NotStartsWith
operators.
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>/object/<object_path>
When resources.type equals AWS::Lambda::Function
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:lambda:<region>:<account_ID>:function:<function_name>
When resources.type equals AWS::DynamoDB::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>
When resources.type
equals AWS::S3Outposts::Object
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-outposts:<region>:<account_ID>:<object_path>
When resources.type
equals AWS::ManagedBlockchain::Node
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:managedblockchain:<region>:<account_ID>:nodes/<node_ID>
When resources.type
equals AWS::S3ObjectLambda::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-object-lambda:<region>:<account_ID>:accesspoint/<access_point_name>
When resources.type
equals AWS::EC2::Snapshot
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:ec2:<region>::snapshot/<snapshot_ID>
When resources.type
equals AWS::DynamoDB::Stream
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>/stream/<date_time>
When resources.type
equals AWS::Glue::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:glue:<region>:<account_ID>:table/<database_name>/<table_name>
An operator that includes events that match the exact value of the event record field specified as the value of Field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.
An operator that includes events that match the first few characters of the event record field specified as the value of Field
.
An operator that includes events that match the last few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the exact value of the event record field specified as the value of Field
.
An operator that excludes events that match the first few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the last few characters of the event record field specified as the value of Field
.
Indicates whether the event data store includes events from all regions, or only from the region in which it was created.
Indicates whether an event data store is collecting logged events for an organization in Organizations.
The retention period of the event data store, in days.
Indicates that termination protection is enabled.
The timestamp of the event data store's creation.
Shows the time that an event data store was updated, if applicable. UpdatedTimestamp
is always either the same or newer than the time shown in CreatedTimestamp
.
Specifies the KMS key ID that encrypts the events delivered by CloudTrail. The value is a fully specified ARN to a KMS key in the following format.
arn:aws:kms:us-east-2:123456789012:key/12345678-1234-1234-1234-123456789012
Exceptions
CloudTrail.Client.exceptions.EventDataStoreARNInvalidException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
get_event_selectors
(**kwargs)¶Describes the settings for the event selectors that you configured for your trail. The information returned for your event selectors includes the following:
For more information about logging management and data events, see the following topics in the CloudTrail User Guide :
See also: AWS API Documentation
Request Syntax
response = client.get_event_selectors(
TrailName='string'
)
[REQUIRED]
Specifies the name of the trail or trail ARN. If you specify a trail name, the string must meet the following requirements:
my-_namespace
and my--namespace
are not valid.If you specify a trail ARN, it must be in the format:
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
{
'TrailARN': 'string',
'EventSelectors': [
{
'ReadWriteType': 'ReadOnly'|'WriteOnly'|'All',
'IncludeManagementEvents': True|False,
'DataResources': [
{
'Type': 'string',
'Values': [
'string',
]
},
],
'ExcludeManagementEventSources': [
'string',
]
},
],
'AdvancedEventSelectors': [
{
'Name': 'string',
'FieldSelectors': [
{
'Field': 'string',
'Equals': [
'string',
],
'StartsWith': [
'string',
],
'EndsWith': [
'string',
],
'NotEquals': [
'string',
],
'NotStartsWith': [
'string',
],
'NotEndsWith': [
'string',
]
},
]
},
]
}
Response Structure
The specified trail ARN that has the event selectors.
The event selectors that are configured for the 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 selector for 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.
You can configure up to five event selectors for a trail.
You cannot apply both event selectors and advanced event selectors to a trail.
Specify if you want your trail to log read-only events, write-only events, or all. For example, the EC2 GetConsoleOutput
is a read-only API operation and RunInstances
is a write-only API operation.
By default, the value is All
.
Specify if you want your event selector to include management events for your trail.
For more information, see Management Events in the CloudTrail User Guide .
By default, the value is true
.
The first copy of management events is free. You are charged for additional copies of management events that you are logging on any subsequent trail in the same region. For more information about CloudTrail pricing, see CloudTrail Pricing .
CloudTrail supports data event logging for Amazon S3 objects, Lambda functions, and Amazon DynamoDB tables with basic event selectors. You can specify up to 250 resources for an individual event selector, but the total number of data resources cannot exceed 250 across all event selectors in a trail. This limit does not apply if you configure resource logging for all data events.
For more information, see Data Events and Limits in CloudTrail in the CloudTrail User Guide .
The Amazon S3 buckets, Lambda functions, or Amazon DynamoDB tables that you specify in your event selectors for your trail to log data events. Data events provide information about the resource operations performed on or within a resource itself. These are also known as data plane operations. You can specify up to 250 data resources for a trail.
Note
The total number of allowed data resources is 250. This number can be distributed between 1 and 5 event selectors, but the total cannot exceed 250 across all selectors.
If you are using advanced event selectors, the maximum total number of values for all conditions, across all advanced event selectors for the trail, is 500.
The following example demonstrates how logging works when you configure logging of all data events for an S3 bucket named bucket-1
. In this example, the CloudTrail user specified an empty prefix, and the option to log both Read
and Write
data events.
bucket-1
.PutObject
API operation is an Amazon S3 object-level API. It is recorded as a data event in CloudTrail. Because the CloudTrail user specified an S3 bucket with an empty prefix, events that occur on any object in that bucket are logged. The trail processes and logs the event.arn:aws:s3:::bucket-2
.PutObject
API operation occurred for an object in an S3 bucket that the CloudTrail user didn't specify for the trail. The trail doesn’t log the event.The following example demonstrates how logging works when you configure logging of Lambda data events for a Lambda function named MyLambdaFunction , but not for all Lambda functions.
Invoke
API operation on MyLambdaFunction is an Lambda API. It is recorded as a data event in CloudTrail. Because the CloudTrail user specified logging data events for MyLambdaFunction , any invocations of that function are logged. The trail processes and logs the event.Invoke
API operation on MyOtherLambdaFunction is an Lambda API. Because the CloudTrail user did not specify logging data events for all Lambda functions, the Invoke
operation for MyOtherLambdaFunction does not match the function specified for the trail. The trail doesn’t log the event.The resource type in which you want to log data events. You can specify the following basic event selector resource types:
AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
The following resource types are also available through advanced event selectors. Basic event selector resource types are valid in advanced event selectors, but advanced event selector resource types are not valid in basic event selectors. For more information, see AdvancedFieldSelector$Field .
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
An array of Amazon Resource Name (ARN) strings or partial ARN strings for the specified objects.
arn:aws:s3
.Note
This also enables logging of data event activity performed by any user or role in your Amazon Web Services account, even if that activity is performed on a bucket that belongs to another Amazon Web Services account.
arn:aws:s3:::bucket-1/
. The trail logs data events for all objects in this S3 bucket.arn:aws:s3:::bucket-1/example-images
. The trail logs data events for objects in this S3 bucket that match the prefix.arn:aws:lambda
.Note
This also enables logging of Invoke
activity performed by any user or role in your Amazon Web Services account, even if that activity is performed on a function that belongs to another Amazon Web Services account.
Note
Lambda function ARNs are exact. For example, if you specify a function ARN arn:aws:lambda:us-west-2:111111111111:function:helloworld , data events will only be logged for arn:aws:lambda:us-west-2:111111111111:function:helloworld . They will not be logged for arn:aws:lambda:us-west-2:111111111111:function:helloworld2 .
arn:aws:dynamodb
.An optional list of service event sources from which you do not want management events to be logged on your trail. In this release, the list can be empty (disables the filter), or it can filter out Key Management Service or Amazon RDS Data API events by containing kms.amazonaws.com
or rdsdata.amazonaws.com
. By default, ExcludeManagementEventSources
is empty, and KMS and Amazon RDS Data API events are logged to your trail. You can exclude management event sources only in regions that support the event source.
The advanced event selectors that are configured for the trail.
Advanced event selectors let you create fine-grained selectors for the following CloudTrail event record fields. They help you control costs by logging only those events that are important to you. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
readOnly
eventSource
eventName
eventCategory
resources.type
resources.ARN
You cannot apply both event selectors and advanced event selectors to a trail.
An optional, descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets".
Contains all selector statements in an advanced event selector.
A single selector statement in an advanced event selector.
A field in an event record on which to filter events to be logged. Supported fields include readOnly
, eventCategory
, eventSource
(for management events), eventName
, resources.type
, and resources.ARN
.
readOnly
** - Optional. Can be set to Equals
a value of true
or false
. If you do not add this field, CloudTrail logs both read
and write
events. A value of true
logs only read
events. A value of false
logs only write
events.eventSource
** - For filtering management events only. This can be set only to NotEquals
kms.amazonaws.com
.eventName
** - Can use any operator. You can use it to filter in or filter out any data event logged to CloudTrail, such as PutBucket
or GetSnapshotBlock
. You can have multiple values for this field, separated by commas.eventCategory
** - This is required. It must be set to Equals
, and the value must be Management
or Data
.resources.type
** - This field is required. resources.type
can only use the Equals
operator, and the value can be one of the following:AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
You can have only one resources.type
field per selector. To log data events on more than one resource type, add another selector.
resources.ARN
** - You can use any operator with resources.ARN
, but if you use Equals
or NotEquals
, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type. For example, if resources.type equals AWS::S3::Object
, the ARN must be in one of the following formats. To log all data events for all objects in a specific S3 bucket, use the StartsWith
operator, and include only the bucket ARN as the matching value. The trailing slash is intentional; do not exclude it. Replace the text between less than and greater than symbols (<>) with resource-specific information.arn:<partition>:s3:::<bucket_name>/
arn:<partition>:s3:::<bucket_name>/<object_path>/
When resources.type
equals AWS::S3::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in one of the following formats. To log events on all objects in an S3 access point, we recommend that you use only the access point ARN, don’t include the object path, and use the StartsWith
or NotStartsWith
operators.
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>/object/<object_path>
When resources.type equals AWS::Lambda::Function
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:lambda:<region>:<account_ID>:function:<function_name>
When resources.type equals AWS::DynamoDB::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>
When resources.type
equals AWS::S3Outposts::Object
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-outposts:<region>:<account_ID>:<object_path>
When resources.type
equals AWS::ManagedBlockchain::Node
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:managedblockchain:<region>:<account_ID>:nodes/<node_ID>
When resources.type
equals AWS::S3ObjectLambda::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-object-lambda:<region>:<account_ID>:accesspoint/<access_point_name>
When resources.type
equals AWS::EC2::Snapshot
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:ec2:<region>::snapshot/<snapshot_ID>
When resources.type
equals AWS::DynamoDB::Stream
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>/stream/<date_time>
When resources.type
equals AWS::Glue::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:glue:<region>:<account_ID>:table/<database_name>/<table_name>
An operator that includes events that match the exact value of the event record field specified as the value of Field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.
An operator that includes events that match the first few characters of the event record field specified as the value of Field
.
An operator that includes events that match the last few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the exact value of the event record field specified as the value of Field
.
An operator that excludes events that match the first few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the last few characters of the event record field specified as the value of Field
.
Exceptions
CloudTrail.Client.exceptions.TrailNotFoundException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
get_import
(**kwargs)¶Returns information about a specific import.
See also: AWS API Documentation
Request Syntax
response = client.get_import(
ImportId='string'
)
[REQUIRED]
The ID for the import.
{
'ImportId': 'string',
'Destinations': [
'string',
],
'ImportSource': {
'S3': {
'S3LocationUri': 'string',
'S3BucketRegion': 'string',
'S3BucketAccessRoleArn': 'string'
}
},
'StartEventTime': datetime(2015, 1, 1),
'EndEventTime': datetime(2015, 1, 1),
'ImportStatus': 'INITIALIZING'|'IN_PROGRESS'|'FAILED'|'STOPPED'|'COMPLETED',
'CreatedTimestamp': datetime(2015, 1, 1),
'UpdatedTimestamp': datetime(2015, 1, 1),
'ImportStatistics': {
'PrefixesFound': 123,
'PrefixesCompleted': 123,
'FilesCompleted': 123,
'EventsCompleted': 123,
'FailedEntries': 123
}
}
Response Structure
The ID of the import.
The ARN of the destination event data store.
The source S3 bucket.
The source S3 bucket.
The URI for the source S3 bucket.
The region associated with the source S3 bucket.
The IAM ARN role used to access the source S3 bucket.
Used with EndEventTime
to bound a StartImport
request, and limit imported trail events to only those events logged within a specified time period.
Used with StartEventTime
to bound a StartImport
request, and limit imported trail events to only those events logged within a specified time period.
The status of the import.
The timestamp of the import's creation.
The timestamp of when the import was updated.
Provides statistics for the import. CloudTrail does not update import statistics in real-time. Returned values for parameters such as EventsCompleted
may be lower than the actual value, because CloudTrail updates statistics incrementally over the course of the import.
The number of S3 prefixes found for the import.
The number of S3 prefixes that completed import.
The number of log files that completed import.
The number of trail events imported into the event data store.
The number of failed entries.
Exceptions
CloudTrail.Client.exceptions.ImportNotFoundException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
get_insight_selectors
(**kwargs)¶Describes the settings for the Insights event selectors that you configured for your trail. GetInsightSelectors
shows if CloudTrail Insights event logging is enabled on the trail, and if it is, which insight types are enabled. If you run GetInsightSelectors
on a trail that does not have Insights events enabled, the operation throws the exception InsightNotEnabledException
For more information, see Logging CloudTrail Insights Events for Trails in the CloudTrail User Guide .
See also: AWS API Documentation
Request Syntax
response = client.get_insight_selectors(
TrailName='string'
)
[REQUIRED]
Specifies the name of the trail or trail ARN. If you specify a trail name, the string must meet the following requirements:
my-_namespace
and my--namespace
are not valid.If you specify a trail ARN, it must be in the format:
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
{
'TrailARN': 'string',
'InsightSelectors': [
{
'InsightType': 'ApiCallRateInsight'|'ApiErrorRateInsight'
},
]
}
Response Structure
The Amazon Resource Name (ARN) of a trail for which you want to get Insights selectors.
A JSON string that contains the insight types you want to log on a trail. In this release, ApiErrorRateInsight
and ApiCallRateInsight
are supported as insight types.
A JSON string that contains a list of insight types that are logged on a trail.
The type of insights to log on a trail. ApiCallRateInsight
and ApiErrorRateInsight
are valid insight types.
Exceptions
CloudTrail.Client.exceptions.TrailNotFoundException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.InsightNotEnabledException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
get_paginator
(operation_name)¶Create a paginator for an operation.
create_foo
, and you'd normally invoke the
operation as client.create_foo(**kwargs)
, if the
create_foo
operation can be paginated, you can use the
call client.get_paginator("create_foo")
.client.can_paginate
method to
check if an operation is pageable.get_query_results
(**kwargs)¶Gets event data results of a query. You must specify the QueryID
value returned by the StartQuery
operation, and an ARN for EventDataStore
.
See also: AWS API Documentation
Request Syntax
response = client.get_query_results(
EventDataStore='string',
QueryId='string',
NextToken='string',
MaxQueryResults=123
)
[REQUIRED]
The ID of the query for which you want to get results.
dict
Response Syntax
{
'QueryStatus': 'QUEUED'|'RUNNING'|'FINISHED'|'FAILED'|'CANCELLED'|'TIMED_OUT',
'QueryStatistics': {
'ResultsCount': 123,
'TotalResultsCount': 123,
'BytesScanned': 123
},
'QueryResultRows': [
[
{
'string': 'string'
},
],
],
'NextToken': 'string',
'ErrorMessage': 'string'
}
Response Structure
(dict) --
QueryStatus (string) --
The status of the query. Values include QUEUED
, RUNNING
, FINISHED
, FAILED
, TIMED_OUT
, or CANCELLED
.
QueryStatistics (dict) --
Shows the count of query results.
ResultsCount (integer) --
The number of results returned.
TotalResultsCount (integer) --
The total number of results returned by a query.
BytesScanned (integer) --
The total bytes that the query scanned in the event data store. This value matches the number of bytes for which your account is billed for the query, unless the query is still running.
QueryResultRows (list) --
Contains the individual event results of the query.
NextToken (string) --
A token you can use to get the next page of query results.
ErrorMessage (string) --
The error message returned if a query failed.
Exceptions
CloudTrail.Client.exceptions.EventDataStoreARNInvalidException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.InactiveEventDataStoreException
CloudTrail.Client.exceptions.InvalidMaxResultsException
CloudTrail.Client.exceptions.InvalidNextTokenException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.QueryIdNotFoundException
CloudTrail.Client.exceptions.InsufficientEncryptionPolicyException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
get_trail
(**kwargs)¶Returns settings information for a specified trail.
See also: AWS API Documentation
Request Syntax
response = client.get_trail(
Name='string'
)
[REQUIRED]
The name or the Amazon Resource Name (ARN) of the trail for which you want to retrieve settings information.
{
'Trail': {
'Name': 'string',
'S3BucketName': 'string',
'S3KeyPrefix': 'string',
'SnsTopicName': 'string',
'SnsTopicARN': 'string',
'IncludeGlobalServiceEvents': True|False,
'IsMultiRegionTrail': True|False,
'HomeRegion': 'string',
'TrailARN': 'string',
'LogFileValidationEnabled': True|False,
'CloudWatchLogsLogGroupArn': 'string',
'CloudWatchLogsRoleArn': 'string',
'KmsKeyId': 'string',
'HasCustomEventSelectors': True|False,
'HasInsightSelectors': True|False,
'IsOrganizationTrail': True|False
}
}
Response Structure
The settings for a trail.
Name of the trail set by calling CreateTrail . The maximum length is 128 characters.
Name of the Amazon S3 bucket into which CloudTrail delivers your trail files. See Amazon S3 Bucket Naming Requirements .
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.
This field is no longer in use. Use SnsTopicARN.
Specifies the ARN of the Amazon SNS topic that CloudTrail uses to send notifications when log files are delivered. The following is the format of a topic ARN.
arn:aws:sns:us-east-2:123456789012:MyTopic
Set to True to include Amazon Web Services API calls from Amazon Web Services global services such as IAM. Otherwise, False .
Specifies whether the trail exists only in one region or exists in all regions.
The region in which the trail was created.
Specifies the ARN of the trail. The following is the format of a trail ARN.
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
Specifies whether log file validation is enabled.
Specifies an Amazon Resource Name (ARN), a unique identifier that represents the log group to which CloudTrail logs will be delivered.
Specifies the role for the CloudWatch Logs endpoint to assume to write to a user's log group.
Specifies the KMS key ID that encrypts the logs delivered by CloudTrail. The value is a fully specified ARN to a KMS key in the following format.
arn:aws:kms:us-east-2:123456789012:key/12345678-1234-1234-1234-123456789012
Specifies if the trail has custom event selectors.
Specifies whether a trail has insight types specified in an InsightSelector
list.
Specifies whether the trail is an organization trail.
Exceptions
CloudTrail.Client.exceptions.TrailNotFoundException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
get_trail_status
(**kwargs)¶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.
See also: AWS API Documentation
Request Syntax
response = client.get_trail_status(
Name='string'
)
[REQUIRED]
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 following is the format of a trail ARN.
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
{
'IsLogging': True|False,
'LatestDeliveryError': 'string',
'LatestNotificationError': 'string',
'LatestDeliveryTime': datetime(2015, 1, 1),
'LatestNotificationTime': datetime(2015, 1, 1),
'StartLoggingTime': datetime(2015, 1, 1),
'StopLoggingTime': datetime(2015, 1, 1),
'LatestCloudWatchLogsDeliveryError': 'string',
'LatestCloudWatchLogsDeliveryTime': datetime(2015, 1, 1),
'LatestDigestDeliveryTime': datetime(2015, 1, 1),
'LatestDigestDeliveryError': 'string',
'LatestDeliveryAttemptTime': 'string',
'LatestNotificationAttemptTime': 'string',
'LatestNotificationAttemptSucceeded': 'string',
'LatestDeliveryAttemptSucceeded': 'string',
'TimeLoggingStarted': 'string',
'TimeLoggingStopped': 'string'
}
Response Structure
Returns the objects or data listed below if successful. Otherwise, returns an error.
Whether the CloudTrail trail is currently logging Amazon Web Services API calls.
Displays any Amazon S3 error that CloudTrail encountered when attempting to deliver log files to the designated bucket. For more information, see Error Responses in the Amazon S3 API Reference.
Note
This error occurs only when there is a problem with the destination S3 bucket, and does not occur for requests that time out. To resolve the issue, create a new bucket, and then call UpdateTrail
to specify the new bucket; or fix the existing objects so that CloudTrail can again write to the bucket.
Displays any Amazon SNS error that CloudTrail encountered when attempting to send a notification. For more information about Amazon SNS errors, see the Amazon SNS Developer Guide .
Specifies the date and time that CloudTrail last delivered log files to an account's Amazon S3 bucket.
Specifies the date and time of the most recent Amazon SNS notification that CloudTrail has written a new log file to an account's Amazon S3 bucket.
Specifies the most recent date and time when CloudTrail started recording API calls for an Amazon Web Services account.
Specifies the most recent date and time when CloudTrail stopped recording API calls for an Amazon Web Services account.
Displays any CloudWatch Logs error that CloudTrail encountered when attempting to deliver logs to CloudWatch Logs.
Displays the most recent date and time when CloudTrail delivered logs to CloudWatch Logs.
Specifies the date and time that CloudTrail last delivered a digest file to an account's Amazon S3 bucket.
Displays any Amazon S3 error that CloudTrail encountered when attempting to deliver a digest file to the designated bucket. For more information, see Error Responses in the Amazon S3 API Reference.
Note
This error occurs only when there is a problem with the destination S3 bucket, and does not occur for requests that time out. To resolve the issue, create a new bucket, and then call UpdateTrail
to specify the new bucket; or fix the existing objects so that CloudTrail can again write to the bucket.
This field is no longer in use.
This field is no longer in use.
This field is no longer in use.
This field is no longer in use.
This field is no longer in use.
This field is no longer in use.
Exceptions
CloudTrail.Client.exceptions.TrailNotFoundException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
get_waiter
(waiter_name)¶Returns an object that can wait for some condition.
list_channels
(**kwargs)¶Lists the channels in the current account, and their source names. Amazon Web Services services create service-linked channels get information about CloudTrail events on your behalf. For more information about service-linked channels, see Viewing service-linked channels for CloudTrail by using the CLI .
See also: AWS API Documentation
Request Syntax
response = client.list_channels(
MaxResults=123,
NextToken='string'
)
dict
Response Syntax
{
'Channels': [
{
'ChannelArn': 'string',
'Name': 'string'
},
],
'NextToken': 'string'
}
Response Structure
(dict) --
Channels (list) --
The list of channels in the account.
(dict) --
Contains information about a returned CloudTrail channel.
ChannelArn (string) --
The Amazon Resource Name (ARN) of a channel.
Name (string) --
The name of the CloudTrail channel. For service-linked channels, the name is aws-service-channel/service-name/custom-suffix
where service-name
represents the name of the Amazon Web Services service that created the channel and custom-suffix
represents the suffix created by the Amazon Web Services service.
NextToken (string) --
The token to use to get the next page of results after a previous API call.
Exceptions
CloudTrail.Client.exceptions.InvalidNextTokenException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
list_event_data_stores
(**kwargs)¶Returns information about all event data stores in the account, in the current region.
See also: AWS API Documentation
Request Syntax
response = client.list_event_data_stores(
NextToken='string',
MaxResults=123
)
dict
Response Syntax
{
'EventDataStores': [
{
'EventDataStoreArn': 'string',
'Name': 'string',
'TerminationProtectionEnabled': True|False,
'Status': 'CREATED'|'ENABLED'|'PENDING_DELETION',
'AdvancedEventSelectors': [
{
'Name': 'string',
'FieldSelectors': [
{
'Field': 'string',
'Equals': [
'string',
],
'StartsWith': [
'string',
],
'EndsWith': [
'string',
],
'NotEquals': [
'string',
],
'NotStartsWith': [
'string',
],
'NotEndsWith': [
'string',
]
},
]
},
],
'MultiRegionEnabled': True|False,
'OrganizationEnabled': True|False,
'RetentionPeriod': 123,
'CreatedTimestamp': datetime(2015, 1, 1),
'UpdatedTimestamp': datetime(2015, 1, 1)
},
],
'NextToken': 'string'
}
Response Structure
(dict) --
EventDataStores (list) --
Contains information about event data stores in the account, in the current region.
(dict) --
A storage lake of event data against which you can run complex SQL-based queries. An event data store can include events that you have logged on your account from the last 90 to 2557 days (about three months to up to seven years). To select events for an event data store, use advanced event selectors .
EventDataStoreArn (string) --
The ARN of the event data store.
Name (string) --
The name of the event data store.
TerminationProtectionEnabled (boolean) --
This field is being deprecated. Indicates whether the event data store is protected from termination.
Status (string) --
This field is being deprecated. The status of an event data store. Values are ENABLED
and PENDING_DELETION
.
AdvancedEventSelectors (list) --
This field is being deprecated. The advanced event selectors that were used to select events for the data store.
(dict) --
Advanced event selectors let you create fine-grained selectors for the following CloudTrail event record fields. They help you control costs by logging only those events that are important to you. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
readOnly
eventSource
eventName
eventCategory
resources.type
resources.ARN
You cannot apply both event selectors and advanced event selectors to a trail.
Name (string) --
An optional, descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets".
FieldSelectors (list) --
Contains all selector statements in an advanced event selector.
(dict) --
A single selector statement in an advanced event selector.
Field (string) --
A field in an event record on which to filter events to be logged. Supported fields include readOnly
, eventCategory
, eventSource
(for management events), eventName
, resources.type
, and resources.ARN
.
readOnly
** - Optional. Can be set to Equals
a value of true
or false
. If you do not add this field, CloudTrail logs both read
and write
events. A value of true
logs only read
events. A value of false
logs only write
events.eventSource
** - For filtering management events only. This can be set only to NotEquals
kms.amazonaws.com
.eventName
** - Can use any operator. You can use it to filter in or filter out any data event logged to CloudTrail, such as PutBucket
or GetSnapshotBlock
. You can have multiple values for this field, separated by commas.eventCategory
** - This is required. It must be set to Equals
, and the value must be Management
or Data
.resources.type
** - This field is required. resources.type
can only use the Equals
operator, and the value can be one of the following:AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
You can have only one resources.type
field per selector. To log data events on more than one resource type, add another selector.
resources.ARN
** - You can use any operator with resources.ARN
, but if you use Equals
or NotEquals
, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type. For example, if resources.type equals AWS::S3::Object
, the ARN must be in one of the following formats. To log all data events for all objects in a specific S3 bucket, use the StartsWith
operator, and include only the bucket ARN as the matching value. The trailing slash is intentional; do not exclude it. Replace the text between less than and greater than symbols (<>) with resource-specific information.arn:<partition>:s3:::<bucket_name>/
arn:<partition>:s3:::<bucket_name>/<object_path>/
When resources.type
equals AWS::S3::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in one of the following formats. To log events on all objects in an S3 access point, we recommend that you use only the access point ARN, don’t include the object path, and use the StartsWith
or NotStartsWith
operators.
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>/object/<object_path>
When resources.type equals AWS::Lambda::Function
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:lambda:<region>:<account_ID>:function:<function_name>
When resources.type equals AWS::DynamoDB::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>
When resources.type
equals AWS::S3Outposts::Object
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-outposts:<region>:<account_ID>:<object_path>
When resources.type
equals AWS::ManagedBlockchain::Node
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:managedblockchain:<region>:<account_ID>:nodes/<node_ID>
When resources.type
equals AWS::S3ObjectLambda::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-object-lambda:<region>:<account_ID>:accesspoint/<access_point_name>
When resources.type
equals AWS::EC2::Snapshot
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:ec2:<region>::snapshot/<snapshot_ID>
When resources.type
equals AWS::DynamoDB::Stream
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>/stream/<date_time>
When resources.type
equals AWS::Glue::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:glue:<region>:<account_ID>:table/<database_name>/<table_name>
Equals (list) --
An operator that includes events that match the exact value of the event record field specified as the value of Field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.
StartsWith (list) --
An operator that includes events that match the first few characters of the event record field specified as the value of Field
.
EndsWith (list) --
An operator that includes events that match the last few characters of the event record field specified as the value of Field
.
NotEquals (list) --
An operator that excludes events that match the exact value of the event record field specified as the value of Field
.
NotStartsWith (list) --
An operator that excludes events that match the first few characters of the event record field specified as the value of Field
.
NotEndsWith (list) --
An operator that excludes events that match the last few characters of the event record field specified as the value of Field
.
MultiRegionEnabled (boolean) --
This field is being deprecated. Indicates whether the event data store includes events from all regions, or only from the region in which it was created.
OrganizationEnabled (boolean) --
This field is being deprecated. Indicates that an event data store is collecting logged events for an organization.
RetentionPeriod (integer) --
This field is being deprecated. The retention period, in days.
CreatedTimestamp (datetime) --
This field is being deprecated. The timestamp of the event data store's creation.
UpdatedTimestamp (datetime) --
This field is being deprecated. The timestamp showing when an event data store was updated, if applicable. UpdatedTimestamp
is always either the same or newer than the time shown in CreatedTimestamp
.
NextToken (string) --
A token you can use to get the next page of results.
Exceptions
CloudTrail.Client.exceptions.InvalidMaxResultsException
CloudTrail.Client.exceptions.InvalidNextTokenException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
list_import_failures
(**kwargs)¶Returns a list of failures for the specified import.
See also: AWS API Documentation
Request Syntax
response = client.list_import_failures(
ImportId='string',
MaxResults=123,
NextToken='string'
)
[REQUIRED]
The ID of the import.
dict
Response Syntax
{
'Failures': [
{
'Location': 'string',
'Status': 'FAILED'|'RETRY'|'SUCCEEDED',
'ErrorType': 'string',
'ErrorMessage': 'string',
'LastUpdatedTime': datetime(2015, 1, 1)
},
],
'NextToken': 'string'
}
Response Structure
(dict) --
Failures (list) --
Contains information about the import failures.
(dict) --
Provides information about an import failure.
Location (string) --
The location of the failure in the S3 bucket.
Status (string) --
The status of the import.
ErrorType (string) --
The type of import error.
ErrorMessage (string) --
Provides the reason the import failed.
LastUpdatedTime (datetime) --
When the import was last updated.
NextToken (string) --
A token you can use to get the next page of results.
Exceptions
CloudTrail.Client.exceptions.InvalidNextTokenException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
list_imports
(**kwargs)¶Returns information on all imports, or a select set of imports by ImportStatus
or Destination
.
See also: AWS API Documentation
Request Syntax
response = client.list_imports(
MaxResults=123,
Destination='string',
ImportStatus='INITIALIZING'|'IN_PROGRESS'|'FAILED'|'STOPPED'|'COMPLETED',
NextToken='string'
)
dict
Response Syntax
{
'Imports': [
{
'ImportId': 'string',
'ImportStatus': 'INITIALIZING'|'IN_PROGRESS'|'FAILED'|'STOPPED'|'COMPLETED',
'Destinations': [
'string',
],
'CreatedTimestamp': datetime(2015, 1, 1),
'UpdatedTimestamp': datetime(2015, 1, 1)
},
],
'NextToken': 'string'
}
Response Structure
(dict) --
Imports (list) --
The list of returned imports.
(dict) --
Contains information about an import that was returned by a lookup request.
ImportId (string) --
The ID of the import.
ImportStatus (string) --
The status of the import.
Destinations (list) --
The ARN of the destination event data store.
CreatedTimestamp (datetime) --
The timestamp of the import's creation.
UpdatedTimestamp (datetime) --
The timestamp of the import's last update.
NextToken (string) --
A token you can use to get the next page of import results.
Exceptions
CloudTrail.Client.exceptions.EventDataStoreARNInvalidException
CloudTrail.Client.exceptions.InvalidNextTokenException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
list_public_keys
(**kwargs)¶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.
Note
CloudTrail uses different private and public key pairs per region. Each digest file is signed with a private key unique to its region. When you validate a digest file from a specific region, you must look in the same region for its corresponding public key.
See also: AWS API Documentation
Request Syntax
response = client.list_public_keys(
StartTime=datetime(2015, 1, 1),
EndTime=datetime(2015, 1, 1),
NextToken='string'
)
dict
Response Syntax
{
'PublicKeyList': [
{
'Value': b'bytes',
'ValidityStartTime': datetime(2015, 1, 1),
'ValidityEndTime': datetime(2015, 1, 1),
'Fingerprint': 'string'
},
],
'NextToken': 'string'
}
Response Structure
(dict) --
Returns the objects or data listed below if successful. Otherwise, returns an error.
PublicKeyList (list) --
Contains an array of PublicKey objects.
Note
The returned public keys may have validity time ranges that overlap.
(dict) --
Contains information about a returned public key.
Value (bytes) --
The DER encoded public key value in PKCS#1 format.
ValidityStartTime (datetime) --
The starting time of validity of the public key.
ValidityEndTime (datetime) --
The ending time of validity of the public key.
Fingerprint (string) --
The fingerprint of the public key.
NextToken (string) --
Reserved for future use.
Exceptions
CloudTrail.Client.exceptions.InvalidTimeRangeException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.InvalidTokenException
list_queries
(**kwargs)¶Returns a list of queries and query statuses for the past seven days. You must specify an ARN value for EventDataStore
. Optionally, to shorten the list of results, you can specify a time range, formatted as timestamps, by adding StartTime
and EndTime
parameters, and a QueryStatus
value. Valid values for QueryStatus
include QUEUED
, RUNNING
, FINISHED
, FAILED
, TIMED_OUT
, or CANCELLED
.
See also: AWS API Documentation
Request Syntax
response = client.list_queries(
EventDataStore='string',
NextToken='string',
MaxResults=123,
StartTime=datetime(2015, 1, 1),
EndTime=datetime(2015, 1, 1),
QueryStatus='QUEUED'|'RUNNING'|'FINISHED'|'FAILED'|'CANCELLED'|'TIMED_OUT'
)
[REQUIRED]
The ARN (or the ID suffix of the ARN) of an event data store on which queries were run.
EndTime
to bound a ListQueries
request, and limit its results to only those queries run within a specified time period.StartTime
to bound a ListQueries
request, and limit its results to only those queries run within a specified time period.QueryStatus
include QUEUED
, RUNNING
, FINISHED
, FAILED
, TIMED_OUT
, or CANCELLED
.dict
Response Syntax
{
'Queries': [
{
'QueryId': 'string',
'QueryStatus': 'QUEUED'|'RUNNING'|'FINISHED'|'FAILED'|'CANCELLED'|'TIMED_OUT',
'CreationTime': datetime(2015, 1, 1)
},
],
'NextToken': 'string'
}
Response Structure
(dict) --
Queries (list) --
Lists matching query results, and shows query ID, status, and creation time of each query.
(dict) --
A SQL string of criteria about events that you want to collect in an event data store.
QueryId (string) --
The ID of a query.
QueryStatus (string) --
The status of the query. This can be QUEUED
, RUNNING
, FINISHED
, FAILED
, TIMED_OUT
, or CANCELLED
.
CreationTime (datetime) --
The creation time of a query.
NextToken (string) --
A token you can use to get the next page of results.
Exceptions
CloudTrail.Client.exceptions.EventDataStoreARNInvalidException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.InactiveEventDataStoreException
CloudTrail.Client.exceptions.InvalidDateRangeException
CloudTrail.Client.exceptions.InvalidMaxResultsException
CloudTrail.Client.exceptions.InvalidNextTokenException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.InvalidQueryStatusException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
Lists the tags for the trail or event data store in the current region.
See also: AWS API Documentation
Request Syntax
response = client.list_tags(
ResourceIdList=[
'string',
],
NextToken='string'
)
[REQUIRED]
Specifies a list of trail and event data store ARNs whose tags will be listed. The list has a limit of 20 ARNs.
dict
Response Syntax
{
'ResourceTagList': [
{
'ResourceId': 'string',
'TagsList': [
{
'Key': 'string',
'Value': 'string'
},
]
},
],
'NextToken': 'string'
}
Response Structure
(dict) --
Returns the objects or data listed below if successful. Otherwise, returns an error.
ResourceTagList (list) --
A list of resource tags.
(dict) --
A resource tag.
ResourceId (string) --
Specifies the ARN of the resource.
TagsList (list) --
A list of tags.
(dict) --
A custom key-value pair associated with a resource such as a CloudTrail trail.
Key (string) --
The key in a key-value pair. The key must be must be no longer than 128 Unicode characters. The key must be unique for the resource to which it applies.
Value (string) --
The value in a key-value pair of a tag. The value must be no longer than 256 Unicode characters.
NextToken (string) --
Reserved for future use.
Exceptions
CloudTrail.Client.exceptions.ResourceNotFoundException
CloudTrail.Client.exceptions.CloudTrailARNInvalidException
CloudTrail.Client.exceptions.ResourceTypeNotSupportedException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.InactiveEventDataStoreException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.InvalidTokenException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
list_trails
(**kwargs)¶Lists trails that are in the current account.
See also: AWS API Documentation
Request Syntax
response = client.list_trails(
NextToken='string'
)
{
'Trails': [
{
'TrailARN': 'string',
'Name': 'string',
'HomeRegion': 'string'
},
],
'NextToken': 'string'
}
Response Structure
Returns the name, ARN, and home region of trails in the current account.
Information about a CloudTrail trail, including the trail's name, home region, and Amazon Resource Name (ARN).
The ARN of a trail.
The name of a trail.
The Amazon Web Services Region in which a trail was created.
The token to use to get the next page of results after a previous API call. If the token does not appear, there are no more results to return. The token must be passed in with the same parameters as the previous 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.
Exceptions
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
lookup_events
(**kwargs)¶Looks up management events or CloudTrail Insights events that are captured by CloudTrail. You can look up events that occurred in a region within the last 90 days. Lookup supports the following attributes for management events:
Lookup supports the following attributes for Insights events:
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.
Warning
The rate of lookup requests is limited to two per second, per account, per region. If this limit is exceeded, a throttling error occurs.
See also: AWS API Documentation
Request Syntax
response = client.lookup_events(
LookupAttributes=[
{
'AttributeKey': 'EventId'|'EventName'|'ReadOnly'|'Username'|'ResourceType'|'ResourceName'|'EventSource'|'AccessKeyId',
'AttributeValue': 'string'
},
],
StartTime=datetime(2015, 1, 1),
EndTime=datetime(2015, 1, 1),
EventCategory='insight',
MaxResults=123,
NextToken='string'
)
Contains a list of lookup attributes. Currently the list can contain only one item.
Specifies an attribute and value that filter the events returned.
Specifies an attribute on which to filter the events returned.
Specifies a value for the specified AttributeKey.
insight
as the value of EventCategory
, no Insights events are returned.dict
Response Syntax
{
'Events': [
{
'EventId': 'string',
'EventName': 'string',
'ReadOnly': 'string',
'AccessKeyId': 'string',
'EventTime': datetime(2015, 1, 1),
'EventSource': 'string',
'Username': 'string',
'Resources': [
{
'ResourceType': 'string',
'ResourceName': 'string'
},
],
'CloudTrailEvent': 'string'
},
],
'NextToken': 'string'
}
Response Structure
(dict) --
Contains a response to a LookupEvents action.
Events (list) --
A list of events returned based on the lookup attributes specified and the CloudTrail event. The events list is sorted by time. The most recent event is listed first.
(dict) --
Contains information about an event that was returned by a lookup request. The result includes a representation of a CloudTrail event.
EventId (string) --
The CloudTrail ID of the event returned.
EventName (string) --
The name of the event returned.
ReadOnly (string) --
Information about whether the event is a write event or a read event.
AccessKeyId (string) --
The Amazon Web Services access key ID that was used to sign the request. If the request was made with temporary security credentials, this is the access key ID of the temporary credentials.
EventTime (datetime) --
The date and time of the event returned.
EventSource (string) --
The Amazon Web Services service to which the request was made.
Username (string) --
A user name or role name of the requester that called the API in the event returned.
Resources (list) --
A list of resources referenced by the event returned.
(dict) --
Specifies the type and name of a resource referenced by an event.
ResourceType (string) --
The type of a resource referenced by the event returned. When the resource type cannot be determined, null is returned. Some examples of resource types are: Instance for EC2, Trail for CloudTrail, DBInstance for Amazon RDS, and AccessKey for IAM. To learn more about how to look up and filter events by the resource types supported for a service, see Filtering CloudTrail Events .
ResourceName (string) --
The name of the resource referenced by the event returned. These are user-created names whose values will depend on the environment. For example, the resource name might be "auto-scaling-test-group" for an Auto Scaling Group or "i-1234567" for an EC2 Instance.
CloudTrailEvent (string) --
A JSON string that contains a representation of the event returned.
NextToken (string) --
The token to use to get the next page of results after a previous API call. If the token does not appear, there are no more results to return. The token must be passed in with the same parameters as the previous 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.
Exceptions
CloudTrail.Client.exceptions.InvalidLookupAttributesException
CloudTrail.Client.exceptions.InvalidTimeRangeException
CloudTrail.Client.exceptions.InvalidMaxResultsException
CloudTrail.Client.exceptions.InvalidNextTokenException
CloudTrail.Client.exceptions.InvalidEventCategoryException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
put_event_selectors
(**kwargs)¶Configures an event selector or advanced event selectors for your trail. Use event selectors or advanced event selectors to specify management and data event settings for your trail. By default, trails created without specific event selectors are 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 or advanced 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
GetConsoleOutput
and RunInstances
API operations occur in your account.RunInstances
is a write-only event and it matches your event selector. The trail logs the event.GetConsoleOutput
is a read-only event that 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
exception is thrown.
You can configure up to five event selectors for each trail. For more information, see Logging management events for trails , Logging data events for trails , and Quotas in CloudTrail in the CloudTrail User Guide .
You can add advanced event selectors, and conditions for your advanced event selectors, up to a maximum of 500 values for all conditions and selectors on a trail. You can use either AdvancedEventSelectors
or EventSelectors
, but not both. If you apply AdvancedEventSelectors
to a trail, any existing EventSelectors
are overwritten. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
See also: AWS API Documentation
Request Syntax
response = client.put_event_selectors(
TrailName='string',
EventSelectors=[
{
'ReadWriteType': 'ReadOnly'|'WriteOnly'|'All',
'IncludeManagementEvents': True|False,
'DataResources': [
{
'Type': 'string',
'Values': [
'string',
]
},
],
'ExcludeManagementEventSources': [
'string',
]
},
],
AdvancedEventSelectors=[
{
'Name': 'string',
'FieldSelectors': [
{
'Field': 'string',
'Equals': [
'string',
],
'StartsWith': [
'string',
],
'EndsWith': [
'string',
],
'NotEquals': [
'string',
],
'NotStartsWith': [
'string',
],
'NotEndsWith': [
'string',
]
},
]
},
]
)
[REQUIRED]
Specifies the name of the trail or trail ARN. If you specify a trail name, the string must meet the following requirements:
my-_namespace
and my--namespace
are not valid.If you specify a trail ARN, it must be in the following format.
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
Specifies the settings for your event selectors. You can configure up to five event selectors for a trail. You can use either EventSelectors
or AdvancedEventSelectors
in a PutEventSelectors
request, but not both. If you apply EventSelectors
to a trail, any existing AdvancedEventSelectors
are overwritten.
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 selector for 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.
You can configure up to five event selectors for a trail.
You cannot apply both event selectors and advanced event selectors to a trail.
Specify if you want your trail to log read-only events, write-only events, or all. For example, the EC2 GetConsoleOutput
is a read-only API operation and RunInstances
is a write-only API operation.
By default, the value is All
.
Specify if you want your event selector to include management events for your trail.
For more information, see Management Events in the CloudTrail User Guide .
By default, the value is true
.
The first copy of management events is free. You are charged for additional copies of management events that you are logging on any subsequent trail in the same region. For more information about CloudTrail pricing, see CloudTrail Pricing .
CloudTrail supports data event logging for Amazon S3 objects, Lambda functions, and Amazon DynamoDB tables with basic event selectors. You can specify up to 250 resources for an individual event selector, but the total number of data resources cannot exceed 250 across all event selectors in a trail. This limit does not apply if you configure resource logging for all data events.
For more information, see Data Events and Limits in CloudTrail in the CloudTrail User Guide .
The Amazon S3 buckets, Lambda functions, or Amazon DynamoDB tables that you specify in your event selectors for your trail to log data events. Data events provide information about the resource operations performed on or within a resource itself. These are also known as data plane operations. You can specify up to 250 data resources for a trail.
Note
The total number of allowed data resources is 250. This number can be distributed between 1 and 5 event selectors, but the total cannot exceed 250 across all selectors.
If you are using advanced event selectors, the maximum total number of values for all conditions, across all advanced event selectors for the trail, is 500.
The following example demonstrates how logging works when you configure logging of all data events for an S3 bucket named bucket-1
. In this example, the CloudTrail user specified an empty prefix, and the option to log both Read
and Write
data events.
bucket-1
.PutObject
API operation is an Amazon S3 object-level API. It is recorded as a data event in CloudTrail. Because the CloudTrail user specified an S3 bucket with an empty prefix, events that occur on any object in that bucket are logged. The trail processes and logs the event.arn:aws:s3:::bucket-2
.PutObject
API operation occurred for an object in an S3 bucket that the CloudTrail user didn't specify for the trail. The trail doesn’t log the event.The following example demonstrates how logging works when you configure logging of Lambda data events for a Lambda function named MyLambdaFunction , but not for all Lambda functions.
Invoke
API operation on MyLambdaFunction is an Lambda API. It is recorded as a data event in CloudTrail. Because the CloudTrail user specified logging data events for MyLambdaFunction , any invocations of that function are logged. The trail processes and logs the event.Invoke
API operation on MyOtherLambdaFunction is an Lambda API. Because the CloudTrail user did not specify logging data events for all Lambda functions, the Invoke
operation for MyOtherLambdaFunction does not match the function specified for the trail. The trail doesn’t log the event.The resource type in which you want to log data events. You can specify the following basic event selector resource types:
AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
The following resource types are also available through advanced event selectors. Basic event selector resource types are valid in advanced event selectors, but advanced event selector resource types are not valid in basic event selectors. For more information, see AdvancedFieldSelector$Field .
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
An array of Amazon Resource Name (ARN) strings or partial ARN strings for the specified objects.
arn:aws:s3
.Note
This also enables logging of data event activity performed by any user or role in your Amazon Web Services account, even if that activity is performed on a bucket that belongs to another Amazon Web Services account.
arn:aws:s3:::bucket-1/
. The trail logs data events for all objects in this S3 bucket.arn:aws:s3:::bucket-1/example-images
. The trail logs data events for objects in this S3 bucket that match the prefix.arn:aws:lambda
.Note
This also enables logging of Invoke
activity performed by any user or role in your Amazon Web Services account, even if that activity is performed on a function that belongs to another Amazon Web Services account.
Note
Lambda function ARNs are exact. For example, if you specify a function ARN arn:aws:lambda:us-west-2:111111111111:function:helloworld , data events will only be logged for arn:aws:lambda:us-west-2:111111111111:function:helloworld . They will not be logged for arn:aws:lambda:us-west-2:111111111111:function:helloworld2 .
arn:aws:dynamodb
.An optional list of service event sources from which you do not want management events to be logged on your trail. In this release, the list can be empty (disables the filter), or it can filter out Key Management Service or Amazon RDS Data API events by containing kms.amazonaws.com
or rdsdata.amazonaws.com
. By default, ExcludeManagementEventSources
is empty, and KMS and Amazon RDS Data API events are logged to your trail. You can exclude management event sources only in regions that support the event source.
Specifies the settings for advanced event selectors. You can add advanced event selectors, and conditions for your advanced event selectors, up to a maximum of 500 values for all conditions and selectors on a trail. You can use either AdvancedEventSelectors
or EventSelectors
, but not both. If you apply AdvancedEventSelectors
to a trail, any existing EventSelectors
are overwritten. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
Advanced event selectors let you create fine-grained selectors for the following CloudTrail event record fields. They help you control costs by logging only those events that are important to you. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
readOnly
eventSource
eventName
eventCategory
resources.type
resources.ARN
You cannot apply both event selectors and advanced event selectors to a trail.
An optional, descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets".
Contains all selector statements in an advanced event selector.
A single selector statement in an advanced event selector.
A field in an event record on which to filter events to be logged. Supported fields include readOnly
, eventCategory
, eventSource
(for management events), eventName
, resources.type
, and resources.ARN
.
readOnly
** - Optional. Can be set to Equals
a value of true
or false
. If you do not add this field, CloudTrail logs both read
and write
events. A value of true
logs only read
events. A value of false
logs only write
events.eventSource
** - For filtering management events only. This can be set only to NotEquals
kms.amazonaws.com
.eventName
** - Can use any operator. You can use it to filter in or filter out any data event logged to CloudTrail, such as PutBucket
or GetSnapshotBlock
. You can have multiple values for this field, separated by commas.eventCategory
** - This is required. It must be set to Equals
, and the value must be Management
or Data
.resources.type
** - This field is required. resources.type
can only use the Equals
operator, and the value can be one of the following:AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
You can have only one resources.type
field per selector. To log data events on more than one resource type, add another selector.
resources.ARN
** - You can use any operator with resources.ARN
, but if you use Equals
or NotEquals
, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type. For example, if resources.type equals AWS::S3::Object
, the ARN must be in one of the following formats. To log all data events for all objects in a specific S3 bucket, use the StartsWith
operator, and include only the bucket ARN as the matching value. The trailing slash is intentional; do not exclude it. Replace the text between less than and greater than symbols (<>) with resource-specific information.arn:<partition>:s3:::<bucket_name>/
arn:<partition>:s3:::<bucket_name>/<object_path>/
When resources.type
equals AWS::S3::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in one of the following formats. To log events on all objects in an S3 access point, we recommend that you use only the access point ARN, don’t include the object path, and use the StartsWith
or NotStartsWith
operators.
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>/object/<object_path>
When resources.type equals AWS::Lambda::Function
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:lambda:<region>:<account_ID>:function:<function_name>
When resources.type equals AWS::DynamoDB::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>
When resources.type
equals AWS::S3Outposts::Object
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-outposts:<region>:<account_ID>:<object_path>
When resources.type
equals AWS::ManagedBlockchain::Node
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:managedblockchain:<region>:<account_ID>:nodes/<node_ID>
When resources.type
equals AWS::S3ObjectLambda::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-object-lambda:<region>:<account_ID>:accesspoint/<access_point_name>
When resources.type
equals AWS::EC2::Snapshot
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:ec2:<region>::snapshot/<snapshot_ID>
When resources.type
equals AWS::DynamoDB::Stream
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>/stream/<date_time>
When resources.type
equals AWS::Glue::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:glue:<region>:<account_ID>:table/<database_name>/<table_name>
An operator that includes events that match the exact value of the event record field specified as the value of Field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.
An operator that includes events that match the first few characters of the event record field specified as the value of Field
.
An operator that includes events that match the last few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the exact value of the event record field specified as the value of Field
.
An operator that excludes events that match the first few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the last few characters of the event record field specified as the value of Field
.
dict
Response Syntax
{
'TrailARN': 'string',
'EventSelectors': [
{
'ReadWriteType': 'ReadOnly'|'WriteOnly'|'All',
'IncludeManagementEvents': True|False,
'DataResources': [
{
'Type': 'string',
'Values': [
'string',
]
},
],
'ExcludeManagementEventSources': [
'string',
]
},
],
'AdvancedEventSelectors': [
{
'Name': 'string',
'FieldSelectors': [
{
'Field': 'string',
'Equals': [
'string',
],
'StartsWith': [
'string',
],
'EndsWith': [
'string',
],
'NotEquals': [
'string',
],
'NotStartsWith': [
'string',
],
'NotEndsWith': [
'string',
]
},
]
},
]
}
Response Structure
(dict) --
TrailARN (string) --
Specifies the ARN of the trail that was updated with event selectors. The following is the format of a trail ARN.
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
EventSelectors (list) --
Specifies the event selectors configured for your trail.
(dict) --
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 selector for 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.
You can configure up to five event selectors for a trail.
You cannot apply both event selectors and advanced event selectors to a trail.
ReadWriteType (string) --
Specify if you want your trail to log read-only events, write-only events, or all. For example, the EC2 GetConsoleOutput
is a read-only API operation and RunInstances
is a write-only API operation.
By default, the value is All
.
IncludeManagementEvents (boolean) --
Specify if you want your event selector to include management events for your trail.
For more information, see Management Events in the CloudTrail User Guide .
By default, the value is true
.
The first copy of management events is free. You are charged for additional copies of management events that you are logging on any subsequent trail in the same region. For more information about CloudTrail pricing, see CloudTrail Pricing .
DataResources (list) --
CloudTrail supports data event logging for Amazon S3 objects, Lambda functions, and Amazon DynamoDB tables with basic event selectors. You can specify up to 250 resources for an individual event selector, but the total number of data resources cannot exceed 250 across all event selectors in a trail. This limit does not apply if you configure resource logging for all data events.
For more information, see Data Events and Limits in CloudTrail in the CloudTrail User Guide .
(dict) --
The Amazon S3 buckets, Lambda functions, or Amazon DynamoDB tables that you specify in your event selectors for your trail to log data events. Data events provide information about the resource operations performed on or within a resource itself. These are also known as data plane operations. You can specify up to 250 data resources for a trail.
Note
The total number of allowed data resources is 250. This number can be distributed between 1 and 5 event selectors, but the total cannot exceed 250 across all selectors.
If you are using advanced event selectors, the maximum total number of values for all conditions, across all advanced event selectors for the trail, is 500.
The following example demonstrates how logging works when you configure logging of all data events for an S3 bucket named bucket-1
. In this example, the CloudTrail user specified an empty prefix, and the option to log both Read
and Write
data events.
bucket-1
.PutObject
API operation is an Amazon S3 object-level API. It is recorded as a data event in CloudTrail. Because the CloudTrail user specified an S3 bucket with an empty prefix, events that occur on any object in that bucket are logged. The trail processes and logs the event.arn:aws:s3:::bucket-2
.PutObject
API operation occurred for an object in an S3 bucket that the CloudTrail user didn't specify for the trail. The trail doesn’t log the event.The following example demonstrates how logging works when you configure logging of Lambda data events for a Lambda function named MyLambdaFunction , but not for all Lambda functions.
Invoke
API operation on MyLambdaFunction is an Lambda API. It is recorded as a data event in CloudTrail. Because the CloudTrail user specified logging data events for MyLambdaFunction , any invocations of that function are logged. The trail processes and logs the event.Invoke
API operation on MyOtherLambdaFunction is an Lambda API. Because the CloudTrail user did not specify logging data events for all Lambda functions, the Invoke
operation for MyOtherLambdaFunction does not match the function specified for the trail. The trail doesn’t log the event.Type (string) --
The resource type in which you want to log data events. You can specify the following basic event selector resource types:
AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
The following resource types are also available through advanced event selectors. Basic event selector resource types are valid in advanced event selectors, but advanced event selector resource types are not valid in basic event selectors. For more information, see AdvancedFieldSelector$Field .
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
Values (list) --
An array of Amazon Resource Name (ARN) strings or partial ARN strings for the specified objects.
arn:aws:s3
.Note
This also enables logging of data event activity performed by any user or role in your Amazon Web Services account, even if that activity is performed on a bucket that belongs to another Amazon Web Services account.
arn:aws:s3:::bucket-1/
. The trail logs data events for all objects in this S3 bucket.arn:aws:s3:::bucket-1/example-images
. The trail logs data events for objects in this S3 bucket that match the prefix.arn:aws:lambda
.Note
This also enables logging of Invoke
activity performed by any user or role in your Amazon Web Services account, even if that activity is performed on a function that belongs to another Amazon Web Services account.
Note
Lambda function ARNs are exact. For example, if you specify a function ARN arn:aws:lambda:us-west-2:111111111111:function:helloworld , data events will only be logged for arn:aws:lambda:us-west-2:111111111111:function:helloworld . They will not be logged for arn:aws:lambda:us-west-2:111111111111:function:helloworld2 .
arn:aws:dynamodb
.ExcludeManagementEventSources (list) --
An optional list of service event sources from which you do not want management events to be logged on your trail. In this release, the list can be empty (disables the filter), or it can filter out Key Management Service or Amazon RDS Data API events by containing kms.amazonaws.com
or rdsdata.amazonaws.com
. By default, ExcludeManagementEventSources
is empty, and KMS and Amazon RDS Data API events are logged to your trail. You can exclude management event sources only in regions that support the event source.
AdvancedEventSelectors (list) --
Specifies the advanced event selectors configured for your trail.
(dict) --
Advanced event selectors let you create fine-grained selectors for the following CloudTrail event record fields. They help you control costs by logging only those events that are important to you. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
readOnly
eventSource
eventName
eventCategory
resources.type
resources.ARN
You cannot apply both event selectors and advanced event selectors to a trail.
Name (string) --
An optional, descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets".
FieldSelectors (list) --
Contains all selector statements in an advanced event selector.
(dict) --
A single selector statement in an advanced event selector.
Field (string) --
A field in an event record on which to filter events to be logged. Supported fields include readOnly
, eventCategory
, eventSource
(for management events), eventName
, resources.type
, and resources.ARN
.
readOnly
** - Optional. Can be set to Equals
a value of true
or false
. If you do not add this field, CloudTrail logs both read
and write
events. A value of true
logs only read
events. A value of false
logs only write
events.eventSource
** - For filtering management events only. This can be set only to NotEquals
kms.amazonaws.com
.eventName
** - Can use any operator. You can use it to filter in or filter out any data event logged to CloudTrail, such as PutBucket
or GetSnapshotBlock
. You can have multiple values for this field, separated by commas.eventCategory
** - This is required. It must be set to Equals
, and the value must be Management
or Data
.resources.type
** - This field is required. resources.type
can only use the Equals
operator, and the value can be one of the following:AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
You can have only one resources.type
field per selector. To log data events on more than one resource type, add another selector.
resources.ARN
** - You can use any operator with resources.ARN
, but if you use Equals
or NotEquals
, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type. For example, if resources.type equals AWS::S3::Object
, the ARN must be in one of the following formats. To log all data events for all objects in a specific S3 bucket, use the StartsWith
operator, and include only the bucket ARN as the matching value. The trailing slash is intentional; do not exclude it. Replace the text between less than and greater than symbols (<>) with resource-specific information.arn:<partition>:s3:::<bucket_name>/
arn:<partition>:s3:::<bucket_name>/<object_path>/
When resources.type
equals AWS::S3::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in one of the following formats. To log events on all objects in an S3 access point, we recommend that you use only the access point ARN, don’t include the object path, and use the StartsWith
or NotStartsWith
operators.
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>/object/<object_path>
When resources.type equals AWS::Lambda::Function
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:lambda:<region>:<account_ID>:function:<function_name>
When resources.type equals AWS::DynamoDB::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>
When resources.type
equals AWS::S3Outposts::Object
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-outposts:<region>:<account_ID>:<object_path>
When resources.type
equals AWS::ManagedBlockchain::Node
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:managedblockchain:<region>:<account_ID>:nodes/<node_ID>
When resources.type
equals AWS::S3ObjectLambda::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-object-lambda:<region>:<account_ID>:accesspoint/<access_point_name>
When resources.type
equals AWS::EC2::Snapshot
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:ec2:<region>::snapshot/<snapshot_ID>
When resources.type
equals AWS::DynamoDB::Stream
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>/stream/<date_time>
When resources.type
equals AWS::Glue::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:glue:<region>:<account_ID>:table/<database_name>/<table_name>
Equals (list) --
An operator that includes events that match the exact value of the event record field specified as the value of Field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.
StartsWith (list) --
An operator that includes events that match the first few characters of the event record field specified as the value of Field
.
EndsWith (list) --
An operator that includes events that match the last few characters of the event record field specified as the value of Field
.
NotEquals (list) --
An operator that excludes events that match the exact value of the event record field specified as the value of Field
.
NotStartsWith (list) --
An operator that excludes events that match the first few characters of the event record field specified as the value of Field
.
NotEndsWith (list) --
An operator that excludes events that match the last few characters of the event record field specified as the value of Field
.
Exceptions
CloudTrail.Client.exceptions.TrailNotFoundException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.InvalidHomeRegionException
CloudTrail.Client.exceptions.InvalidEventSelectorsException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
put_insight_selectors
(**kwargs)¶Lets you enable Insights event logging by specifying the Insights selectors that you want to enable on an existing trail. You also use PutInsightSelectors
to turn off Insights event logging, by passing an empty list of insight types. The valid Insights event types in this release are ApiErrorRateInsight
and ApiCallRateInsight
.
See also: AWS API Documentation
Request Syntax
response = client.put_insight_selectors(
TrailName='string',
InsightSelectors=[
{
'InsightType': 'ApiCallRateInsight'|'ApiErrorRateInsight'
},
]
)
[REQUIRED]
The name of the CloudTrail trail for which you want to change or add Insights selectors.
[REQUIRED]
A JSON string that contains the insight types you want to log on a trail. ApiCallRateInsight
and ApiErrorRateInsight
are valid insight types.
A JSON string that contains a list of insight types that are logged on a trail.
The type of insights to log on a trail. ApiCallRateInsight
and ApiErrorRateInsight
are valid insight types.
dict
Response Syntax
{
'TrailARN': 'string',
'InsightSelectors': [
{
'InsightType': 'ApiCallRateInsight'|'ApiErrorRateInsight'
},
]
}
Response Structure
(dict) --
TrailARN (string) --
The Amazon Resource Name (ARN) of a trail for which you want to change or add Insights selectors.
InsightSelectors (list) --
A JSON string that contains the Insights event types that you want to log on a trail. The valid Insights types in this release are ApiErrorRateInsight
and ApiCallRateInsight
.
(dict) --
A JSON string that contains a list of insight types that are logged on a trail.
InsightType (string) --
The type of insights to log on a trail. ApiCallRateInsight
and ApiErrorRateInsight
are valid insight types.
Exceptions
CloudTrail.Client.exceptions.TrailNotFoundException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.InvalidHomeRegionException
CloudTrail.Client.exceptions.InvalidInsightSelectorsException
CloudTrail.Client.exceptions.InsufficientS3BucketPolicyException
CloudTrail.Client.exceptions.InsufficientEncryptionPolicyException
CloudTrail.Client.exceptions.S3BucketDoesNotExistException
CloudTrail.Client.exceptions.KmsException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
register_organization_delegated_admin
(**kwargs)¶Registers an organization’s member account as the CloudTrail delegated administrator.
See also: AWS API Documentation
Request Syntax
response = client.register_organization_delegated_admin(
MemberAccountId='string'
)
[REQUIRED]
An organization member account ID that you want to designate as a delegated administrator.
{}
Response Structure
Returns the following response if successful. Otherwise, returns an error.
Exceptions
CloudTrail.Client.exceptions.AccountRegisteredException
CloudTrail.Client.exceptions.AccountNotFoundException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.CannotDelegateManagementAccountException
CloudTrail.Client.exceptions.CloudTrailAccessNotEnabledException
CloudTrail.Client.exceptions.DelegatedAdminAccountLimitExceededException
CloudTrail.Client.exceptions.NotOrganizationManagementAccountException
CloudTrail.Client.exceptions.OrganizationNotInAllFeaturesModeException
CloudTrail.Client.exceptions.OrganizationsNotInUseException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
Removes the specified tags from a trail or event data store.
See also: AWS API Documentation
Request Syntax
response = client.remove_tags(
ResourceId='string',
TagsList=[
{
'Key': 'string',
'Value': 'string'
},
]
)
[REQUIRED]
Specifies the ARN of the trail or event data store from which tags should be removed.
Example trail ARN format: arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
Example event data store ARN format: arn:aws:cloudtrail:us-east-2:12345678910:eventdatastore/EXAMPLE-f852-4e8f-8bd1-bcf6cEXAMPLE
[REQUIRED]
Specifies a list of tags to be removed.
A custom key-value pair associated with a resource such as a CloudTrail trail.
The key in a key-value pair. The key must be must be no longer than 128 Unicode characters. The key must be unique for the resource to which it applies.
The value in a key-value pair of a tag. The value must be no longer than 256 Unicode characters.
dict
Response Syntax
{}
Response Structure
(dict) --
Returns the objects or data listed below if successful. Otherwise, returns an error.
Exceptions
CloudTrail.Client.exceptions.ResourceNotFoundException
CloudTrail.Client.exceptions.CloudTrailARNInvalidException
CloudTrail.Client.exceptions.ResourceTypeNotSupportedException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.InvalidTagParameterException
CloudTrail.Client.exceptions.InactiveEventDataStoreException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
restore_event_data_store
(**kwargs)¶Restores a deleted event data store specified by EventDataStore
, which accepts an event data store ARN. You can only restore a deleted event data store within the seven-day wait period after deletion. Restoring an event data store can take several minutes, depending on the size of the event data store.
See also: AWS API Documentation
Request Syntax
response = client.restore_event_data_store(
EventDataStore='string'
)
[REQUIRED]
The ARN (or the ID suffix of the ARN) of the event data store that you want to restore.
{
'EventDataStoreArn': 'string',
'Name': 'string',
'Status': 'CREATED'|'ENABLED'|'PENDING_DELETION',
'AdvancedEventSelectors': [
{
'Name': 'string',
'FieldSelectors': [
{
'Field': 'string',
'Equals': [
'string',
],
'StartsWith': [
'string',
],
'EndsWith': [
'string',
],
'NotEquals': [
'string',
],
'NotStartsWith': [
'string',
],
'NotEndsWith': [
'string',
]
},
]
},
],
'MultiRegionEnabled': True|False,
'OrganizationEnabled': True|False,
'RetentionPeriod': 123,
'TerminationProtectionEnabled': True|False,
'CreatedTimestamp': datetime(2015, 1, 1),
'UpdatedTimestamp': datetime(2015, 1, 1),
'KmsKeyId': 'string'
}
Response Structure
The event data store ARN.
The name of the event data store.
The status of the event data store.
The advanced event selectors that were used to select events.
Advanced event selectors let you create fine-grained selectors for the following CloudTrail event record fields. They help you control costs by logging only those events that are important to you. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
readOnly
eventSource
eventName
eventCategory
resources.type
resources.ARN
You cannot apply both event selectors and advanced event selectors to a trail.
An optional, descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets".
Contains all selector statements in an advanced event selector.
A single selector statement in an advanced event selector.
A field in an event record on which to filter events to be logged. Supported fields include readOnly
, eventCategory
, eventSource
(for management events), eventName
, resources.type
, and resources.ARN
.
readOnly
** - Optional. Can be set to Equals
a value of true
or false
. If you do not add this field, CloudTrail logs both read
and write
events. A value of true
logs only read
events. A value of false
logs only write
events.eventSource
** - For filtering management events only. This can be set only to NotEquals
kms.amazonaws.com
.eventName
** - Can use any operator. You can use it to filter in or filter out any data event logged to CloudTrail, such as PutBucket
or GetSnapshotBlock
. You can have multiple values for this field, separated by commas.eventCategory
** - This is required. It must be set to Equals
, and the value must be Management
or Data
.resources.type
** - This field is required. resources.type
can only use the Equals
operator, and the value can be one of the following:AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
You can have only one resources.type
field per selector. To log data events on more than one resource type, add another selector.
resources.ARN
** - You can use any operator with resources.ARN
, but if you use Equals
or NotEquals
, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type. For example, if resources.type equals AWS::S3::Object
, the ARN must be in one of the following formats. To log all data events for all objects in a specific S3 bucket, use the StartsWith
operator, and include only the bucket ARN as the matching value. The trailing slash is intentional; do not exclude it. Replace the text between less than and greater than symbols (<>) with resource-specific information.arn:<partition>:s3:::<bucket_name>/
arn:<partition>:s3:::<bucket_name>/<object_path>/
When resources.type
equals AWS::S3::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in one of the following formats. To log events on all objects in an S3 access point, we recommend that you use only the access point ARN, don’t include the object path, and use the StartsWith
or NotStartsWith
operators.
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>/object/<object_path>
When resources.type equals AWS::Lambda::Function
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:lambda:<region>:<account_ID>:function:<function_name>
When resources.type equals AWS::DynamoDB::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>
When resources.type
equals AWS::S3Outposts::Object
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-outposts:<region>:<account_ID>:<object_path>
When resources.type
equals AWS::ManagedBlockchain::Node
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:managedblockchain:<region>:<account_ID>:nodes/<node_ID>
When resources.type
equals AWS::S3ObjectLambda::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-object-lambda:<region>:<account_ID>:accesspoint/<access_point_name>
When resources.type
equals AWS::EC2::Snapshot
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:ec2:<region>::snapshot/<snapshot_ID>
When resources.type
equals AWS::DynamoDB::Stream
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>/stream/<date_time>
When resources.type
equals AWS::Glue::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:glue:<region>:<account_ID>:table/<database_name>/<table_name>
An operator that includes events that match the exact value of the event record field specified as the value of Field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.
An operator that includes events that match the first few characters of the event record field specified as the value of Field
.
An operator that includes events that match the last few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the exact value of the event record field specified as the value of Field
.
An operator that excludes events that match the first few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the last few characters of the event record field specified as the value of Field
.
Indicates whether the event data store is collecting events from all regions, or only from the region in which the event data store was created.
Indicates whether an event data store is collecting logged events for an organization in Organizations.
The retention period, in days.
Indicates that termination protection is enabled and the event data store cannot be automatically deleted.
The timestamp of an event data store's creation.
The timestamp that shows when an event data store was updated, if applicable. UpdatedTimestamp
is always either the same or newer than the time shown in CreatedTimestamp
.
Specifies the KMS key ID that encrypts the events delivered by CloudTrail. The value is a fully specified ARN to a KMS key in the following format.
arn:aws:kms:us-east-2:123456789012:key/12345678-1234-1234-1234-123456789012
Exceptions
CloudTrail.Client.exceptions.EventDataStoreARNInvalidException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.EventDataStoreMaxLimitExceededException
CloudTrail.Client.exceptions.InvalidEventDataStoreStatusException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.CloudTrailAccessNotEnabledException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
CloudTrail.Client.exceptions.OrganizationsNotInUseException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
CloudTrail.Client.exceptions.OrganizationNotInAllFeaturesModeException
start_import
(**kwargs)¶Starts an import of logged trail events from a source S3 bucket to a destination event data store. By default, CloudTrail only imports events contained in the S3 bucket's CloudTrail
prefix and the prefixes inside the CloudTrail
prefix, and does not check prefixes for other Amazon Web Services services. If you want to import CloudTrail events contained in another prefix, you must include the prefix in the S3LocationUri
. For more considerations about importing trail events, see Considerations .
When you start a new import, the Destinations
and ImportSource
parameters are required. Before starting a new import, disable any access control lists (ACLs) attached to the source S3 bucket. For more information about disabling ACLs, see Controlling ownership of objects and disabling ACLs for your bucket .
When you retry an import, the ImportID
parameter is required.
See also: AWS API Documentation
Request Syntax
response = client.start_import(
Destinations=[
'string',
],
ImportSource={
'S3': {
'S3LocationUri': 'string',
'S3BucketRegion': 'string',
'S3BucketAccessRoleArn': 'string'
}
},
StartEventTime=datetime(2015, 1, 1),
EndEventTime=datetime(2015, 1, 1),
ImportId='string'
)
The ARN of the destination event data store. Use this parameter for a new import.
The source S3 bucket for the import. Use this parameter for a new import.
The source S3 bucket.
The URI for the source S3 bucket.
The region associated with the source S3 bucket.
The IAM ARN role used to access the source S3 bucket.
EndEventTime
to bound a StartImport
request, and limit imported trail events to only those events logged within a specified time period. When you specify a time range, CloudTrail checks the prefix and log file names to verify the names contain a date between the specified StartEventTime
and EndEventTime
before attempting to import events.StartEventTime
to bound a StartImport
request, and limit imported trail events to only those events logged within a specified time period. When you specify a time range, CloudTrail checks the prefix and log file names to verify the names contain a date between the specified StartEventTime
and EndEventTime
before attempting to import events.dict
Response Syntax
{
'ImportId': 'string',
'Destinations': [
'string',
],
'ImportSource': {
'S3': {
'S3LocationUri': 'string',
'S3BucketRegion': 'string',
'S3BucketAccessRoleArn': 'string'
}
},
'StartEventTime': datetime(2015, 1, 1),
'EndEventTime': datetime(2015, 1, 1),
'ImportStatus': 'INITIALIZING'|'IN_PROGRESS'|'FAILED'|'STOPPED'|'COMPLETED',
'CreatedTimestamp': datetime(2015, 1, 1),
'UpdatedTimestamp': datetime(2015, 1, 1)
}
Response Structure
(dict) --
ImportId (string) --
The ID of the import.
Destinations (list) --
The ARN of the destination event data store.
ImportSource (dict) --
The source S3 bucket for the import.
S3 (dict) --
The source S3 bucket.
S3LocationUri (string) --
The URI for the source S3 bucket.
S3BucketRegion (string) --
The region associated with the source S3 bucket.
S3BucketAccessRoleArn (string) --
The IAM ARN role used to access the source S3 bucket.
StartEventTime (datetime) --
Used with EndEventTime
to bound a StartImport
request, and limit imported trail events to only those events logged within a specified time period.
EndEventTime (datetime) --
Used with StartEventTime
to bound a StartImport
request, and limit imported trail events to only those events logged within a specified time period.
ImportStatus (string) --
Shows the status of the import after a StartImport
request. An import finishes with a status of COMPLETED
if there were no failures, or FAILED
if there were failures.
CreatedTimestamp (datetime) --
The timestamp for the import's creation.
UpdatedTimestamp (datetime) --
The timestamp of the import's last update, if applicable.
Exceptions
CloudTrail.Client.exceptions.AccountHasOngoingImportException
CloudTrail.Client.exceptions.EventDataStoreARNInvalidException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.InvalidEventDataStoreStatusException
CloudTrail.Client.exceptions.InvalidEventDataStoreCategoryException
CloudTrail.Client.exceptions.InactiveEventDataStoreException
CloudTrail.Client.exceptions.InvalidImportSourceException
CloudTrail.Client.exceptions.ImportNotFoundException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
start_logging
(**kwargs)¶Starts the recording of Amazon Web Services 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.
See also: AWS API Documentation
Request Syntax
response = client.start_logging(
Name='string'
)
[REQUIRED]
Specifies the name or the CloudTrail ARN of the trail for which CloudTrail logs Amazon Web Services API calls. The following is the format of a trail ARN.
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
{}
Response Structure
Returns the objects or data listed below if successful. Otherwise, returns an error.
Exceptions
CloudTrail.Client.exceptions.TrailNotFoundException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.InvalidHomeRegionException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
start_query
(**kwargs)¶Starts a CloudTrail Lake query. The required QueryStatement
parameter provides your SQL query, enclosed in single quotation marks. Use the optional DeliveryS3Uri
parameter to deliver the query results to an S3 bucket.
See also: AWS API Documentation
Request Syntax
response = client.start_query(
QueryStatement='string',
DeliveryS3Uri='string'
)
[REQUIRED]
The SQL code of your query.
dict
Response Syntax
{
'QueryId': 'string'
}
Response Structure
(dict) --
QueryId (string) --
The ID of the started query.
Exceptions
CloudTrail.Client.exceptions.EventDataStoreARNInvalidException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.InactiveEventDataStoreException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.InvalidQueryStatementException
CloudTrail.Client.exceptions.MaxConcurrentQueriesException
CloudTrail.Client.exceptions.InsufficientEncryptionPolicyException
CloudTrail.Client.exceptions.InvalidS3PrefixException
CloudTrail.Client.exceptions.InvalidS3BucketNameException
CloudTrail.Client.exceptions.InsufficientS3BucketPolicyException
CloudTrail.Client.exceptions.S3BucketDoesNotExistException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
stop_import
(**kwargs)¶Stops a specified import.
See also: AWS API Documentation
Request Syntax
response = client.stop_import(
ImportId='string'
)
[REQUIRED]
The ID of the import.
{
'ImportId': 'string',
'ImportSource': {
'S3': {
'S3LocationUri': 'string',
'S3BucketRegion': 'string',
'S3BucketAccessRoleArn': 'string'
}
},
'Destinations': [
'string',
],
'ImportStatus': 'INITIALIZING'|'IN_PROGRESS'|'FAILED'|'STOPPED'|'COMPLETED',
'CreatedTimestamp': datetime(2015, 1, 1),
'UpdatedTimestamp': datetime(2015, 1, 1),
'StartEventTime': datetime(2015, 1, 1),
'EndEventTime': datetime(2015, 1, 1),
'ImportStatistics': {
'PrefixesFound': 123,
'PrefixesCompleted': 123,
'FilesCompleted': 123,
'EventsCompleted': 123,
'FailedEntries': 123
}
}
Response Structure
The ID for the import.
The source S3 bucket for the import.
The source S3 bucket.
The URI for the source S3 bucket.
The region associated with the source S3 bucket.
The IAM ARN role used to access the source S3 bucket.
The ARN of the destination event data store.
The status of the import.
The timestamp of the import's creation.
The timestamp of the import's last update.
Used with EndEventTime
to bound a StartImport
request, and limit imported trail events to only those events logged within a specified time period.
Used with StartEventTime
to bound a StartImport
request, and limit imported trail events to only those events logged within a specified time period.
Returns information on the stopped import.
The number of S3 prefixes found for the import.
The number of S3 prefixes that completed import.
The number of log files that completed import.
The number of trail events imported into the event data store.
The number of failed entries.
Exceptions
CloudTrail.Client.exceptions.ImportNotFoundException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
stop_logging
(**kwargs)¶Suspends the recording of Amazon Web Services 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.
See also: AWS API Documentation
Request Syntax
response = client.stop_logging(
Name='string'
)
[REQUIRED]
Specifies the name or the CloudTrail ARN of the trail for which CloudTrail will stop logging Amazon Web Services API calls. The following is the format of a trail ARN.
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
{}
Response Structure
Returns the objects or data listed below if successful. Otherwise, returns an error.
Exceptions
CloudTrail.Client.exceptions.TrailNotFoundException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.InvalidHomeRegionException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
update_event_data_store
(**kwargs)¶Updates an event data store. The required EventDataStore
value is an ARN or the ID portion of the ARN. Other parameters are optional, but at least one optional parameter must be specified, or CloudTrail throws an error. RetentionPeriod
is in days, and valid values are integers between 90 and 2557. By default, TerminationProtection
is enabled. AdvancedEventSelectors
includes or excludes management and data events in your event data store; for more information about AdvancedEventSelectors
, see PutEventSelectorsRequest$AdvancedEventSelectors .
See also: AWS API Documentation
Request Syntax
response = client.update_event_data_store(
EventDataStore='string',
Name='string',
AdvancedEventSelectors=[
{
'Name': 'string',
'FieldSelectors': [
{
'Field': 'string',
'Equals': [
'string',
],
'StartsWith': [
'string',
],
'EndsWith': [
'string',
],
'NotEquals': [
'string',
],
'NotStartsWith': [
'string',
],
'NotEndsWith': [
'string',
]
},
]
},
],
MultiRegionEnabled=True|False,
OrganizationEnabled=True|False,
RetentionPeriod=123,
TerminationProtectionEnabled=True|False,
KmsKeyId='string'
)
[REQUIRED]
The ARN (or the ID suffix of the ARN) of the event data store that you want to update.
The advanced event selectors used to select events for the event data store. You can configure up to five advanced event selectors for each event data store.
Advanced event selectors let you create fine-grained selectors for the following CloudTrail event record fields. They help you control costs by logging only those events that are important to you. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
readOnly
eventSource
eventName
eventCategory
resources.type
resources.ARN
You cannot apply both event selectors and advanced event selectors to a trail.
An optional, descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets".
Contains all selector statements in an advanced event selector.
A single selector statement in an advanced event selector.
A field in an event record on which to filter events to be logged. Supported fields include readOnly
, eventCategory
, eventSource
(for management events), eventName
, resources.type
, and resources.ARN
.
readOnly
** - Optional. Can be set to Equals
a value of true
or false
. If you do not add this field, CloudTrail logs both read
and write
events. A value of true
logs only read
events. A value of false
logs only write
events.eventSource
** - For filtering management events only. This can be set only to NotEquals
kms.amazonaws.com
.eventName
** - Can use any operator. You can use it to filter in or filter out any data event logged to CloudTrail, such as PutBucket
or GetSnapshotBlock
. You can have multiple values for this field, separated by commas.eventCategory
** - This is required. It must be set to Equals
, and the value must be Management
or Data
.resources.type
** - This field is required. resources.type
can only use the Equals
operator, and the value can be one of the following:AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
You can have only one resources.type
field per selector. To log data events on more than one resource type, add another selector.
resources.ARN
** - You can use any operator with resources.ARN
, but if you use Equals
or NotEquals
, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type. For example, if resources.type equals AWS::S3::Object
, the ARN must be in one of the following formats. To log all data events for all objects in a specific S3 bucket, use the StartsWith
operator, and include only the bucket ARN as the matching value. The trailing slash is intentional; do not exclude it. Replace the text between less than and greater than symbols (<>) with resource-specific information.arn:<partition>:s3:::<bucket_name>/
arn:<partition>:s3:::<bucket_name>/<object_path>/
When resources.type
equals AWS::S3::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in one of the following formats. To log events on all objects in an S3 access point, we recommend that you use only the access point ARN, don’t include the object path, and use the StartsWith
or NotStartsWith
operators.
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>/object/<object_path>
When resources.type equals AWS::Lambda::Function
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:lambda:<region>:<account_ID>:function:<function_name>
When resources.type equals AWS::DynamoDB::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>
When resources.type
equals AWS::S3Outposts::Object
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-outposts:<region>:<account_ID>:<object_path>
When resources.type
equals AWS::ManagedBlockchain::Node
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:managedblockchain:<region>:<account_ID>:nodes/<node_ID>
When resources.type
equals AWS::S3ObjectLambda::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-object-lambda:<region>:<account_ID>:accesspoint/<access_point_name>
When resources.type
equals AWS::EC2::Snapshot
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:ec2:<region>::snapshot/<snapshot_ID>
When resources.type
equals AWS::DynamoDB::Stream
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>/stream/<date_time>
When resources.type
equals AWS::Glue::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:glue:<region>:<account_ID>:table/<database_name>/<table_name>
An operator that includes events that match the exact value of the event record field specified as the value of Field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.
An operator that includes events that match the first few characters of the event record field specified as the value of Field
.
An operator that includes events that match the last few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the exact value of the event record field specified as the value of Field
.
An operator that excludes events that match the first few characters of the event record field specified as the value of Field
.
An operator that excludes events that match the last few characters of the event record field specified as the value of Field
.
Specifies the KMS key ID to use to encrypt the events 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.
Warning
Disabling or deleting the KMS key, or removing CloudTrail permissions on the key, prevents CloudTrail from logging events to the event data store, and prevents users from querying the data in the event data store that was encrypted with the key. After you associate an event data store with a KMS key, the KMS key cannot be removed or changed. Before you disable or delete a KMS key that you are using with an event data store, delete or back up your event data store.
CloudTrail also supports KMS multi-Region keys. For more information about multi-Region keys, see Using multi-Region keys in the Key Management Service Developer Guide .
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
dict
Response Syntax
{
'EventDataStoreArn': 'string',
'Name': 'string',
'Status': 'CREATED'|'ENABLED'|'PENDING_DELETION',
'AdvancedEventSelectors': [
{
'Name': 'string',
'FieldSelectors': [
{
'Field': 'string',
'Equals': [
'string',
],
'StartsWith': [
'string',
],
'EndsWith': [
'string',
],
'NotEquals': [
'string',
],
'NotStartsWith': [
'string',
],
'NotEndsWith': [
'string',
]
},
]
},
],
'MultiRegionEnabled': True|False,
'OrganizationEnabled': True|False,
'RetentionPeriod': 123,
'TerminationProtectionEnabled': True|False,
'CreatedTimestamp': datetime(2015, 1, 1),
'UpdatedTimestamp': datetime(2015, 1, 1),
'KmsKeyId': 'string'
}
Response Structure
(dict) --
EventDataStoreArn (string) --
The ARN of the event data store.
Name (string) --
The name of the event data store.
Status (string) --
The status of an event data store. Values can be ENABLED
and PENDING_DELETION
.
AdvancedEventSelectors (list) --
The advanced event selectors that are applied to the event data store.
(dict) --
Advanced event selectors let you create fine-grained selectors for the following CloudTrail event record fields. They help you control costs by logging only those events that are important to you. For more information about advanced event selectors, see Logging data events for trails in the CloudTrail User Guide .
readOnly
eventSource
eventName
eventCategory
resources.type
resources.ARN
You cannot apply both event selectors and advanced event selectors to a trail.
Name (string) --
An optional, descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets".
FieldSelectors (list) --
Contains all selector statements in an advanced event selector.
(dict) --
A single selector statement in an advanced event selector.
Field (string) --
A field in an event record on which to filter events to be logged. Supported fields include readOnly
, eventCategory
, eventSource
(for management events), eventName
, resources.type
, and resources.ARN
.
readOnly
** - Optional. Can be set to Equals
a value of true
or false
. If you do not add this field, CloudTrail logs both read
and write
events. A value of true
logs only read
events. A value of false
logs only write
events.eventSource
** - For filtering management events only. This can be set only to NotEquals
kms.amazonaws.com
.eventName
** - Can use any operator. You can use it to filter in or filter out any data event logged to CloudTrail, such as PutBucket
or GetSnapshotBlock
. You can have multiple values for this field, separated by commas.eventCategory
** - This is required. It must be set to Equals
, and the value must be Management
or Data
.resources.type
** - This field is required. resources.type
can only use the Equals
operator, and the value can be one of the following:AWS::S3::Object
AWS::Lambda::Function
AWS::DynamoDB::Table
AWS::S3Outposts::Object
AWS::ManagedBlockchain::Node
AWS::S3ObjectLambda::AccessPoint
AWS::EC2::Snapshot
AWS::S3::AccessPoint
AWS::DynamoDB::Stream
AWS::Glue::Table
You can have only one resources.type
field per selector. To log data events on more than one resource type, add another selector.
resources.ARN
** - You can use any operator with resources.ARN
, but if you use Equals
or NotEquals
, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type. For example, if resources.type equals AWS::S3::Object
, the ARN must be in one of the following formats. To log all data events for all objects in a specific S3 bucket, use the StartsWith
operator, and include only the bucket ARN as the matching value. The trailing slash is intentional; do not exclude it. Replace the text between less than and greater than symbols (<>) with resource-specific information.arn:<partition>:s3:::<bucket_name>/
arn:<partition>:s3:::<bucket_name>/<object_path>/
When resources.type
equals AWS::S3::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in one of the following formats. To log events on all objects in an S3 access point, we recommend that you use only the access point ARN, don’t include the object path, and use the StartsWith
or NotStartsWith
operators.
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>
arn:<partition>:s3:<region>:<account_ID>:accesspoint/<access_point_name>/object/<object_path>
When resources.type equals AWS::Lambda::Function
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:lambda:<region>:<account_ID>:function:<function_name>
When resources.type equals AWS::DynamoDB::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>
When resources.type
equals AWS::S3Outposts::Object
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-outposts:<region>:<account_ID>:<object_path>
When resources.type
equals AWS::ManagedBlockchain::Node
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:managedblockchain:<region>:<account_ID>:nodes/<node_ID>
When resources.type
equals AWS::S3ObjectLambda::AccessPoint
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:s3-object-lambda:<region>:<account_ID>:accesspoint/<access_point_name>
When resources.type
equals AWS::EC2::Snapshot
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:ec2:<region>::snapshot/<snapshot_ID>
When resources.type
equals AWS::DynamoDB::Stream
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:dynamodb:<region>:<account_ID>:table/<table_name>/stream/<date_time>
When resources.type
equals AWS::Glue::Table
, and the operator is set to Equals
or NotEquals
, the ARN must be in the following format:
arn:<partition>:glue:<region>:<account_ID>:table/<database_name>/<table_name>
Equals (list) --
An operator that includes events that match the exact value of the event record field specified as the value of Field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.
StartsWith (list) --
An operator that includes events that match the first few characters of the event record field specified as the value of Field
.
EndsWith (list) --
An operator that includes events that match the last few characters of the event record field specified as the value of Field
.
NotEquals (list) --
An operator that excludes events that match the exact value of the event record field specified as the value of Field
.
NotStartsWith (list) --
An operator that excludes events that match the first few characters of the event record field specified as the value of Field
.
NotEndsWith (list) --
An operator that excludes events that match the last few characters of the event record field specified as the value of Field
.
MultiRegionEnabled (boolean) --
Indicates whether the event data store includes events from all regions, or only from the region in which it was created.
OrganizationEnabled (boolean) --
Indicates whether an event data store is collecting logged events for an organization in Organizations.
RetentionPeriod (integer) --
The retention period, in days.
TerminationProtectionEnabled (boolean) --
Indicates whether termination protection is enabled for the event data store.
CreatedTimestamp (datetime) --
The timestamp that shows when an event data store was first created.
UpdatedTimestamp (datetime) --
The timestamp that shows when the event data store was last updated. UpdatedTimestamp
is always either the same or newer than the time shown in CreatedTimestamp
.
KmsKeyId (string) --
Specifies the KMS key ID that encrypts the events delivered by CloudTrail. The value is a fully specified ARN to a KMS key in the following format.
arn:aws:kms:us-east-2:123456789012:key/12345678-1234-1234-1234-123456789012
Exceptions
CloudTrail.Client.exceptions.EventDataStoreARNInvalidException
CloudTrail.Client.exceptions.EventDataStoreNotFoundException
CloudTrail.Client.exceptions.EventDataStoreHasOngoingImportException
CloudTrail.Client.exceptions.InactiveEventDataStoreException
CloudTrail.Client.exceptions.InvalidParameterException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.InsufficientEncryptionPolicyException
CloudTrail.Client.exceptions.InvalidKmsKeyIdException
CloudTrail.Client.exceptions.KmsKeyNotFoundException
CloudTrail.Client.exceptions.KmsException
CloudTrail.Client.exceptions.CloudTrailAccessNotEnabledException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
CloudTrail.Client.exceptions.OrganizationsNotInUseException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
CloudTrail.Client.exceptions.OrganizationNotInAllFeaturesModeException
update_trail
(**kwargs)¶Updates trail settings that control what events you are logging, and how to handle 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.
See also: AWS API Documentation
Request Syntax
response = client.update_trail(
Name='string',
S3BucketName='string',
S3KeyPrefix='string',
SnsTopicName='string',
IncludeGlobalServiceEvents=True|False,
IsMultiRegionTrail=True|False,
EnableLogFileValidation=True|False,
CloudWatchLogsLogGroupArn='string',
CloudWatchLogsRoleArn='string',
KmsKeyId='string',
IsOrganizationTrail=True|False
)
[REQUIRED]
Specifies the name of the trail or trail ARN. If Name
is a trail name, the string must meet the following requirements:
my-_namespace
and my--namespace
are not valid.If Name
is a trail ARN, it must be in the following format.
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
Specifies whether log file validation is enabled. The default is false.
Note
When you disable log file integrity validation, the chain of digest files is broken after one hour. CloudTrail does 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.
CloudWatchLogsRoleArn
.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.
CloudTrail also supports KMS multi-Region keys. For more information about multi-Region keys, see Using multi-Region keys in the Key Management Service Developer Guide .
Examples:
true
, the trail will be created in all Amazon Web Services accounts that belong to the organization. If the trail is an organization trail and this is set to false
, the trail will remain in the current Amazon Web Services account but be deleted from all member accounts in the organization.dict
Response Syntax
{
'Name': 'string',
'S3BucketName': 'string',
'S3KeyPrefix': 'string',
'SnsTopicName': 'string',
'SnsTopicARN': 'string',
'IncludeGlobalServiceEvents': True|False,
'IsMultiRegionTrail': True|False,
'TrailARN': 'string',
'LogFileValidationEnabled': True|False,
'CloudWatchLogsLogGroupArn': 'string',
'CloudWatchLogsRoleArn': 'string',
'KmsKeyId': 'string',
'IsOrganizationTrail': True|False
}
Response Structure
(dict) --
Returns the objects or data listed below if successful. Otherwise, returns an error.
Name (string) --
Specifies the name of the trail.
S3BucketName (string) --
Specifies the name of the Amazon S3 bucket designated for publishing log files.
S3KeyPrefix (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 IAM Log Files .
SnsTopicName (string) --
This field is no longer in use. Use UpdateTrailResponse$SnsTopicARN .
SnsTopicARN (string) --
Specifies the ARN of the Amazon SNS topic that CloudTrail uses to send notifications when log files are delivered. The following is the format of a topic ARN.
arn:aws:sns:us-east-2:123456789012:MyTopic
IncludeGlobalServiceEvents (boolean) --
Specifies whether the trail is publishing events from global services such as IAM to the log files.
IsMultiRegionTrail (boolean) --
Specifies whether the trail exists in one region or in all regions.
TrailARN (string) --
Specifies the ARN of the trail that was updated. The following is the format of a trail ARN.
arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
LogFileValidationEnabled (boolean) --
Specifies whether log file integrity validation is enabled.
CloudWatchLogsLogGroupArn (string) --
Specifies the Amazon Resource Name (ARN) of the log group to which CloudTrail logs are delivered.
CloudWatchLogsRoleArn (string) --
Specifies the role for the CloudWatch Logs endpoint to assume to write to a user's log group.
KmsKeyId (string) --
Specifies the KMS key ID that encrypts the logs delivered by CloudTrail. The value is a fully specified ARN to a KMS key in the following format.
arn:aws:kms:us-east-2:123456789012:key/12345678-1234-1234-1234-123456789012
IsOrganizationTrail (boolean) --
Specifies whether the trail is an organization trail.
Exceptions
CloudTrail.Client.exceptions.S3BucketDoesNotExistException
CloudTrail.Client.exceptions.InsufficientS3BucketPolicyException
CloudTrail.Client.exceptions.InsufficientSnsTopicPolicyException
CloudTrail.Client.exceptions.InsufficientEncryptionPolicyException
CloudTrail.Client.exceptions.TrailNotFoundException
CloudTrail.Client.exceptions.InvalidS3BucketNameException
CloudTrail.Client.exceptions.InvalidS3PrefixException
CloudTrail.Client.exceptions.InvalidSnsTopicNameException
CloudTrail.Client.exceptions.InvalidKmsKeyIdException
CloudTrail.Client.exceptions.InvalidTrailNameException
CloudTrail.Client.exceptions.TrailNotProvidedException
CloudTrail.Client.exceptions.InvalidEventSelectorsException
CloudTrail.Client.exceptions.InvalidParameterCombinationException
CloudTrail.Client.exceptions.InvalidHomeRegionException
CloudTrail.Client.exceptions.KmsKeyNotFoundException
CloudTrail.Client.exceptions.KmsKeyDisabledException
CloudTrail.Client.exceptions.KmsException
CloudTrail.Client.exceptions.InvalidCloudWatchLogsLogGroupArnException
CloudTrail.Client.exceptions.InvalidCloudWatchLogsRoleArnException
CloudTrail.Client.exceptions.CloudWatchLogsDeliveryUnavailableException
CloudTrail.Client.exceptions.UnsupportedOperationException
CloudTrail.Client.exceptions.OperationNotPermittedException
CloudTrail.Client.exceptions.CloudTrailAccessNotEnabledException
CloudTrail.Client.exceptions.InsufficientDependencyServiceAccessPermissionException
CloudTrail.Client.exceptions.OrganizationsNotInUseException
CloudTrail.Client.exceptions.NotOrganizationMasterAccountException
CloudTrail.Client.exceptions.OrganizationNotInAllFeaturesModeException
CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException
CloudTrail.Client.exceptions.CloudTrailInvalidClientTokenIdException
CloudTrail.Client.exceptions.InvalidParameterException
The available paginators are:
CloudTrail.Paginator.ListImportFailures
CloudTrail.Paginator.ListImports
CloudTrail.Paginator.ListPublicKeys
CloudTrail.Paginator.ListTags
CloudTrail.Paginator.ListTrails
CloudTrail.Paginator.LookupEvents
CloudTrail.Paginator.
ListImportFailures
¶paginator = client.get_paginator('list_import_failures')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from CloudTrail.Client.list_import_failures()
.
See also: AWS API Documentation
Request Syntax
response_iterator = paginator.paginate(
ImportId='string',
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
[REQUIRED]
The ID of the import.
A dictionary that provides parameters to control pagination.
The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken
will be provided in the output that you can use to resume pagination.
The size of each page.
A token to specify where to start paginating. This is the NextToken
from a previous response.
dict
Response Syntax
{
'Failures': [
{
'Location': 'string',
'Status': 'FAILED'|'RETRY'|'SUCCEEDED',
'ErrorType': 'string',
'ErrorMessage': 'string',
'LastUpdatedTime': datetime(2015, 1, 1)
},
],
}
Response Structure
(dict) --
Failures (list) --
Contains information about the import failures.
(dict) --
Provides information about an import failure.
Location (string) --
The location of the failure in the S3 bucket.
Status (string) --
The status of the import.
ErrorType (string) --
The type of import error.
ErrorMessage (string) --
Provides the reason the import failed.
LastUpdatedTime (datetime) --
When the import was last updated.
CloudTrail.Paginator.
ListImports
¶paginator = client.get_paginator('list_imports')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from CloudTrail.Client.list_imports()
.
See also: AWS API Documentation
Request Syntax
response_iterator = paginator.paginate(
Destination='string',
ImportStatus='INITIALIZING'|'IN_PROGRESS'|'FAILED'|'STOPPED'|'COMPLETED',
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
A dictionary that provides parameters to control pagination.
The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken
will be provided in the output that you can use to resume pagination.
The size of each page.
A token to specify where to start paginating. This is the NextToken
from a previous response.
dict
Response Syntax
{
'Imports': [
{
'ImportId': 'string',
'ImportStatus': 'INITIALIZING'|'IN_PROGRESS'|'FAILED'|'STOPPED'|'COMPLETED',
'Destinations': [
'string',
],
'CreatedTimestamp': datetime(2015, 1, 1),
'UpdatedTimestamp': datetime(2015, 1, 1)
},
],
}
Response Structure
(dict) --
Imports (list) --
The list of returned imports.
(dict) --
Contains information about an import that was returned by a lookup request.
ImportId (string) --
The ID of the import.
ImportStatus (string) --
The status of the import.
Destinations (list) --
The ARN of the destination event data store.
CreatedTimestamp (datetime) --
The timestamp of the import's creation.
UpdatedTimestamp (datetime) --
The timestamp of the import's last update.
CloudTrail.Paginator.
ListPublicKeys
¶paginator = client.get_paginator('list_public_keys')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from CloudTrail.Client.list_public_keys()
.
See also: AWS API Documentation
Request Syntax
response_iterator = paginator.paginate(
StartTime=datetime(2015, 1, 1),
EndTime=datetime(2015, 1, 1),
PaginationConfig={
'MaxItems': 123,
'StartingToken': 'string'
}
)
A dictionary that provides parameters to control pagination.
The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken
will be provided in the output that you can use to resume pagination.
A token to specify where to start paginating. This is the NextToken
from a previous response.
dict
Response Syntax
{
'PublicKeyList': [
{
'Value': b'bytes',
'ValidityStartTime': datetime(2015, 1, 1),
'ValidityEndTime': datetime(2015, 1, 1),
'Fingerprint': 'string'
},
],
}
Response Structure
(dict) --
Returns the objects or data listed below if successful. Otherwise, returns an error.
PublicKeyList (list) --
Contains an array of PublicKey objects.
Note
The returned public keys may have validity time ranges that overlap.
(dict) --
Contains information about a returned public key.
Value (bytes) --
The DER encoded public key value in PKCS#1 format.
ValidityStartTime (datetime) --
The starting time of validity of the public key.
ValidityEndTime (datetime) --
The ending time of validity of the public key.
Fingerprint (string) --
The fingerprint of the public key.
CloudTrail.Paginator.
ListTags
¶paginator = client.get_paginator('list_tags')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from CloudTrail.Client.list_tags()
.
See also: AWS API Documentation
Request Syntax
response_iterator = paginator.paginate(
ResourceIdList=[
'string',
],
PaginationConfig={
'MaxItems': 123,
'StartingToken': 'string'
}
)
[REQUIRED]
Specifies a list of trail and event data store ARNs whose tags will be listed. The list has a limit of 20 ARNs.
A dictionary that provides parameters to control pagination.
The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken
will be provided in the output that you can use to resume pagination.
A token to specify where to start paginating. This is the NextToken
from a previous response.
dict
Response Syntax
{
'ResourceTagList': [
{
'ResourceId': 'string',
'TagsList': [
{
'Key': 'string',
'Value': 'string'
},
]
},
],
}
Response Structure
(dict) --
Returns the objects or data listed below if successful. Otherwise, returns an error.
ResourceTagList (list) --
A list of resource tags.
(dict) --
A resource tag.
ResourceId (string) --
Specifies the ARN of the resource.
TagsList (list) --
A list of tags.
(dict) --
A custom key-value pair associated with a resource such as a CloudTrail trail.
Key (string) --
The key in a key-value pair. The key must be must be no longer than 128 Unicode characters. The key must be unique for the resource to which it applies.
Value (string) --
The value in a key-value pair of a tag. The value must be no longer than 256 Unicode characters.
CloudTrail.Paginator.
ListTrails
¶paginator = client.get_paginator('list_trails')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from CloudTrail.Client.list_trails()
.
See also: AWS API Documentation
Request Syntax
response_iterator = paginator.paginate(
PaginationConfig={
'MaxItems': 123,
'StartingToken': 'string'
}
)
A dictionary that provides parameters to control pagination.
The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken
will be provided in the output that you can use to resume pagination.
A token to specify where to start paginating. This is the NextToken
from a previous response.
{
'Trails': [
{
'TrailARN': 'string',
'Name': 'string',
'HomeRegion': 'string'
},
],
}
Response Structure
Returns the name, ARN, and home region of trails in the current account.
Information about a CloudTrail trail, including the trail's name, home region, and Amazon Resource Name (ARN).
The ARN of a trail.
The name of a trail.
The Amazon Web Services Region in which a trail was created.
CloudTrail.Paginator.
LookupEvents
¶paginator = client.get_paginator('lookup_events')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from CloudTrail.Client.lookup_events()
.
See also: AWS API Documentation
Request Syntax
response_iterator = paginator.paginate(
LookupAttributes=[
{
'AttributeKey': 'EventId'|'EventName'|'ReadOnly'|'Username'|'ResourceType'|'ResourceName'|'EventSource'|'AccessKeyId',
'AttributeValue': 'string'
},
],
StartTime=datetime(2015, 1, 1),
EndTime=datetime(2015, 1, 1),
EventCategory='insight',
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
Contains a list of lookup attributes. Currently the list can contain only one item.
Specifies an attribute and value that filter the events returned.
Specifies an attribute on which to filter the events returned.
Specifies a value for the specified AttributeKey.
insight
as the value of EventCategory
, no Insights events are returned.A dictionary that provides parameters to control pagination.
The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken
will be provided in the output that you can use to resume pagination.
The size of each page.
A token to specify where to start paginating. This is the NextToken
from a previous response.
dict
Response Syntax
{
'Events': [
{
'EventId': 'string',
'EventName': 'string',
'ReadOnly': 'string',
'AccessKeyId': 'string',
'EventTime': datetime(2015, 1, 1),
'EventSource': 'string',
'Username': 'string',
'Resources': [
{
'ResourceType': 'string',
'ResourceName': 'string'
},
],
'CloudTrailEvent': 'string'
},
],
}
Response Structure
(dict) --
Contains a response to a LookupEvents action.
Events (list) --
A list of events returned based on the lookup attributes specified and the CloudTrail event. The events list is sorted by time. The most recent event is listed first.
(dict) --
Contains information about an event that was returned by a lookup request. The result includes a representation of a CloudTrail event.
EventId (string) --
The CloudTrail ID of the event returned.
EventName (string) --
The name of the event returned.
ReadOnly (string) --
Information about whether the event is a write event or a read event.
AccessKeyId (string) --
The Amazon Web Services access key ID that was used to sign the request. If the request was made with temporary security credentials, this is the access key ID of the temporary credentials.
EventTime (datetime) --
The date and time of the event returned.
EventSource (string) --
The Amazon Web Services service to which the request was made.
Username (string) --
A user name or role name of the requester that called the API in the event returned.
Resources (list) --
A list of resources referenced by the event returned.
(dict) --
Specifies the type and name of a resource referenced by an event.
ResourceType (string) --
The type of a resource referenced by the event returned. When the resource type cannot be determined, null is returned. Some examples of resource types are: Instance for EC2, Trail for CloudTrail, DBInstance for Amazon RDS, and AccessKey for IAM. To learn more about how to look up and filter events by the resource types supported for a service, see Filtering CloudTrail Events .
ResourceName (string) --
The name of the resource referenced by the event returned. These are user-created names whose values will depend on the environment. For example, the resource name might be "auto-scaling-test-group" for an Auto Scaling Group or "i-1234567" for an EC2 Instance.
CloudTrailEvent (string) --
A JSON string that contains a representation of the event returned.