Type Annotations for Boto3 IAM

1.42.64 · active · verified Sun Apr 12

types-boto3-iam provides comprehensive type annotations for the AWS Identity and Access Management (IAM) service client within the `boto3` library. This package is generated by `mypy-boto3-builder` and aims to enhance static analysis, autocompletion, and error detection in IDEs and linters like MyPy and Pyright, ensuring type safety for `boto3` IAM operations. It is actively maintained with frequent updates reflecting `boto3` versions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize an IAM client with type annotations using `types-boto3-iam`. The `IAMClient` type ensures that `iam_client` methods and their arguments/return values are checked by your static type checker, providing autocompletion and early error detection.

import boto3
from boto3.session import Session
from types_boto3_iam import IAMClient

# Instantiate a boto3 session and client
session: Session = boto3.session.Session()
iam_client: IAMClient = session.client("iam")

# Example usage with type-hinted client
# (Note: In a real scenario, use proper error handling and credential management)
try:
    response = iam_client.list_users(MaxItems=1)
    for user in response.get('Users', []):
        print(f"IAM User: {user['UserName']} (ARN: {user['Arn']})")
except Exception as e:
    print(f"Error listing users: {e}")

view raw JSON →