CloudTrail / Client / start_query

start_query#

CloudTrail.Client.start_query(**kwargs)#

Starts a CloudTrail Lake query. Use the QueryStatement parameter to provide your SQL query, enclosed in single quotation marks. Use the optional DeliveryS3Uri parameter to deliver the query results to an S3 bucket.

StartQuery requires you specify either the QueryStatement parameter, or a QueryAlias and any QueryParameters. In the current release, the QueryAlias and QueryParameters parameters are used only for the queries that populate the CloudTrail Lake dashboards.

See also: AWS API Documentation

Request Syntax

response = client.start_query(
    QueryStatement='string',
    DeliveryS3Uri='string',
    QueryAlias='string',
    QueryParameters=[
        'string',
    ]
)
Parameters:
  • QueryStatement (string) – The SQL code of your query.

  • DeliveryS3Uri (string) – The URI for the S3 bucket where CloudTrail delivers the query results.

  • QueryAlias (string) – The alias that identifies a query template.

  • QueryParameters (list) –

    The query parameters for the specified QueryAlias.

    • (string) –

Return type:

dict

Returns:

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