mypy-boto3-eks-auth type annotations

1.42.3 · active · verified Sat Apr 11

mypy-boto3-eks-auth provides type annotations for the boto3 EKSAuth service, enabling static type checking for AWS EKSAuth client interactions. It is generated by the mypy-boto3-builder project and is currently at version 1.42.3, with updates frequently released alongside new boto3 versions or builder changes.

Warnings

Install

Imports

Quickstart

Demonstrates how to type-hint a `boto3` EKSAuth client using `mypy-boto3-eks-auth` for static analysis. It shows importing the client type and a response type, and type-hinting a client and its method call. Note that runtime execution of `get_token` requires valid AWS credentials and an existing EKS cluster.

import boto3
from mypy_boto3_eks_auth.client import EKSAuthClient
from mypy_boto3_eks_auth.type_defs import GetTokenResponseTypeDef
import os

# Type-hint the boto3 client directly for static analysis
eks_auth_client: EKSAuthClient = boto3.client(
    "eks-auth",
    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-west-2') # EKS is region-specific
)

print(f"Client object type: {type(eks_auth_client)}")

# Demonstrating a method call that mypy would type-check.
# This call requires a valid EKS cluster name and proper AWS credentials to succeed at runtime.
# For quickstart, we wrap it in a try-except as it might fail without real setup.
cluster_name = os.environ.get('EKS_CLUSTER_NAME', 'your-eks-cluster-name')

try:
    # This will likely result in an authentication/authorization error without real AWS credentials
    # and a valid EKS cluster configured.
    response: GetTokenResponseTypeDef = eks_auth_client.get_token(clusterName=cluster_name)
    print(f"Successfully called get_token (type checked):")
    print(f"  Token expiry: {response.get('expiration', 'N/A')}")
except Exception as e:
    print(f"Error calling get_token (expected without real setup or valid cluster): {e}")

# To verify type checking, you would run `mypy your_script_name.py`

view raw JSON →