Universal Command Line Environment for AWS.
npx @tessl/cli install tessl/pypi-awscli@1.42.0AWS CLI (awscli) is a unified command line interface for Amazon Web Services that provides comprehensive programmatic access to AWS services. Beyond its primary role as a command-line tool, it offers a rich Python API for building custom automation, creating CLI extensions, and integrating AWS functionality into applications.
pip install awscliimport awscli
from awscli.clidriver import main, create_clidriverCommon programmatic usage:
from awscli.clidriver import CLIDriver, create_clidriver
from awscli.commands import CLICommand
from awscli.customizations.commands import BasicCommandfrom awscli.clidriver import main
import sys
# Execute AWS CLI commands programmatically
exit_code = main(['s3', 'ls'])
sys.exit(exit_code)from awscli.clidriver import create_clidriver
# Create a CLI driver instance for more control
driver = create_clidriver()
exit_code = driver.main(['ec2', 'describe-instances', '--region', 'us-east-1'])
print(f"Command completed with exit code: {exit_code}")from awscli.customizations.commands import BasicCommand
class MyCustomCommand(BasicCommand):
NAME = 'my-custom-command'
DESCRIPTION = 'A custom AWS CLI command'
def _run_main(self, parsed_args, parsed_globals):
print("Executing custom command")
return 0The AWS CLI is built on a layered architecture that enables extensive customization:
This design enables AWS CLI to serve as both a powerful command-line tool and a foundation for building AWS-powered applications and automation tools.
The foundational CLI execution system that provides programmatic access to AWS CLI functionality, including session management, command routing, and plugin integration.
def main() -> int: ...
def create_clidriver() -> CLIDriver: ...
class CLIDriver:
def __init__(self, session=None): ...
def main(self, args=None) -> int: ...
def create_help_command(self): ...Comprehensive command framework for creating and executing AWS service operations and custom commands, with support for hierarchical command structures and argument processing.
class CLICommand:
name: str
lineage: list
lineage_names: list
arg_table: dict
def __call__(self, args, parsed_globals): ...
def create_help_command(self): ...
class ServiceCommand(CLICommand):
def __init__(self, cli_name, session, service_name=None): ...
class ServiceOperation:
def __init__(self, name, parent_name, operation_caller, operation_model, session): ...Advanced argument parsing, validation, and transformation system supporting complex AWS parameter structures, shorthand syntax, and file-based parameter input.
class BaseCLIArgument:
def __init__(self, name): ...
def add_to_arg_table(self): ...
def add_to_parser(self): ...
def add_to_params(self): ...
class CustomArgument(BaseCLIArgument):
def __init__(self, name, help_text='', dest=None, default=None,
action=None, required=None, choices=None, nargs=None,
cli_type_name=None, group_name=None, positional_arg=False,
no_paramfile=False, argument_model=None, synopsis='', const=None): ...
def unpack_argument(session, service_name, operation_name, cli_argument, value): ...Extensible framework for creating custom CLI commands with built-in support for argument handling, help generation, and integration with the AWS CLI command hierarchy.
class BasicCommand(CLICommand):
NAME: str
DESCRIPTION: str
SYNOPSIS: str
EXAMPLES: str
ARG_TABLE: dict
SUBCOMMANDS: dict
FROM_FILE: type
class _FromFile:
def __init__(self, *paths, **kwargs): ...Event-driven plugin architecture for extending AWS CLI functionality with custom handlers, commands, and integrations.
def load_plugins(plugin_mapping, event_hooks=None, include_builtins=True): ...
BUILTIN_PLUGINS: dictFlexible output formatting system supporting multiple formats (JSON, table, text, YAML) with customizable formatters and styling options.
def get_formatter(output_format, args): ...
def is_response_paginated(response) -> bool: ...
class Formatter:
def __init__(self, args): ...
class TableFormatter:
def __init__(self, args): ...
class MultiTable: ...Comprehensive utility functions for AWS CLI operations, including JSON handling, exception management, client creation, and compatibility helpers.
def split_on_commas(value) -> list: ...
def emit_top_level_args_parsed_event(session, args): ...
def write_exception(ex, outfile): ...
def create_nested_client(session, service_name, region_name=None,
endpoint_url=None, verify=None): ...
def json_encoder(obj): ...Extensive testing utilities for developing and validating AWS CLI commands, including test base classes, output capture, and AWS service mocking.
class BaseCLIDriverTest(unittest.TestCase): ...
class BaseAWSCommandParamsTest(unittest.TestCase): ...
class BaseS3CLICommand(unittest.TestCase): ...
def create_clidriver(): ...
def aws(*args): ...
def capture_output(): ...Comprehensive help system providing contextual documentation for AWS CLI commands, services, and operations with platform-specific rendering and interactive navigation.
class HelpCommand:
def __init__(self, session, command_table, arg_table, name, event_class=None): ...
def create_help_command(self): ...
def __call__(self, args, parsed_globals): ...
class ProviderHelpCommand(HelpCommand): ...
class ServiceHelpCommand(HelpCommand): ...
class OperationHelpCommand(HelpCommand): ...
def get_renderer(): ...
class PosixHelpRenderer: ...
class WindowsHelpRenderer: ...Structured exception handling system for AWS CLI operations, providing comprehensive error processing, HTTP error handling, and user-friendly error reporting.
class UnknownArgumentError(Exception): ...
class ParamError(Exception): ...
class ParamSyntaxError(ParamError): ...
class ParamUnknownKeyError(ParamError): ...
class ErrorHandler:
def __call__(self, parsed, **kwargs): ...
class ClientError(Exception): ...
class ServerError(Exception): ...
def write_exception(ex, outfile): ...# Package constants
__version__: str
EnvironmentVariables: dict
SCALAR_TYPES: set[str]
COMPLEX_TYPES: set[str]
# Core type aliases
ArgumentTable = dict[str, BaseCLIArgument]
CommandTable = dict[str, CLICommand]
ParsedArgs = argparse.Namespace
ParsedGlobals = argparse.Namespace
# Exception types
class UnknownArgumentError(Exception): ...
class ParamError(Exception): ...
class ParamSyntaxError(Exception): ...
class ParamUnknownKeyError(Exception): ...
class ClientError(Exception): ...
class ServerError(Exception): ...
class ExecutableNotFoundError(Exception): ...