or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

argument-processing.mdcommand-system.mdcore-driver.mdcustom-commands.mderror-handling.mdhelp-system.mdindex.mdoutput-formatting.mdplugin-system.mdtesting-framework.mdutilities.md
tile.json

tessl/pypi-awscli

Universal Command Line Environment for AWS.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/awscli@1.42.x

To install, run

npx @tessl/cli install tessl/pypi-awscli@1.42.0

index.mddocs/

AWS CLI

AWS 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.

Package Information

  • Package Name: awscli
  • Package Type: pypi
  • Language: Python
  • Installation: pip install awscli
  • Python Requirements: Python 3.9+ (3.9, 3.10, 3.11, 3.12, 3.13)

Core Imports

import awscli
from awscli.clidriver import main, create_clidriver

Common programmatic usage:

from awscli.clidriver import CLIDriver, create_clidriver
from awscli.commands import CLICommand
from awscli.customizations.commands import BasicCommand

Basic Usage

Command Line Execution

from awscli.clidriver import main
import sys

# Execute AWS CLI commands programmatically
exit_code = main(['s3', 'ls'])
sys.exit(exit_code)

Programmatic CLI Driver

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}")

Custom Command Development

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 0

Architecture

The AWS CLI is built on a layered architecture that enables extensive customization:

  • CLI Driver: Core execution engine that processes commands and manages session state
  • Command System: Hierarchical command structure supporting services, operations, and custom commands
  • Argument Processing: Flexible argument parsing, validation, and transformation system
  • Plugin Architecture: Event-driven plugin system for extending functionality
  • Output Formatting: Multiple output formats (JSON, table, text, YAML) with customizable formatters
  • Session Management: Integration with botocore for AWS service communication and credential management

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.

Capabilities

Core CLI Driver

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): ...

Core CLI Driver

Command System

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): ...

Command System

Argument Processing

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): ...

Argument Processing

Custom Commands Framework

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): ...

Custom Commands

Plugin System

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: dict

Plugin System

Output Formatting

Flexible 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: ...

Output Formatting

Utilities and Helpers

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): ...

Utilities

Testing Framework

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(): ...

Testing Framework

Help System

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: ...

Help System

Error Handling

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): ...

Error Handling

Types

Core Types

# 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): ...