### Zsh Autocomplete Script Setup Source: https://github.com/trek10inc/awsume/blob/master/docs/utilities/awsume-configure.md Provides the Zsh script for enabling command-line autocompletion for awsume. This script is typically loaded into the user's $ZDOTDIR/.zshenv file. ```zsh #compdef awsume _arguments "*: :($(awsume-autocomplete))" ``` -------------------------------- ### Bash Autocomplete Script Setup Source: https://github.com/trek10inc/awsume/blob/master/docs/utilities/awsume-configure.md Provides the Bash script for enabling command-line autocompletion for awsume. This script should be added to one of the user's Bash login files like ~/.bash_profile, ~/.bashrc, or ~/.bash_login. ```bash _awsume() { local cur prev opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" opts=$(awsume-autocomplete) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 } complete -F _awsume awsume ``` -------------------------------- ### PowerShell Autocomplete Script Setup Source: https://github.com/trek10inc/awsume/blob/master/docs/utilities/awsume-configure.md Provides the PowerShell script for enabling command-line autocompletion for awsume. This script registers an argument completer for the 'awsume' command within PowerShell. ```powershell Register-ArgumentCompleter -Native -CommandName awsume -ScriptBlock { param($wordToComplete, $commandAst, $cursorPosition) $(awsume-autocomplete) | Where-Object { $_ -like "$wordToComplete*" } | Sort-Object | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) } } ``` -------------------------------- ### Awsume Show Commands Example Source: https://github.com/trek10inc/awsume/blob/master/docs/general/usage.md Demonstrates how to use the `--show-commands` flag to display the necessary shell commands for exporting Awsume credentials. This is useful for setting credentials in different shell sessions. ```bash $ awsume my-admin -s export AWS_ACCESS_KEY_ID= export AWS_SECRET_ACCESS_KEY= export AWS_SECURITY_TOKEN= export AWS_REGION= export AWS_DEFAULT_REGION= export AWSUME_PROFILE=my-admin export AWSUME_EXPIRATION= ``` -------------------------------- ### Configure AWS Profile Credentials and Config Source: https://github.com/trek10inc/awsume/blob/master/docs/general/aws-file-configuration.md Examples demonstrating how to define AWS profiles using credentials and configuration files. Includes setups for basic authentication, region specification, MFA serials, and cross-account role assumption. ```ini # ~/.aws/credentials [dev] aws_access_key_id = AKIA... aws_secret_access_key = ABCD... # ~/.aws/config [profile dev] region = us-east-1 mfa_serial = arn:aws:iam::000000000000:mfa/devuser [profile myrole] region = us-east-1 source_profile = dev role_arn = arn:aws:iam::111111111111:role/myrole ``` -------------------------------- ### Setup Shell Autocomplete for AWSume Source: https://context7.com/trek10inc/awsume/llms.txt Configures shell autocompletion for AWSume profile names in Bash and Zsh. This enhances user experience by providing suggestions as you type commands. ```bash # Bash autocomplete (~/.bash_profile) _awsume() { local cur prev opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" opts=$(awsume-autocomplete) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 } complete -F _awsume awsume # Zsh autocomplete (~/.zshrc) #compdef awsume _arguments "*: :($(awsume-autocomplete))" # Refresh autocomplete cache (after adding new profiles) awsume --refresh-autocomplete ``` -------------------------------- ### Awsume Alias Configuration Source: https://github.com/trek10inc/awsume/blob/master/docs/utilities/awsume-configure.md Defines the necessary alias for awsume on Unix-like systems (Bash, Zsh). It ensures awsume is loaded correctly in shell sessions. Special configurations are provided for pyenv users. ```bash alias awsume=". awsume" ``` ```bash alias awsume=". $(pyenv which awsume)" ``` -------------------------------- ### Non-interactive Argument Handling (Python Import) Source: https://github.com/trek10inc/awsume/blob/master/docs/developer/awsume.md Demonstrates how to invoke awsume non-interactively using Python imports, including examples of passing arguments as strings and keyword arguments. ```python awsume('myprofile', '--role-duration', '43200') # Example of keyword argument transformation: # role_duration=43200 becomes --role-duration 43200 # with_saml=True becomes --with-saml ``` -------------------------------- ### Get Profile Names Function (Python) Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/get-profile-names.md The `get_profile_names` function is a hook implementation for awsume. It takes a configuration dictionary and an argparse.Namespace object as input and returns a list of strings, where each string represents an AWS profile name. ```python import argparse from awsume.awsumepy import hookimpl @hookimpl def get_profile_names(config: dict, arguments: argparse.Namespace): return [ 'profile1', 'profile2', 'profile3', ] ``` -------------------------------- ### Get AWS SAML Credentials (Python) Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/get-credentials.md The `get_credentials_with_saml` hook is invoked when the `--with-saml` flag is used. It bypasses other credential hooks and is responsible for generating a SAML assertion. The hook takes configuration and arguments, returning the SAML assertion as a string. ```python import argparse from awsume.awsumepy import hookimpl @hookimpl def get_credentials_with_saml(config: dict, arguments: argparse.Namespace): # ... handle getting saml assertion saml_assertion = 'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZ...3NhbWwycDpSZXNwb25zZT4=' return saml_assertion ``` -------------------------------- ### Get AWS Credentials (Python) Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/get-credentials.md The `get_credentials` hook is the primary method for retrieving AWS credentials. It accepts configuration, arguments, and existing profiles, returning a dictionary containing AWS credentials and expiration information. This is a standard method for fetching credentials. ```python import argparse from awsume.awsumepy import hookimpl from datetime import datetime @hookimpl def get_credentials(config: dict, arguments: argparse.Namespace, profiles: dict): # ... handle getting credentials return { 'AccessKeyId': 'AKIA...', 'SecretAccessKey': 'SECRET', 'SessionToken': 'LONGSECRET', 'Region': 'us-east-2', 'Expiration': datetime() } ``` -------------------------------- ### Get AWS Web Identity Credentials (Python) Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/get-credentials.md The `get_credentials_with_web_identity` hook is triggered by the `--with-web-identity` flag, preventing other credential hooks. It handles fetching credentials using web identity tokens, accepting configuration, arguments, and profiles, and returns a dictionary of AWS credentials. ```python import argparse from awsume.awsumepy import hookimpl @hookimpl def get_credentials_with_web_identity(config: dict, arguments: argparse.Namespace, profiles: dict): # ... handle getting credentials return { 'AccessKeyId': 'AKIA...', 'SecretAccessKey': 'SECRET', 'SessionToken': 'LONGSECRET', 'Region': 'us-east-2', } ``` -------------------------------- ### Pre-Collect AWS Profiles Hook in Python Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/collect-aws-profiles.md The `pre_collect_aws_profiles` hook allows custom actions to be executed before the AWS profiles are collected. It receives configuration, argument parser, and file paths as input. This function is useful for any setup or validation steps required prior to profile collection. ```python import argparse from awsume.awsumepy import hookimpl, safe_print @hookimpl def pre_collect_aws_profiles(config: dict, arguments: argparse.Namespace, credentials_file: str, config_file: str): safe_print('Before collecting aws profiles') ``` -------------------------------- ### Get Boto3 Session with Awsume Python Function Source: https://github.com/trek10inc/awsume/blob/master/docs/advanced/non-interactive-awsume.md Obtain a boto3 session for a given AWS profile using the `awsume` Python function. This function delegates to the main awsume driver, leveraging its caching and plugin system. It accepts a profile name, positional arguments (command-line flags), and keyword arguments (long command-line flags). ```python from awsume.awsumepy import awsume session = awsume('profile', '-r', region='us-west-2', mfa_token='123123') # The `session` is a boto3.Session object client = session.client('sts') result = client.get_caller_identity() ``` -------------------------------- ### CLI Entry Point Configuration (setup.py) Source: https://github.com/trek10inc/awsume/blob/master/docs/developer/awsume.md Defines the main entry point for the awsumepy command-line interface, mapping it to the main function within the awsume.awsumepy.main module. ```python entry_points={ 'console_scripts': [ 'awsumepy=awsume.awsumepy.main:main', ``` -------------------------------- ### Configure AWSume Settings and Custom Files Source: https://context7.com/trek10inc/awsume/llms.txt Provides commands for using custom configuration/credentials files and managing global AWSume settings like role duration and region. ```bash awsume dev --credentials-file /path/to/custom/credentials awsume dev --config-file /path/to/custom/config awsume --config set role-duration 43200 awsume --config set region us-west-2 ``` -------------------------------- ### Assume AWS Roles via CLI Source: https://context7.com/trek10inc/awsume/llms.txt Demonstrates how to assume AWS roles using shorthand syntax, source profiles, and external IDs for cross-account trust. ```bash awsume --role-arn aws:123456789012:MyRole awsume --role-arn arn:aws:iam::123456789012:role/MyRole --source-profile dev awsume --role-arn arn:aws:iam::123456789012:role/MyRole --external-id abc123 ``` -------------------------------- ### Configure AWSume Shell Integration Source: https://context7.com/trek10inc/awsume/llms.txt Utility commands to manually configure AWSume's shell integration, including setting up autocomplete and alias files for Bash and Zsh. ```bash # Configure for bash awsume-configure --shell bash \ --autocomplete-file ~/.bash_profile \ --alias-file ~/.bash_profile # Configure for zsh awsume-configure --shell zsh \ --autocomplete-file ~/.zshrc \ --alias-file ~/.zshrc ``` -------------------------------- ### Manage Output Profiles and Session Policies Source: https://context7.com/trek10inc/awsume/llms.txt Shows how to persist assumed credentials to named profiles and restrict session permissions using inline policies or managed policy ARNs. ```bash awsume dev --output-profile dev-session awsume prod-admin --auto-refresh --output-profile prod-session awsume --clean awsume prod-admin --session-policy '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:GetObject","Resource":"arn:aws:s3:::my-bucket/*"}]}' awsume prod-admin --session-policy-arns arn:aws:iam::aws:policy/ReadOnlyAccess ``` -------------------------------- ### Awsume CLI Help and Options Source: https://github.com/trek10inc/awsume/blob/master/docs/general/usage.md Displays the help message and a comprehensive list of available options for the Awsume CLI. This includes arguments for managing credentials, profiles, and refresh behavior. ```bash usage: awsume [-h] [-v] [-r] [-s] [-u] [-a] [-k] [-o] [-l [more]] [--refresh-autocomplete] [--role-arn role_arn] [--source-profile source_profile] [--external-id external_id] [--mfa-token mfa_token] [--region region] [--session-name session_name] [--session-policy session_policy] [--session-policy-arns session_policy_arns [session_policy_arns...]] [--role-duration role_duration] [--with-saml | --with-web-identity] [--credentials-file credentials_file] [--config-file config_file] [--config [option [option ...]]] [--info] [--debug] profile_name Awsume - A cli that makes using AWS IAM credentials easy positional arguments: profile_name The target profile name optional arguments: -h, --help show this help message and exit -v, --version Display the current version of awsume -r, --refresh Force refresh credentials -s, --show-commands Show the commands to set the credentials -u, --unset Unset your aws environment variables -o, --output-profile output_profile A profile to output credentials to -a, --auto-refresh Auto refresh credentials -k, --kill-refresher Kill autoawsume -l [more], --list-profiles [more] List profiles, "more" for detail (slow) --role-arn role_arn Role ARN to assume --source-profile source_profile source_profile to use (role-arn only) --external-id external_id External ID to pass to the assume_role --mfa-token mfa_token Your mfa token --region region The region you want to awsume into --session-name session_name Set a custom role session name --session-policy session_policy Custom session policy JSON --session-policy-arns [arns ...] List of policy ARNs --role-duration role_duration Seconds to get role creds for --with-saml Use saml (requires plugin) --with-web-identity Use web identity (requires plugin) --credentials-file credentials_file Target a shared credentials file --config-file config_file Target a config file --config [option [option ...]] Configure awsume --list-plugins List installed plugins --info Print any info logs to stderr --debug Print any debug logs to stderr ``` -------------------------------- ### AWSume Debugging and Logging Commands Source: https://context7.com/trek10inc/awsume/llms.txt Commands to enable and control debug output for AWSume, helping to troubleshoot issues. Includes options for different log levels and redirecting output to a file. ```bash # Show info-level logs awsume dev --info # Show debug-level logs (verbose) awsume dev --debug # Redirect debug output to a file awsume dev --debug 2> awsume-debug.log # List installed plugins awsume --list-plugins # Display version awsume --version ``` -------------------------------- ### Awsume Package Structure Source: https://github.com/trek10inc/awsume/blob/master/docs/developer/awsume.md Illustrates the directory structure of the awsume Python package, highlighting key modules like __init__.py, __data__.py, awsumepy, autoawsume, and configure. ```python awsume # root package ├─ __init__.py ├─ __data__.py # contains package information, helpful for quickly deriving the version, package name, etc ├─ awsumepy # the core awsume package ├─ autoawsume # the package for any autoawsume logic └─ configure # A peripheral package to help set up shell login files with the alias and autocomplete definitions ``` -------------------------------- ### Develop AWSume Plugins Source: https://context7.com/trek10inc/awsume/llms.txt Extends AWSume functionality by creating plugins that add custom CLI arguments or provide custom profile sources using hook implementations. ```python import argparse from awsume.awsumepy import hookimpl, safe_print @hookimpl def add_arguments(parser: argparse.ArgumentParser): parser.add_argument('--my-custom-flag', action='store_true', help='Enable my custom feature') @hookimpl def post_add_arguments(config: dict, arguments: argparse.Namespace, parser: argparse.ArgumentParser): if arguments.my_custom_flag: safe_print('Custom feature enabled!') ``` -------------------------------- ### Awsume Python Function Signature and Usage Source: https://github.com/trek10inc/awsume/blob/master/docs/advanced/non-interactive-awsume.md Demonstrates the signature of the `awsume` Python function and how to use keyword arguments for command-line flags. Keyword arguments are converted to their `--flag-name` equivalents. Boolean keyword arguments act as on/off switches. ```python def awsume(profile_name: str = None, *args: list, **kwargs: dict) -> boto3.Session: pass # Example: Using keyword argument for MFA token awsume('profile', mfa_token='123123') # Example: Using boolean keyword argument for refresh flag awsume('profile', refresh=True) ``` -------------------------------- ### Configure Shell Alias for AWSume Source: https://context7.com/trek10inc/awsume/llms.txt Manual configuration of shell aliases for AWSume in Bash, Zsh, and Fish shells. This allows invoking AWSume commands directly from the terminal. ```bash # Bash (~/.bash_profile or ~/.bashrc) alias awsume=". awsume" # For pyenv users alias awsume=". $(pyenv which awsume)" # Zsh (~/.zshrc) alias awsume=". awsume" # Fish (~/.config/fish/config.fish) # Fish uses the awsume.fish script automatically # Verify alias is working which awsume type awsume ``` -------------------------------- ### Provide Custom Credentials with Python Source: https://context7.com/trek10inc/awsume/llms.txt A Python plugin hook to fetch AWS credentials from custom sources, such as HashiCorp Vault or a custom API. It can also provide SAML assertions for authentication. ```python # my_credentials_plugin/__init__.py import argparse from datetime import datetime, timedelta from awsume.awsumepy import hookimpl @hookimpl def get_credentials(config: dict, arguments: argparse.Namespace, profiles: dict) -> dict: """Provide credentials from a custom source.""" # Only handle specific profiles if arguments.target_profile_name != 'my-custom-profile': return None # Let other plugins handle it # Fetch credentials from your custom source # (e.g., HashiCorp Vault, custom API, etc.) credentials = fetch_from_vault(arguments.target_profile_name) return { 'AccessKeyId': credentials['access_key'], 'SecretAccessKey': credentials['secret_key'], 'SessionToken': credentials['session_token'], 'Region': 'us-east-1', 'Expiration': datetime.now() + timedelta(hours=1), } @hookimpl def get_credentials_with_saml(config: dict, arguments: argparse.Namespace) -> str: """Provide SAML assertion for SAML-based authentication.""" # Authenticate with your SAML IdP and return the assertion saml_assertion = authenticate_with_okta( username=config.get('saml_username'), password=get_password_securely() ) return saml_assertion # Base64-encoded SAML assertion def fetch_from_vault(profile_name): # Placeholder for vault integration pass def authenticate_with_okta(username, password): # Placeholder for SAML authentication pass def get_password_securely(): # Placeholder for secure password retrieval pass ``` -------------------------------- ### Programmatic AWSume Usage with Python Source: https://context7.com/trek10inc/awsume/llms.txt Utilize the AWSume Python API to obtain boto3 sessions, interact with AWS services, and apply session options programmatically. ```python from awsume.awsumepy import awsume session = awsume('dev') sts_client = session.client('sts') identity = sts_client.get_caller_identity() print(f"Account: {identity['Account']}, User: {identity['Arn']}") session = awsume('prod-admin', '--refresh', region='us-west-2', mfa_token='123456') ``` -------------------------------- ### Pre-Get Credentials Hook (Python) Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/get-credentials.md The `pre_get_credentials` hook is executed before the main credential retrieval process begins. It receives configuration, arguments, and profile information, allowing for pre-processing actions. This hook does not return any value. ```python import argparse from awsume.awsumepy import hookimpl, safe_print @hookimpl def pre_get_credentials(config: dict, arguments: argparse.Namespace, credentials_file: str, config_file: str): safe_print('Before collecting aws profiles') ``` -------------------------------- ### Handle Awsume Exit Behavior with Flags like -l Source: https://github.com/trek10inc/awsume/blob/master/docs/advanced/non-interactive-awsume.md Illustrates how certain awsume flags, like '-l' (list profiles), can cause the script to exit prematurely. When such a flag is used, awsume performs its intended action (e.g., listing profiles) and exits, preventing subsequent code like client creation from executing. ```python from awsume.awsumepy import awsume session = awsume('profile', '-l') # The script will likely exit here if '-l' causes awsume to terminate client = session.client('sts') result = client.get_caller_identity() print(result) ``` -------------------------------- ### Collect Custom AWS Profiles with Python Source: https://context7.com/trek10inc/awsume/llms.txt Implements a Python hook to collect AWS profiles from external sources like secrets managers or databases. It returns a dictionary of profile configurations. ```python import argparse from awsume.awsumepy import hookimpl @hookimpl def collect_aws_profiles(config: dict, arguments: argparse.Namespace, credentials_file: str, config_file: str) -> dict: """Provide custom profiles from external sources.""" # Example: fetch profiles from a secrets manager or database return { 'dynamic-dev': { 'aws_access_key_id': 'AKIAIOSFODNN7EXAMPLE', 'aws_secret_access_key': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', 'region': 'us-east-1', }, 'dynamic-prod': { 'role_arn': 'arn:aws:iam::123456789012:role/ProdRole', 'source_profile': 'dynamic-dev', 'mfa_serial': 'arn:aws:iam::123456789012:mfa/user', }, } @hookimpl def post_collect_aws_profiles(config: dict, arguments: argparse.Namespace, profiles: dict): """Process profiles after collection.""" # Log or modify collected profiles print(f'Total profiles available: {len(profiles)}') ``` -------------------------------- ### Execute logic before adding arguments using pre_add_arguments hook Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/add-arguments.md The pre_add_arguments hook is triggered before the argument parser is populated. It receives the current awsume configuration dictionary. ```python import argparse from awsume.awsumepy import hookimpl, safe_print @hookimpl def pre_add_arguments(config: dict): safe_print('Before adding arguments') ``` -------------------------------- ### Execute logic after adding arguments using post_add_arguments hook Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/add-arguments.md The post_add_arguments hook runs after the argument parser has been populated. It provides access to the configuration, the parsed arguments namespace, and the parser object itself. ```python import argparse from awsume.awsumepy import hookimpl, safe_print @hookimpl def post_add_arguments(config: dict, arguments: argparse.Namespace, parser: argparse.ArgumentParser): if arguments.test: safe_print('Custom flag was triggered') ``` -------------------------------- ### Post-Get Credentials Hook (Python) Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/get-credentials.md The `post_get_credentials` hook runs after AWS credentials have been successfully retrieved. It receives configuration, arguments, profiles, and the obtained credentials, enabling post-processing or logging. This hook does not return any value. ```python import argparse from awsume.awsumepy import hookimpl, safe_print @hookimpl def post_get_credentials(config: dict, arguments: argparse.Namespace, profiles: dict, credentials: dict): safe_print('After collecting aws profiles') ``` -------------------------------- ### Add custom arguments to awsume using add_arguments hook Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/add-arguments.md The add_arguments hook allows plugins to register custom command-line arguments. It is recommended to wrap parser additions in a try/except block to handle potential conflicts with other plugins. ```python import argparse from awsume.awsumepy import hookimpl @hookimpl def add_arguments(parser: argparse.ArgumentParser): try: parser.add_argument('--test') except argparse.ArgumentError: # handle argument already taken here pass ``` -------------------------------- ### Catch User Authentication Error - Python Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/catch-exceptions.md Handles `UserAuthenticationError` that occurs when fetching a user's session token fails. The function receives configuration, arguments, profiles, and the error, and prints an error message. ```python import argparse from awsume.awsumepy import hookimpl, safe_print @hookimpl def catch_user_authentication_error(config: dict, arguments: argparse.Namespace, profiles: dict, error: Exception): safe_print('Uh oh, a profile was not found') ``` -------------------------------- ### Catch Invalid Profile Exception - Python Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/catch-exceptions.md Handles `InvalidProfileError` when an AWS profile is found but is incorrectly configured (e.g., missing secret key). It accepts configuration, arguments, profiles, and the error, and logs a notification. ```python import argparse from awsume.awsumepy import hookimpl, safe_print @hookimpl def catch_invalid_profile_exception(config: dict, arguments: argparse.Namespace, profiles: dict, error: Exception): safe_print('Uh oh, a profile was not found') ``` -------------------------------- ### Catch Profile Not Found Exception - Python Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/catch-exceptions.md Handles `ProfileNotFoundError` when a specified AWS profile cannot be located in the configuration sources. It takes configuration, arguments, profiles, and the error as input, and prints a user-friendly message. ```python import argparse from awsume.awsumepy import hookimpl, safe_print @hookimpl def catch_profile_not_found_exception(config: dict, arguments: argparse.Namespace, profiles: dict, error: Exception): safe_print('Uh oh, a profile was not found') ``` -------------------------------- ### Catch Role Authentication Error - Python Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/catch-exceptions.md Handles `RoleAuthenticationError` raised when assuming an AWS role fails. This handler accepts configuration, arguments, profiles, and the error, and outputs a notification message. ```python import argparse from awsume.awsumepy import hookimpl, safe_print @hookimpl def catch_role_authentication_error(config: dict, arguments: argparse.Namespace, profiles: dict, error: Exception): safe_print('Uh oh, a profile was not found') ``` -------------------------------- ### Post-Collect AWS Profiles Hook in Python Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/collect-aws-profiles.md The `post_collect_aws_profiles` hook enables custom logic to run after AWS profiles have been collected. It receives the configuration, arguments, and the collected profiles dictionary. This hook is ideal for processing, validating, or reporting on the collected profiles. ```python import argparse from awsume.awsumepy import hookimpl, safe_print @hookimpl def post_collect_aws_profiles(config: dict, arguments: argparse.Namespace, profiles: dict): safe_print('After collecting aws profiles') ``` -------------------------------- ### Collect AWS Profiles Function in Python Source: https://github.com/trek10inc/awsume/blob/master/docs/plugin-development/collect-aws-profiles.md The `collect_aws_profiles` function is responsible for gathering AWS profiles. It takes configuration and argument parser objects, along with paths to credentials and config files, and returns a dictionary representing the collected profiles. The format of the returned dictionary is a mapping of profile names to their respective key-value pairs, as defined by AWS configuration standards. ```python import argparse from awsume.awsumepy import hookimpl @hookimpl def collect_aws_profiles(config: dict, arguments: argparse.Namespace, credentials_file: str, config_file: str): return { 'profile1': { 'aws_access_key_id': 'AKIA...', 'aws_secret_access_key': 'SECRET', 'region': 'us-west-2', }, 'profile2': { 'aws_access_key_id': 'AKIA...', 'aws_secret_access_key': 'SECRET', 'mfa_serial': 'arn:aws:iam::123123123123:mfa/user', }, 'profile3': { 'role_arn': 'AKIA...', 'mfa_serial': 'arn:aws:iam::123123123123:mfa/user', 'source_profile': 'profile2', }, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.