in cid/helpers/account_map.py [0:0]
def select_metadata_collection_method(self) -> str:
""" Selects the method to collect metadata """
logger.info('Metadata source selection')
# Ask user which method to use to retreive account list
selection = list()
account_map_sources = {
'csv': 'CSV file (relative path required)',
'organization': 'AWS Organizations (one time account listing)',
'dummy': 'Dummy (CUR account data, no names)'
}
for k,v in account_map_sources.items():
selection.append(
questionary.Choice(title=f'{v}', value=k)
)
selected_source=questionary.select(
"Please select account metadata collection method",
choices=selection
).ask()
if selected_source in account_map_sources.keys():
logger.info(f'Selected {selected_source}')
self._metadata_source = selected_source
# Collect account list from different sources of user choice
if self._metadata_source == 'csv':
finished = False
while not finished:
mapping_file = click.prompt("Enter file path", type=str)
finished = self.check_file_exists(mapping_file)
if not finished:
click.echo('File not found, ', nl=False)
click.echo('\nCollecting account info...', nl=False)
self._accounts = self.get_csv_accounts(mapping_file)
logger.info(f'Found {len(self._accounts)} accounts')
click.echo(f' {len(self.accounts)} collected')
elif self._metadata_source == 'organization':
click.echo('\nCollecting account info...', nl=False)
self._accounts = self.get_organization_accounts()
logger.info(f'Found {len(self._accounts)} accounts')
click.echo(f' {len(self.accounts)} collected')
elif self._metadata_source == 'dummy':
click.echo('Notice: Dummy account mapping will be created')
else:
print('Unsupported selection')
return False