Registry /
type-stubs / mypy-boto3-cloudtrail-data
Install & Compatibility
Where this runs
tested against v1.43.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.570s · 51.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.7s · import 0.536s · 52MB
50MB installed
● package 50MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CloudTrailDataServiceClient
✓ from mypy_boto3_cloudtrail_data.client import CloudTrailDataServiceClient
This is the primary client type for the CloudTrail Data service.
PutAuditEventsRequestRequestTypeDef
✓ from mypy_boto3_cloudtrail_data.type_defs import PutAuditEventsRequestRequestTypeDef
Type definition for the request parameters of `put_audit_events`.
PutAuditEventsResponseTypeDef
✓ from mypy_boto3_cloudtrail_data.type_defs import PutAuditEventsResponseTypeDef
Type definition for the response of `put_audit_events`.
This example demonstrates how to use the `mypy-boto3-cloudtrail-data` type annotations with a `boto3` client to put audit events into AWS CloudTrail Lake. It showcases explicit type hints for the client and the request/response payloads, which enable static type checking and improved IDE support.
import boto3
from typing import TYPE_CHECKING, List, Dict, Any
if TYPE_CHECKING:
from mypy_boto3_cloudtrail_data.client import CloudTrailDataServiceClient
from mypy_boto3_cloudtrail_data.type_defs import (AuditRecordEntryTypeDef, PutAuditEventsRequestRequestTypeDef, PutAuditEventsResponseTypeDef)
def put_cloudtrail_audit_events(event_data_store_id: str, audit_events: List[AuditRecordEntryTypeDef]) -> PutAuditEventsResponseTypeDef:
"""Puts audit events into CloudTrail Lake with type hints."""
# Boto3 client without type hint - mypy will complain if mypy-boto3 is installed
# Use TYPE_CHECKING guard for production code to avoid runtime dependency on mypy-boto3
if TYPE_CHECKING:
client: CloudTrailDataServiceClient = boto3.client("cloudtrail-data")
else:
client = boto3.client("cloudtrail-data")
# Example request payload with type hint
request_payload: PutAuditEventsRequestRequestTypeDef = {
"audit_events": audit_events,
"EventDataStore": event_data_store_id
}
print(f"Putting {len(audit_events)} audit events into {event_data_store_id}...")
response: PutAuditEventsResponseTypeDef = client.put_audit_events(**request_payload)
print(f"Result: {response['FailedEntries']}")
return response
if __name__ == "__main__":
# Replace with your actual Event Data Store ID
# For a runnable example, ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
# and an existing CloudTrail Lake Event Data Store ID is provided.
sample_event_data_store_id = "your-event-data-store-id" # os.environ.get('CLOUD_TRAIL_DATA_STORE_ID', 'your-event-data-store-id')
sample_audit_events: List[AuditRecordEntryTypeDef] = [
{
"EventID": "example-event-id-1",
"EventData": "{\"eventVersion\":\"1.08\",\"userIdentity\":{\"type\":\"IAMUser\",\"principalId\":\"AIDAJ45Q7YDR2T3W4XXXB\",\"arn\":\"arn:aws:iam::123456789012:user/Alice\",\"accountId\":\"123456789012\",\"userName\":\"Alice\"},\"eventTime\":\"2026-04-11T12:00:00Z\",\"eventSource\":\"my.application.com\",\"eventName\":\"Login\",\"awsRegion\":\"us-east-1\",\"sourceIPAddress\":\"203.0.113.1\",\"userAgent\":\"Mozilla/5.0\",\"requestParameters\":null,\"responseElements\":null}",
"EventDataChecksum": "string", # Optional, required if provided for integrity check
"ExternalID": "string" # Optional
},
{
"EventID": "example-event-id-2",
"EventData": "{\"eventVersion\":\"1.08\",\"userIdentity\":{\"type\":\"IAMUser\",\"principalId\":\"AIDAJ45Q7YDR2T3W4XXXC\",\"arn\":\"arn:aws:iam::123456789012:user/Bob\",\"accountId\":\"123456789012\",\"userName\":\"Bob\"},\"eventTime\":\"2026-04-11T12:01:00Z\",\"eventSource\":\"my.application.com\",\"eventName\":\"Logout\",\"awsRegion\":\"us-east-1\",\"sourceIPAddress\":\"203.0.113.2\",\"userAgent\":\"Chrome\",\"requestParameters\":null,\"responseElements\":null}"
}
]
try:
# Ensure to replace 'your-event-data-store-id' with a valid ID from your AWS account
if sample_event_data_store_id == 'your-event-data-store-id':
print("Please replace 'your-event-data-store-id' with a valid CloudTrail Lake Event Data Store ID.")
else:
result = put_cloudtrail_audit_events(sample_event_data_store_id, sample_audit_events)
if result.get("FailedEntries"):
print(f"Some events failed: {result['FailedEntries']}")
else:
print("All events successfully put.")
except Exception as e:
print(f"An error occurred: {e}")
Debug
Known issues
breaking`mypy-boto3` packages (including this one) removed support for Python 3.8 starting with `mypy-boto3-builder` version 8.12.0. The package now requires Python 3.9 or higher.fixUpgrade your Python environment to 3.9 or later. Ensure your `requires_python` matches your project's `pyproject.toml` or `setup.cfg`.
affects: mypy-boto3-builder >= 8.12.0 (all generated stubs)
breakingStarting with `mypy-boto3-builder` 8.9.0, some `TypeDef` names were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) and conflicting `Extra` postfixes moved to the end. This may require updating import paths and type references in your code.fixReview your `TypeDef` imports and usage for the specific service and adjust names according to the latest generated types. Your IDE with `mypy-boto3` installed should help identify these.
affects: mypy-boto3-builder >= 8.9.0 (all generated stubs)
gotchaIt is crucial to match the `mypy-boto3-*` package version with your installed `boto3` version to ensure accurate type checking and avoid `mypy` errors or incorrect hints.fixAlways install `mypy-boto3-cloudtrail-data` with the same major.minor.patch version as your `boto3` installation (e.g., `boto3==1.42.3` and `mypy-boto3-cloudtrail-data==1.42.3`).
affects: All versions
gotchaThis package provides *type stubs* only. You must also install the actual `boto3` library for your code to run at runtime.fixEnsure both `boto3` and `mypy-boto3-cloudtrail-data` are listed in your project's dependencies.
affects: All versions
gotchaFor optimal IDE auto-completion and static analysis with `mypy`, explicit type annotations for `boto3.client()` calls are often required. While `boto3-stubs` provides some overload magic, explicit types are the most reliable.fixWhen initializing a client, add the explicit type hint: `client: CloudTrailDataServiceClient = boto3.client('cloudtrail-data')`. affects: All versions
Upgrade
Version history
1.43.0latest on PyPI · released Apr 29, 2026
Audit
Dependencies
boto3requiredThis package provides type stubs for the `boto3` library; `boto3` itself must be installed to run code.