Type annotations for boto3 WellArchitected

1.42.3 · active · verified Sat Apr 11

This library provides static type annotations for the AWS Well-Architected service, enabling `mypy` to perform static type checking on `boto3` code. It ensures type safety and enhances developer experience with improved autocompletion. The current version is 1.42.3, and it follows the `mypy-boto3-builder` release cadence, which is typically frequent due to `boto3` updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted `WellArchitectedClient` using `boto3` and the `mypy-boto3-wellarchitected` stubs. It uses environment variables for AWS credentials, which is good practice. The `list_workloads` call is included to show typical client interaction, though it requires valid AWS credentials and permissions to execute successfully.

import os
import boto3
from mypy_boto3_wellarchitected.client import WellArchitectedClient


def get_wellarchitected_client() -> WellArchitectedClient:
    """Initializes and returns a WellArchitectedClient with type annotations."""
    session = boto3.Session(
        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),
        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),
        region_name=os.environ.get('AWS_REGION', 'us-east-1')
    )
    client: WellArchitectedClient = session.client("wellarchitected")
    return client

# Example usage (will require valid AWS credentials for actual execution)
if __name__ == "__main__":
    try:
        wa_client = get_wellarchitected_client()
        # This call will typically fail without proper credentials and permissions
        # but demonstrates type-hinted client usage.
        response = wa_client.list_workloads(
            MaxResults=10
        )
        print("Successfully initialized WellArchitected client (response may be empty/error without valid creds).")
        # print(response.get('WorkloadSummaries'))
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →