Type annotations for boto3 IoTSecureTunneling

1.42.3 · active · verified Sat Apr 11

mypy-boto3-iotsecuretunneling provides type annotations (type stubs) for the `boto3` client for AWS IoTSecureTunneling service. It enhances static analysis for `boto3` usage, allowing tools like MyPy to catch type-related errors before runtime. The current version is 1.42.3, generated by `mypy-boto3-builder` and generally follows the release cadence of new `boto3` features or builder updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-iotsecuretunneling` to get full type hints for a `boto3` IoTSecureTunneling client. The `TYPE_CHECKING` block ensures that the explicit type hint is only considered by static analysis tools like MyPy, without affecting runtime behavior. This allows for autocompletion and error detection for all client methods and response structures.

import boto3
from mypy_boto3_iotsecuretunneling.client import IoTSecureTunnelingClient
from typing import TYPE_CHECKING

# In a real application, you'd configure AWS credentials
# e.g., via environment variables, ~/.aws/credentials, etc.

# Using TYPE_CHECKING to ensure the type hint is only active during static analysis
if TYPE_CHECKING:
    # This line ensures 'client' gets the correct type for static analysis
    client: IoTSecureTunnelingClient = boto3.client("iotsecuretunneling")
else:
    # This line runs at runtime, creating the actual boto3 client
    client = boto3.client("iotsecuretunneling")

# Now, 'client' will have methods and attributes type-hinted by mypy-boto3-iotsecuretunneling
# For example, calling open_tunnel:
try:
    response = client.open_tunnel(
        Description="MyTestTunnel",
        Tags=[
            {"key": "Project", "value": "MyApplication"},
            {"key": "Environment", "value": "Development"}
        ]
    )
    print(f"Successfully opened tunnel. ARN: {response['tunnelArn']}")
    print(f"Source Access Token: {response['sourceAccessToken']}")
    print(f"Destination Access Token: {response['destinationAccessToken']}")

    # Example of a type-hinted response structure
    # if TYPE_CHECKING:
    #     tunnel_arn: str = response['tunnelArn']

except client.exceptions.ResourceNotFoundException as e:
    print(f"Error: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →