Registry / type-stubs / types-boto3-ec2

types-boto3-ec2

JSON →
library1.43.82pypypi✓ verified 24d ago

types-boto3-ec2 provides comprehensive type annotations for the Amazon EC2 service client in boto3, enabling static type checking with tools like mypy, pyright, and enhanced IDE support. It is part of the mypy-boto3-builder ecosystem, which generates separate stub packages for each AWS service. The current version is 1.42.85, with frequent updates synchronized with boto3 releases.

pip install types-boto3-ec2
INSTALL
IMPORT
SIG · TYPES-BOTO3-EC2
T
types-boto3-ec2
type-stubspythonv1.43.82
Install
3.6s avg
Import
Disk
49MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.43.82 · 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 · 75.5MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.6s · import 0.000s · 25MB
49MB installed
● package 49MB
Code
Verified usage

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

EC2Client
from types_boto3_ec2 import EC2Client
from types_boto3_ec2 import EC2Client

This quickstart demonstrates how types-boto3-ec2 provides type hints for your boto3 EC2 client, enabling static analysis and IDE autocompletion. The 'if TYPE_CHECKING:' block is optional but shows how to explicitly reference the stub types without creating a runtime dependency. The type checker will automatically infer types for `boto3.client('ec2')`.

import boto3 from typing import TYPE_CHECKING if TYPE_CHECKING: from types_boto3_ec2 import EC2Client # Boto3 client will be automatically typed by mypy-boto3-ec2 if installed ec2_client: EC2Client = boto3.client('ec2') # Example usage with type-hinted client response = ec2_client.describe_instances( Filters=[ { 'Name': 'instance-state-name', 'Values': ['running'] }, ] ) for reservation in response['Reservations']: for instance in reservation['Instances']: print(f"Instance ID: {instance['InstanceId']}, Type: {instance['InstanceType']}")
Debug
Known issues
breakingSupport for Python 3.8 was removed in mypy-boto3-builder 8.12.0 (and consequently for types-boto3-ec2 versions generated by it). Python 3.9+ is now required.
fix
Upgrade your Python environment to 3.9 or higher.
affects: mypy-boto3-builder >= 8.12.0
gotchaThis is a service-specific stub package. To get type annotations for other AWS services (e.g., S3, Lambda), you must install their respective `types-boto3-<service>` packages (e.g., `types-boto3-s3`). Installing just `types-boto3` will install a 'full' package but it's often more efficient to install specific stubs.
fix
Install the specific stub package for each boto3 service you use (e.g., `pip install types-boto3-s3 types-boto3-lambda`).
affects: All versions
breakingIn mypy-boto3-builder 8.9.0, there were breaking changes to TypeDef naming conventions, where packed method arguments used shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) and conflicting `Extra` postfixes moved to the end (e.g., `CreateDistributionExtraRequestTypeDef` became `CreateDistributionRequestExtraTypeDef`).
fix
Update your code to use the new TypeDef names if you were explicitly referencing them. Check the generated stub files or documentation for the correct new names.
affects: mypy-boto3-builder >= 8.9.0
gotchaThe `mypy-boto3` ecosystem switched to PEP 561 compliant packages in version 8.12.0. This primarily affects how type checkers locate and interpret the installed stub files.
fix
Ensure your type checker (e.g., mypy, pyright) is up-to-date and configured correctly to discover PEP 561 stub packages.
affects: mypy-boto3-builder >= 8.12.0
gotchaPylint might complain about undefined variables when using type hints with `types-boto3-ec2` outside of a `TYPE_CHECKING` block. It is recommended to use an `if TYPE_CHECKING:` guard and set types to `object` in the `else` branch to avoid runtime dependencies and Pylint warnings.
fix
Wrap explicit type imports in `if TYPE_CHECKING:` blocks and provide fallback `object` assignments in the `else` block for runtime safety and Pylint compatibility, as shown in the quickstart example.
affects: All versions
Upgrade
Version history
1.43.82latest on PyPI · released Aug 27, 2026
Audit
Dependencies
boto3requiredThis package provides type stubs for the boto3 library, which must be installed to be used at runtime.
Agent activity
37 hits · last 30 days
node
32
Amazon
1
OpenAI (training)
1
Resources
types-boto3-ec2 — pip install types-boto3-ec2 · libregistry