Type annotations for aiobotocore KMS

3.4.0 · active · verified Sat Apr 11

Type annotations for `aiobotocore KMS` service, compatible with various type checkers and IDEs like VSCode, PyCharm, and mypy. Generated by `mypy-boto3-builder`, it currently provides stubs for `aiobotocore 3.4.0` and is generated with `mypy-boto3-builder 8.12.0`. Releases are frequent, typically mirroring `mypy-boto3-builder` and underlying `aiobotocore` updates.

Warnings

Install

Imports

Quickstart

This example demonstrates how to use the `KMSClient` from `types-aiobotocore-kms` with `aiobotocore` to describe a KMS key, leveraging type hints for better code completion and error checking. It includes basic setup for an asynchronous client session.

import asyncio
import os

from aiobotocore.session import get_session
from types_aiobotocore_kms.client import KMSClient

async def describe_key_example():
    session = get_session()
    async with session.create_client(
        "kms",
        region_name=os.environ.get('AWS_REGION', 'us-east-1'),
        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'test'),
        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'test'),
        aws_session_token=os.environ.get('AWS_SESSION_TOKEN', None),
    ) as client:  # type: KMSClient
        # Replace with a valid KMS Key ID or ARN for real usage
        key_id = "arn:aws:kms:us-east-1:123456789012:key/your-key-id" # Placeholder
        try:
            response = await client.describe_key(KeyId=key_id)
            print(f"Key description: {response.get('KeyMetadata', {})}")
        except Exception as e:
            print(f"Error describing key {key_id}: {e}")

if __name__ == "__main__":
    # Ensure AWS credentials and region are set in environment variables
    # or configure aiobotocore session appropriately.
    # For this example, placeholders are used, but for real AWS interaction,
    # valid credentials and a valid KeyId are required.
    asyncio.run(describe_key_example())

view raw JSON →