AWS CloudTrail

2015/10/01 - AWS CloudTrail - 4 new 4 updated api methods

ListPublicKeys (new) Link ¶

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/public key pairs per region. Each digest file is signed with a private key unique to its region. Therefore, when you validate a digest file from a particular region, you must look in the same region for its corresponding public key.

Request Syntax

client.list_public_keys(
    StartTime=datetime(2015, 1, 1),
    EndTime=datetime(2015, 1, 1),
    NextToken='string'
)
type StartTime

datetime

param StartTime

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

type EndTime

datetime

param EndTime

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

type NextToken

string

param NextToken

Reserved for future use.

rtype

dict

returns

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.

ListTags (new) Link ¶

Lists the tags for the trail in the current region.

Request Syntax

client.list_tags(
    ResourceIdList=[
        'string',
    ],
    NextToken='string'
)
type ResourceIdList

list

param ResourceIdList

[REQUIRED]

Specifies a list of trail ARNs whose tags will be listed. The list has a limit of 20 ARNs. The format of a trail ARN is arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail .

  • (string) --

type NextToken

string

param NextToken

Reserved for future use.

rtype

dict

returns

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.

RemoveTags (new) Link ¶

Removes the specified tags from a trail.

Request Syntax

client.remove_tags(
    ResourceId='string',
    TagsList=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
type ResourceId

string

param ResourceId

[REQUIRED]

Specifies the ARN of the trail from which tags should be removed. The format of a trail ARN is arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail .

type TagsList

list

param TagsList

Specifies a list of tags to be removed.

  • (dict) --

    A custom key-value pair associated with a resource such as a CloudTrail trail.

    • Key (string) -- [REQUIRED]

      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.

rtype

dict

returns

Response Syntax

{}

Response Structure

  • (dict) --

    Returns the objects or data listed below if successful. Otherwise, returns an error.

AddTags (new) Link ¶

Adds one or more tags to a trail, up to a limit of 10. Tags must be unique per trail. Overwrites an existing tag's value when a new value is specified for an existing tag key. If you specify a key without a value, the tag will be created with the specified key and a value of null.

Request Syntax

client.add_tags(
    ResourceId='string',
    TagsList=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
type ResourceId

string

param ResourceId

[REQUIRED]

Specifies the ARN of the trail to which one or more tags will be added. The format of a trail ARN is arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail .

type TagsList

list

param TagsList

Contains a list of CloudTrail tags, up to a limit of 10.

  • (dict) --

    A custom key-value pair associated with a resource such as a CloudTrail trail.

    • Key (string) -- [REQUIRED]

      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.

rtype

dict

returns

Response Syntax

{}

Response Structure

  • (dict) --

    Returns the objects or data listed below if successful. Otherwise, returns an error.

CreateTrail (updated) Link ¶
Changes (request, response)
Request
{'EnableLogFileValidation': 'boolean', 'KmsKeyId': 'string'}
Response
{'KmsKeyId': 'string',
 'LogFileValidationEnabled': 'boolean',
 'TrailARN': 'string'}

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

Request Syntax

client.create_trail(
    Name='string',
    S3BucketName='string',
    S3KeyPrefix='string',
    SnsTopicName='string',
    IncludeGlobalServiceEvents=True|False,
    EnableLogFileValidation=True|False,
    CloudWatchLogsLogGroupArn='string',
    CloudWatchLogsRoleArn='string',
    KmsKeyId='string'
)
type Name

string

param Name

[REQUIRED]

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

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

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

  • Be between 3 and 128 characters

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

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

type S3BucketName

string

param S3BucketName

[REQUIRED]

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

type S3KeyPrefix

string

param S3KeyPrefix

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.

type SnsTopicName

string

param SnsTopicName

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

type IncludeGlobalServiceEvents

boolean

param IncludeGlobalServiceEvents

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

type EnableLogFileValidation

boolean

param EnableLogFileValidation

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 will not create digest files for log files that were delivered during a period in which log file integrity validation was disabled. For example, if you enable log file integrity validation at noon on January 1, disable it at noon on January 2, and re-enable it at noon on January 10, digest files will not be created for the log files delivered from noon on January 2 to noon on January 10. The same applies whenever you stop CloudTrail logging or delete a trail.

type CloudWatchLogsLogGroupArn

string

param CloudWatchLogsLogGroupArn

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

type CloudWatchLogsRoleArn

string

param CloudWatchLogsRoleArn

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

type KmsKeyId

string

param KmsKeyId

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

Examples:

  • alias/MyAliasName

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

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

  • 12345678-1234-1234-1234-123456789012

rtype

dict

returns

Response Syntax

{
    'Name': 'string',
    'S3BucketName': 'string',
    'S3KeyPrefix': 'string',
    'SnsTopicName': 'string',
    'IncludeGlobalServiceEvents': True|False,
    'TrailARN': 'string',
    'LogFileValidationEnabled': True|False,
    'CloudWatchLogsLogGroupArn': 'string',
    'CloudWatchLogsRoleArn': 'string',
    'KmsKeyId': 'string'
}

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) --

      Specifies the name of the Amazon SNS topic defined for notification of log file delivery.

    • IncludeGlobalServiceEvents (boolean) --

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

    • TrailARN (string) --

      Specifies the ARN of the trail that was created.

    • 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 logs delivered by CloudTrail. The value is a fully specified ARN to a KMS key in the format:

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

DescribeTrails (updated) Link ¶
Changes (response)
{'trailList': {'KmsKeyId': 'string',
               'LogFileValidationEnabled': 'boolean',
               'TrailARN': 'string'}}

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

Request Syntax

client.describe_trails(
    trailNameList=[
        'string',
    ]
)
type trailNameList

list

param trailNameList

Specifies a list of trail names, trail ARNs, or both, of the trails to describe. The format of a trail ARN is arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail . If an empty list is specified, information for the trail in the current region is returned.

  • (string) --

rtype

dict

returns

Response Syntax

{
    'trailList': [
        {
            'Name': 'string',
            'S3BucketName': 'string',
            'S3KeyPrefix': 'string',
            'SnsTopicName': 'string',
            'IncludeGlobalServiceEvents': True|False,
            'TrailARN': 'string',
            'LogFileValidationEnabled': True|False,
            'CloudWatchLogsLogGroupArn': 'string',
            'CloudWatchLogsRoleArn': 'string',
            'KmsKeyId': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    Returns the objects or data listed below if successful. Otherwise, returns an error.

    • trailList (list) --

      The list of trail objects.

      • (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) --

          Name of the existing Amazon SNS topic that CloudTrail uses to notify the account owner when new CloudTrail log files have been delivered. The maximum length is 256 characters.

        • IncludeGlobalServiceEvents (boolean) --

          Set to True to include AWS API calls from AWS global services such as IAM. Otherwise, False .

        • TrailARN (string) --

          The Amazon Resource Name of the trail. The TrailARN format is arn:aws:cloudtrail:us-east-1: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 format:

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

GetTrailStatus (updated) Link ¶
Changes (response)
{'LatestDeliveryAttemptSucceeded': 'string',
 'LatestDeliveryAttemptTime': 'string',
 'LatestDigestDeliveryError': 'string',
 'LatestDigestDeliveryTime': 'timestamp',
 'LatestNotificationAttemptSucceeded': 'string',
 'LatestNotificationAttemptTime': 'string',
 'TimeLoggingStarted': 'string',
 'TimeLoggingStopped': 'string'}

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.

Request Syntax

client.get_trail_status(
    Name='string'
)
type Name

string

param Name

[REQUIRED]

Specifies the name or the CloudTrail ARN of the trail for which you are requesting status. The format of a trail ARN is arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail .

rtype

dict

returns

Response Syntax

{
    '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

  • (dict) --

    Returns the objects or data listed below if successful. Otherwise, returns an error.

    • IsLogging (boolean) --

      Whether the CloudTrail is currently logging AWS API calls.

    • LatestDeliveryError (string) --

      Displays any Amazon S3 error that CloudTrail encountered when attempting to deliver log files to the designated bucket. For more information see the topic Error Responses in the Amazon S3 API Reference.

      Note

      This error occurs only when there is a problem with the destination S3 bucket and will not occur for timeouts. To resolve the issue, create a new bucket and call UpdateTrail to specify the new bucket, or fix the existing objects so that CloudTrail can again write to the bucket.

    • LatestNotificationError (string) --

      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.

    • LatestDeliveryTime (datetime) --

      Specifies the date and time that CloudTrail last delivered log files to an account's Amazon S3 bucket.

    • LatestNotificationTime (datetime) --

      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.

    • StartLoggingTime (datetime) --

      Specifies the most recent date and time when CloudTrail started recording API calls for an AWS account.

    • StopLoggingTime (datetime) --

      Specifies the most recent date and time when CloudTrail stopped recording API calls for an AWS account.

    • LatestCloudWatchLogsDeliveryError (string) --

      Displays any CloudWatch Logs error that CloudTrail encountered when attempting to deliver logs to CloudWatch Logs.

    • LatestCloudWatchLogsDeliveryTime (datetime) --

      Displays the most recent date and time when CloudTrail delivered logs to CloudWatch Logs.

    • LatestDigestDeliveryTime (datetime) --

      Specifies the date and time that CloudTrail last delivered a digest file to an account's Amazon S3 bucket.

    • LatestDigestDeliveryError (string) --

      Displays any Amazon S3 error that CloudTrail encountered when attempting to deliver a digest file to the designated bucket. For more information see the topic Error Responses in the Amazon S3 API Reference.

      Note

      This error occurs only when there is a problem with the destination S3 bucket and will not occur for timeouts. To resolve the issue, create a new bucket and call UpdateTrail to specify the new bucket, or fix the existing objects so that CloudTrail can again write to the bucket.

    • LatestDeliveryAttemptTime (string) --

      This field is deprecated.

    • LatestNotificationAttemptTime (string) --

      This field is deprecated.

    • LatestNotificationAttemptSucceeded (string) --

      This field is deprecated.

    • LatestDeliveryAttemptSucceeded (string) --

      This field is deprecated.

    • TimeLoggingStarted (string) --

      This field is deprecated.

    • TimeLoggingStopped (string) --

      This field is deprecated.

UpdateTrail (updated) Link ¶
Changes (request, response)
Request
{'EnableLogFileValidation': 'boolean', 'KmsKeyId': 'string'}
Response
{'KmsKeyId': 'string',
 'LogFileValidationEnabled': 'boolean',
 'TrailARN': 'string'}

Updates the settings that specify delivery of log files. Changes to a trail do not require stopping the CloudTrail service. Use this action to designate an existing bucket for log delivery. If the existing bucket has previously been a target for CloudTrail log files, an IAM policy exists for the bucket.

Request Syntax

client.update_trail(
    Name='string',
    S3BucketName='string',
    S3KeyPrefix='string',
    SnsTopicName='string',
    IncludeGlobalServiceEvents=True|False,
    EnableLogFileValidation=True|False,
    CloudWatchLogsLogGroupArn='string',
    CloudWatchLogsRoleArn='string',
    KmsKeyId='string'
)
type Name

string

param Name

[REQUIRED]

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

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

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

  • Be between 3 and 128 characters

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

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

If Name is a trail ARN, it must be in the format arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail .

type S3BucketName

string

param S3BucketName

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

type S3KeyPrefix

string

param S3KeyPrefix

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.

type SnsTopicName

string

param SnsTopicName

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

type IncludeGlobalServiceEvents

boolean

param IncludeGlobalServiceEvents

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

type EnableLogFileValidation

boolean

param EnableLogFileValidation

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 will not create digest files for log files that were delivered during a period in which log file integrity validation was disabled. For example, if you enable log file integrity validation at noon on January 1, disable it at noon on January 2, and re-enable it at noon on January 10, digest files will not be created for the log files delivered from noon on January 2 to noon on January 10. The same applies whenever you stop CloudTrail logging or delete a trail.

type CloudWatchLogsLogGroupArn

string

param CloudWatchLogsLogGroupArn

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

type CloudWatchLogsRoleArn

string

param CloudWatchLogsRoleArn

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

type KmsKeyId

string

param KmsKeyId

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

Examples:

  • alias/MyAliasName

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

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

  • 12345678-1234-1234-1234-123456789012

rtype

dict

returns

Response Syntax

{
    'Name': 'string',
    'S3BucketName': 'string',
    'S3KeyPrefix': 'string',
    'SnsTopicName': 'string',
    'IncludeGlobalServiceEvents': True|False,
    'TrailARN': 'string',
    'LogFileValidationEnabled': True|False,
    'CloudWatchLogsLogGroupArn': 'string',
    'CloudWatchLogsRoleArn': 'string',
    'KmsKeyId': 'string'
}

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) --

      Specifies the name of the Amazon SNS topic defined for notification of log file delivery.

    • IncludeGlobalServiceEvents (boolean) --

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

    • TrailARN (string) --

      Specifies the ARN of the trail that was updated.

    • 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 logs delivered by CloudTrail. The value is a fully specified ARN to a KMS key in the format:

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