Registry / type-stubs / types-aiobotocore-ec2

types-aiobotocore-ec2

JSON →
library3.9.0pypypi✓ verified 25d ago

This library provides comprehensive type annotations for the aiobotocore EC2 service (version 3.4.0), generated by `mypy-boto3-builder`. It enables static type checking with tools like MyPy and Pyright, offering improved developer experience for asynchronous AWS interactions. The project maintains an active release cadence, often aligning with `aiobotocore` and `botocore` updates.

pip install types-aiobotocore-ec2
INSTALL
IMPORT
SIG · TYPES-AIOBOTOCORE-
T
types-aiobotocore-ec2
type-stubspythonv3.9.0
Install
3.3s avg
Import
Disk
24MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.9.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
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 25.7MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.3s · import 0.000s · 26MB
24MB installed
● package 24MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EC2Client
from types_aiobotocore_ec2 import EC2Client
from types_aiobotocore_ec2 import EC2Client

This example demonstrates how to set up an `aiobotocore` client for EC2 and apply type annotations using `types-aiobotocore-ec2`. It explicitly types the client and shows how to leverage TypeDefs for response objects, enabling better static analysis and IDE autocompletion for asynchronous AWS calls.

import asyncio from aiobotocore.session import get_session from typing import TYPE_CHECKING if TYPE_CHECKING: from types_aiobotocore_ec2.client import EC2Client from types_aiobotocore_ec2.type_defs import DescribeInstancesResultTypeDef async def describe_ec2_instances(): session = get_session() async with session.create_client("ec2") as client: # Explicit type annotation for the client client: "EC2Client" = client response = await client.describe_instances() print(f"Found {len(response['Reservations'])} reservations.") for reservation in response['Reservations']: for instance in reservation['Instances']: print(f" Instance ID: {instance['InstanceId']}, State: {instance['State']['Name']}") # Example of using a TypeDef for a dictionary structure example_type_def: "DescribeInstancesResultTypeDef" = response print(f"Example TypeDef Reservations key: {example_type_def['Reservations'][0]['ReservationId']}") if __name__ == "__main__": asyncio.run(describe_ec2_instances())
Debug
Known issues
breakingSupport for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and subsequent generated packages. Users on Python 3.8 must either upgrade Python or use an older version of `types-aiobotocore-ec2`.
fix
Upgrade your Python environment to 3.9 or newer.
affects: >=3.4.0 (for types-aiobotocore-ec2), >=8.12.0 (for mypy-boto3-builder)
breakingGenerated TypeDef naming conventions may have changed in `mypy-boto3-builder` version 8.9.0. For instance, `CreateDistributionRequestRequestTypeDef` might become `CreateDistributionRequestTypeDef`. Code relying on specific TypeDef names may break.
fix
Review your type hints and update TypeDef names according to the latest generated types if you experience `NameError` or type resolution issues.
affects: >=3.x.x (for types-aiobotocore-ec2), >=8.9.0 (for mypy-boto3-builder)
gotchaInstalling `types-aiobotocore-ec2` only provides type annotations. For actual runtime execution, you must also install the `aiobotocore` library itself (`pip install aiobotocore`).
fix
Ensure both `aiobotocore` and `types-aiobotocore-ec2` are installed in your environment.
affects: all
gotchaWhen using standalone service packages like `types-aiobotocore-ec2` or `types-aiobotocore-lite`, explicit type annotations (e.g., `client: EC2Client`) are often required for full type checking and IDE support. The main `types-aiobotocore` package with overloads can sometimes infer types implicitly.
fix
Add explicit type annotations for clients, resources, paginators, and waiters imported from `types_aiobotocore_ec2`.
affects: all
gotchaPyCharm users might experience slow performance or high CPU usage due to the large number of `Literal` overloads in these stub packages (related to PyCharm issue PY-40997).
fix
Consider using the `-lite` version of the stubs (`types-aiobotocore-lite-ec2` if available) or disable PyCharm's internal type checker and rely on external tools like MyPy or Pyright instead.
affects: all
Upgrade
Version history
3.9.0latest on PyPI · released Aug 2, 2026
Audit
Dependencies
aiobotocorerequiredThis package provides type stubs for aiobotocore. The runtime library is required for execution.
typing-extensionsrequiredWhile Python 3.9+ is required, aiobotocore itself lists typing-extensions as a dependency, and the builder ensures its version compatibility.
Agent activity
29 hits · last 30 days
node
24
OpenAI (training)
1
Resources
types-aiobotocore-ec2 — pip install types-aiobotocore-ec2 · libregistry