CloudTrail

AWS CloudTrail records who did what in your AWS accounts. An API call — from the console, the CLI, an SDK, or another AWS service — is captured as an event with the calling identity, source IP, parameters, and result. It is the system of record for security investigation, compliance evidence, and answering "what changed?"

What lands in that record is set by configuration, not assumed. Trails and event data stores log management events by default; data events, network activity events, and Insights events are captured only where you configure selectors for them. Read a trail's selectors before you treat its history as complete.

With AWS CloudTrail, you can:

  • Look up recent activity: Search the last 90 days of management events by user, event name, resource, or event source
  • Inspect trail configuration: Describe trails, check logging status, and read the event and Insights selectors that decide what gets captured
  • Query history with SQL: Run CloudTrail Lake queries across event data stores for analysis that reaches further back than event lookup
  • Confirm coverage: Verify that logging is actually enabled and that multi-region and organization trails are delivering

In Sim, CloudTrail is the audit half of the AWS story. Where IAM and Identity Center answer who has access, CloudTrail answers what they actually did with it — so an agent can take a suspicious permission change and trace it back to the principal, the source IP, and the moment it happened, then hand a written timeline to whoever needs to act on it.

This block is read-only with one narrow exception: Cancel Query stops a running CloudTrail Lake query. It never enables or disables logging, alters trail configuration, or deletes a trail. Every operation it ships is covered by this policy, with no residual write risk:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "cloudtrail:DescribeTrails",
        "cloudtrail:GetTrail",
        "cloudtrail:GetTrailStatus",
        "cloudtrail:GetEventSelectors",
        "cloudtrail:GetInsightSelectors",
        "cloudtrail:GetEventDataStore",
        "cloudtrail:ListTrails",
        "cloudtrail:ListEventDataStores",
        "cloudtrail:ListTags",
        "cloudtrail:LookupEvents",
        "cloudtrail:StartQuery",
        "cloudtrail:DescribeQuery",
        "cloudtrail:GetQueryResults",
        "cloudtrail:CancelQuery"
      ],
      "Resource": "*"
    }
  ]
}

cloudtrail:CancelQuery is the action Cancel Query needs, and it is not implied by Describe*, Get*, or List* — omit it and that one operation fails with an access-denied error. Note that Start Query is billed per GB scanned and consumes your account's concurrent-query quota of 10.

Lookup Events is limited by AWS to two requests per second per account per Region. Each call uses AWS adaptive retry mode and allows up to six attempts, so a throttled request backs off exponentially with jitter and usually succeeds instead of surfacing an error. That is a retry budget, not a guarantee: sustained throttling past six attempts fails the call with a ThrottlingException, and because a fresh SDK client is built per invocation, adaptive mode's client-side rate limiter carries no pacing state between calls. Lookup Events also returns one page per call — feed nextToken back in to walk a broad search, and expect to handle a throttling error on a long paging loop.

Usage Instructions

Integrate AWS CloudTrail into workflows. Look up the last 90 days of management and Insights events by user, event name, resource, or access key; inspect trail configuration, logging status, and event selectors; and run SQL queries against CloudTrail Lake event data stores. This block never changes trail or event data store configuration, and never starts or stops logging. Starting and cancelling a Lake query are the only actions that are not reads, and AWS bills Lake queries on the data they scan. Requires AWS access key and secret access key.

Actions

CloudTrail Look Up Events

Look up AWS CloudTrail management or Insights events from the last 90 days in a Region

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
attributeKeystringNoLookup attribute to filter on: AccessKeyId, EventId, EventName, EventSource, ReadOnly, ResourceName, ResourceType, or Username. Must be paired with attributeValue
attributeValuestringNoValue the lookup attribute must equal. Must be paired with attributeKey
startTimestringNoOnly return events at or after this ISO 8601 timestamp
endTimestringNoOnly return events at or before this ISO 8601 timestamp
eventCategorystringNoSet to the value insight to return CloudTrail Insights events instead of management events
maxResultsnumberNoNumber of events to return, 1 to 50 (default 50)
nextTokenstringNoPagination token from a previous lookup, which must repeat the same filters

Output

ParameterTypeDescription
eventsarrayMatching events, most recent first
eventIdstringCloudTrail event ID
eventNamestringAPI action that was called
readOnlystringWhether the action was read-only, as the string 'true' or 'false'
accessKeyIdstringAccess key ID used to make the call, when applicable
eventTimestringWhen the event occurred (ISO 8601)
eventSourcestringAWS service endpoint that recorded the event
usernamestringName of the principal that made the call
resourcesarrayResources referenced by the event, as resourceType and resourceName
cloudTrailEventobjectFull CloudTrail event record parsed from JSON, including userIdentity, sourceIPAddress, userAgent, requestParameters, responseElements, and errorCode
cloudTrailEventRawstringRaw CloudTrail event JSON string, populated only when it could not be parsed
nextTokenstringPagination token for the next page of events

CloudTrail Describe Trails

Retrieve the full configuration of one or more CloudTrail trails in the current Region

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
trailNameListstringNoComma-separated trail names or ARNs. Leave empty to describe every trail in the Region. Trails in another Region must be given as ARNs
includeShadowTrailsbooleanNoInclude shadow trails (replications of trails created in another Region, and organization trails in member accounts). Defaults to true

Output

ParameterTypeDescription
trailsarrayFull configuration of each matching trail
namestringTrail name
s3BucketNamestringS3 bucket that receives log files
s3KeyPrefixstringS3 key prefix for delivered log files
snsTopicNamestringSNS topic notified on log delivery
snsTopicArnstringARN of that SNS topic
includeGlobalServiceEventsbooleanWhether global service events are recorded
isMultiRegionTrailbooleanWhether the trail records events in all Regions
homeRegionstringRegion in which the trail was created
trailArnstringARN of the trail
logFileValidationEnabledbooleanWhether log file integrity validation is enabled
cloudWatchLogsLogGroupArnstringCloudWatch Logs log group receiving events
cloudWatchLogsRoleArnstringRole CloudTrail assumes to write to CloudWatch Logs
kmsKeyIdstringKMS key used to encrypt log files
hasCustomEventSelectorsbooleanWhether the trail has custom event selectors
hasInsightSelectorsbooleanWhether the trail has Insights event selectors
isOrganizationTrailbooleanWhether the trail is an organization trail

CloudTrail Get Trail

Retrieve the settings of a single CloudTrail trail by name or ARN

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
namestringYesTrail name, or the trail ARN for a trail in another Region

Output

ParameterTypeDescription
namestringTrail name
s3BucketNamestringName of the S3 bucket that receives log files
s3KeyPrefixstringS3 key prefix prepended to delivered log files
snsTopicNamestringName of the SNS topic notified on log delivery
snsTopicArnstringARN of the SNS topic notified on log delivery
includeGlobalServiceEventsbooleanWhether the trail records global service events
isMultiRegionTrailbooleanWhether the trail records events in all Regions
homeRegionstringRegion in which the trail was created
trailArnstringARN of the trail
logFileValidationEnabledbooleanWhether log file integrity validation is enabled
cloudWatchLogsLogGroupArnstringARN of the CloudWatch Logs log group receiving events
cloudWatchLogsRoleArnstringARN of the role CloudTrail assumes to write to CloudWatch Logs
kmsKeyIdstringKMS key used to encrypt log files
hasCustomEventSelectorsbooleanWhether the trail has custom event selectors
hasInsightSelectorsbooleanWhether the trail has Insights event selectors
isOrganizationTrailbooleanWhether the trail is an organization trail

CloudTrail Get Trail Status

Check whether a CloudTrail trail is logging and surface its most recent delivery errors

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
namestringYesTrail name, or the trail ARN. An organization trail read from a member account must be given as an ARN

Output

ParameterTypeDescription
isLoggingbooleanWhether the trail is currently recording API calls
latestDeliveryErrorstringMost recent S3 error encountered delivering log files
latestDeliveryTimestringWhen log files were last delivered to S3 (ISO 8601)
latestNotificationErrorstringMost recent SNS error encountered sending a notification
latestNotificationTimestringWhen the last SNS notification was sent (ISO 8601)
latestCloudWatchLogsDeliveryErrorstringMost recent CloudWatch Logs delivery error
latestCloudWatchLogsDeliveryTimestringWhen events were last delivered to CloudWatch Logs (ISO 8601)
latestDigestDeliveryErrorstringMost recent S3 error encountered delivering a digest file
latestDigestDeliveryTimestringWhen a digest file was last delivered to S3 (ISO 8601)
startLoggingTimestringWhen logging was most recently started (ISO 8601)
stopLoggingTimestringWhen logging was most recently stopped (ISO 8601)

CloudTrail List Trails

List the ARN, name, and home Region of every CloudTrail trail visible to the account

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
nextTokenstringNoPagination token from a previous list request

Output

ParameterTypeDescription
trailsarrayTrail summaries
trailArnstringARN of the trail
namestringTrail name
homeRegionstringRegion in which the trail was created
nextTokenstringPagination token for the next page of trails, or null on the last page

CloudTrail Get Event Selectors

Read which management, data, and network activity events a CloudTrail trail is configured to log

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
trailNamestringYesTrail name or trail ARN

Output

ParameterTypeDescription
trailArnstringARN of the trail that owns these selectors
eventSelectorsarrayBasic event selectors configured on the trail
readWriteTypestringAll, ReadOnly, or WriteOnly
includeManagementEventsbooleanWhether management events are recorded
dataResourcesarrayData resources logged by the selector, as type and values
excludeManagementEventSourcesarrayEvent sources excluded from management event logging
advancedEventSelectorsarrayAdvanced event selectors configured on the trail
namestringName of the advanced event selector
fieldSelectorsarrayField selectors, each with field plus its equals, startsWith, endsWith, notEquals, notStartsWith, and notEndsWith values

CloudTrail Get Insight Selectors

Read which CloudTrail Insights types are enabled on a trail or event data store

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
trailNamestringNoTrail name or trail ARN. Cannot be combined with eventDataStore
eventDataStorestringNoEvent data store ARN, or the ID suffix of that ARN. Cannot be combined with trailName

Output

ParameterTypeDescription
trailArnstringARN of the trail whose Insights selectors were read
eventDataStoreArnstringARN of the source event data store that enabled Insights events
insightsDestinationstringARN of the destination event data store that logs Insights events
insightSelectorsarrayEnabled Insights types and their event categories
insightTypestringApiCallRateInsight or ApiErrorRateInsight
eventCategoriesarrayEvent categories the Insights type applies to: Management, Data, or both

CloudTrail Start Query

Start a CloudTrail Lake SQL query over an event data store

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
queryStatementstringNoSQL query to run, up to 10,000 characters. The event data store ID is named in the FROM clause. Supply this or queryAlias, not both
queryAliasstringNoAlias of a query template used by CloudTrail Lake dashboards. Supply this or queryStatement, not both
queryParametersstringNoComma-separated parameter values for the query alias, up to 10 values
deliveryS3UristringNoS3 URI where CloudTrail delivers the query results (e.g., s3://my-bucket/results)
eventDataStoreOwnerAccountIdstringNoAccount ID of the event data store owner, for a shared event data store

Output

ParameterTypeDescription
queryIdstringID of the started query. Pass it to Describe Query to poll status, or to Get Query Results to page through rows
eventDataStoreOwnerAccountIdstringAccount ID of the event data store owner

CloudTrail Describe Query

Check the status, run time, and scan statistics of a CloudTrail Lake query

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
queryIdstringNoID of the query returned by Start Query. Supply this or queryAlias, not both
queryAliasstringNoQuery template alias; returns the last run for that alias. Supply this or queryId, not both
refreshIdstringNoDashboard refresh ID, used together with queryAlias
eventDataStoreOwnerAccountIdstringNoAccount ID of the event data store owner, for a shared event data store

Output

ParameterTypeDescription
queryIdstringID of the query
queryStringstringSQL body of the query
queryStatusstringQUEUED, RUNNING, FINISHED, FAILED, CANCELLED, or TIMED_OUT
errorMessagestringError message returned if the query failed
deliveryS3UristringS3 URI the results were delivered to, if configured
deliveryStatusstringDelivery status of the S3 results (SUCCESS, FAILED, PENDING, and similar)
promptstringNatural-language prompt used to generate the query, if it was generated
eventDataStoreOwnerAccountIdstringAccount ID of the event data store owner
eventsMatchednumberNumber of events that matched the query
eventsScannednumberNumber of events scanned by the query
bytesScannednumberBytes scanned by the query
executionTimeInMillisnumberQuery run time in milliseconds
creationTimestringWhen the query was created (ISO 8601)

CloudTrail Get Query Results

Fetch a page of result rows from a finished CloudTrail Lake query

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
queryIdstringYesID of the query returned by Start Query
maxQueryResultsnumberNoMaximum rows to return on a single page, 1 to 1000
nextTokenstringNoPagination token from a previous results request
eventDataStoreOwnerAccountIdstringNoAccount ID of the event data store owner, for a shared event data store

Output

ParameterTypeDescription
queryStatusstringQUEUED, RUNNING, FINISHED, FAILED, CANCELLED, or TIMED_OUT
rowsarrayResult rows, each flattened into a single object keyed by the query column names
resultsCountnumberNumber of rows on this page
totalResultsCountnumberTotal number of rows the query produced
bytesScannednumberBytes scanned by the query
errorMessagestringError message returned if the query failed
nextTokenstringPagination token for the next page of rows

CloudTrail Cancel Query

Cancel a running CloudTrail Lake query

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
queryIdstringYesID of the query returned by Start Query
eventDataStoreOwnerAccountIdstringNoAccount ID of the event data store owner, for a shared event data store

Output

ParameterTypeDescription
queryIdstringID of the cancelled query
queryStatusstringStatus AWS reported for the query after the cancellation request. Cancellation is asynchronous, so this is typically RUNNING or CANCELLED — poll Describe Lake Query for the terminal status
eventDataStoreOwnerAccountIdstringAccount ID of the event data store owner, when the query was cross-account

CloudTrail List Event Data Stores

List the CloudTrail Lake event data stores in the account for the current Region

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
maxResultsnumberNoMaximum event data stores to return on a single page, 1 to 1000
nextTokenstringNoPagination token from a previous list request

Output

ParameterTypeDescription
eventDataStoresarrayEvent data stores in the account for the current Region
eventDataStoreArnstringARN of the event data store
namestringName of the event data store
statusstringCREATED, ENABLED, PENDING_DELETION, or an ingestion state
advancedEventSelectorsarrayAdvanced event selectors that define what the store ingests
multiRegionEnabledbooleanWhether the store collects events from all Regions
organizationEnabledbooleanWhether the store collects events for the organization
retentionPeriodnumberRetention period in days
terminationProtectionEnabledbooleanWhether termination protection is enabled
createdTimestampstringWhen the store was created (ISO 8601)
updatedTimestampstringWhen the store was last updated (ISO 8601)
nextTokenstringPagination token for the next page of event data stores

CloudTrail Get Event Data Store

Retrieve the configuration of a single CloudTrail Lake event data store

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
eventDataStorestringYesEvent data store ARN, or the ID suffix of that ARN

Output

ParameterTypeDescription
eventDataStoreArnstringARN of the event data store
namestringName of the event data store
statusstringCREATED, ENABLED, PENDING_DELETION, or an ingestion state
advancedEventSelectorsarrayAdvanced event selectors that define what the store ingests
namestringName of the advanced event selector
fieldSelectorsarrayField selectors, each with field plus its equals, startsWith, endsWith, notEquals, notStartsWith, and notEndsWith values
multiRegionEnabledbooleanWhether the store collects events from all Regions
organizationEnabledbooleanWhether the store collects events for the organization
retentionPeriodnumberRetention period in days
terminationProtectionEnabledbooleanWhether termination protection is enabled
createdTimestampstringWhen the store was created (ISO 8601)
updatedTimestampstringWhen the store was last updated (ISO 8601)
kmsKeyIdstringKMS key used to encrypt the store
billingModestringEXTENDABLE_RETENTION_PRICING or FIXED_RETENTION_PRICING
federationStatusstringLake Formation federation status
federationRoleArnstringARN of the role used for Lake Formation federation
partitionKeysarrayPartition keys of the event data store
namestringPartition key name
typestringPartition key data type

CloudTrail List Tags

List the tags on CloudTrail trails, event data stores, dashboards, or channels

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
resourceIdListstringYesComma-separated CloudTrail resource ARNs, up to 20
nextTokenstringNoReserved for future use by AWS

Output

ParameterTypeDescription
resourceTagsarrayTags for each requested resource
resourceIdstringARN of the tagged resource
tagsarrayTags on the resource, as key and value
nextTokenstringReserved for future use by AWS

On this page