# Collect AWS Profiles
Collect AWS Profiles
# collect_aws_profiles
# Parameters
config- adictof awsume's configurationparser- anargparse.ArgumentParserobjectcredentials_file- the path to the aws shared credentials file to be usedconfig_file- the path to the aws config file to be used
# Returns
- A
dictof profiles in the following format:
{
'profile_name': {
'profile_key': 'profile_value',
},
}
Review the official documentation (opens new window) for the various acceptable profile_keys.
# Example
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',
},
}
# pre_collect_aws_profiles
# Parameters
config- adictof awsume's configurationparser- anargparse.ArgumentParserobjectcredentials_file- the path to the aws shared credentials file to be usedconfig_file- the path to the aws config file to be used
# Returns
- Nothing
# Example
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')
# post_collect_aws_profiles
# Parameters
config- adictof awsume's configurationarguments- anargparse.Namespaceobject containing awsume's argumentsprofiles- the collected aws profiles
# Returns
- Nothing
# Example
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')