mypy-boto3-route53-recovery-control-config Type Annotations

1.42.3 · active · verified Sat Apr 11

This library provides type annotations for the `boto3` AWS SDK's Route53RecoveryControlConfig service, compatible with static analysis tools like mypy, pyright, and various IDEs. Currently at version `1.42.3`, it helps improve code quality and error detection for `boto3` usage. The release cadence is tied to updates in `boto3` itself and the `mypy-boto3-builder` project, which generates these stubs.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a type-hinted `Route53RecoveryControlConfigClient` using `boto3` and perform a basic operation, `list_clusters`, with a type-hinted response. It requires `boto3` to be installed and AWS credentials configured in the environment.

import boto3
import os

from mypy_boto3_route53_recovery_control_config.client import Route53RecoveryControlConfigClient
from mypy_boto3_route53_recovery_control_config.type_defs import ListClustersOutputTypeDef

def get_r53_recovery_control_config_client() -> Route53RecoveryControlConfigClient:
    """Returns a type-hinted Route53RecoveryControlConfig client."""
    # Ensure AWS credentials and region are configured (e.g., via environment variables or ~/.aws/credentials)
    region_name = os.environ.get('AWS_REGION', 'us-east-1')
    return boto3.client('route53-recovery-control-config', region_name=region_name)

def list_r53_recovery_clusters() -> ListClustersOutputTypeDef:
    """Lists Route53 Recovery Control Config clusters with type hints."""
    client = get_r53_recovery_control_config_client()
    response: ListClustersOutputTypeDef = client.list_clusters()
    for cluster in response.get('Clusters', []):
        print(f"Cluster ARN: {cluster['ClusterArn']}, Name: {cluster['ClusterName']}")
    return response

if __name__ == '__main__':
    try:
        print("Listing Route53 Recovery Control Config clusters...")
        result = list_r53_recovery_clusters()
        print(f"Successfully listed {len(result.get('Clusters', []))} clusters.")
    except Exception as e:
        print(f"An error occurred: {e}")
        print("Please ensure 'boto3' is installed and AWS credentials/region are configured.")

view raw JSON →