diff --git a/cid/cli.py b/cid/cli.py index 5cfb52d7..af4811f1 100644 --- a/cid/cli.py +++ b/cid/cli.py @@ -245,7 +245,7 @@ def init_qs(ctx, **kwargs): @click.option('-v', '--verbose', count=True) @cid_command -def init_cur(ctx, **kwargs): +def create_cur_table(ctx, **kwargs): """Initialize CUR table \b @@ -253,7 +253,7 @@ def init_cur(ctx, **kwargs): --crawler-role ROLE Name or ARN of crawler role """ - ctx.obj.init_cur(**kwargs) + ctx.obj.create_cur_table(**kwargs) @click.option('-v', '--verbose', count=True) @click.option('-y', '--yes', help='confirm all', is_flag=True, default=False) diff --git a/cid/common.py b/cid/common.py index 8fac4bec..0d12b037 100644 --- a/cid/common.py +++ b/cid/common.py @@ -1663,9 +1663,9 @@ def create_or_update_crawler(self, crawler_name, location): crawler_role = get_parameter( 'crawler-role', message='Provide a crawler role name', - choices=glue_trusted_roles + [''] + choices=glue_trusted_roles + ['CidCmdCurCrawlerRole '] ) - if crawler_role == '': + if 'CREATE NEW' in crawler_role: crawler_role = 'CidCmdCurCrawlerRole' self.iam.ensure_role_for_crawler( s3bucket=location.split('/')[2], @@ -1760,7 +1760,7 @@ def init_qs(self, **kwargs): return InitQsCommand(cid=self, **kwargs).execute() @command - def init_cur(self, **kwargs): + def create_cur_table(self, **kwargs): """ Initialize CUR """ if get_parameters().get('view-cur-location'): s3path = get_parameters().get('view-cur-location') diff --git a/cid/helpers/iam.py b/cid/helpers/iam.py index a63d290c..735e8e6d 100644 --- a/cid/helpers/iam.py +++ b/cid/helpers/iam.py @@ -8,7 +8,9 @@ import boto3 from tqdm import tqdm +from cid.exceptions import CidCritical from cid.base import CidBase +from cid.utils import get_parameter logger = logging.getLogger(__name__) @@ -242,6 +244,10 @@ def ensure_role_with_policy(self, role_name, assume_role_policy_document, permis logger.info(f"No need to update '{policy_name}' the doc is the same as requested.") else: logger.debug(f'Updating policy {policy_arn} to {result_document}') + print(f'Updating policy {policy_arn} to :\n{json.dumps(result_document, indent=2)}') + if get_parameter(f'confirm-policy-{policy_name}', message='Please confirm', choices=['yes', 'no']) != 'yes': + raise CidCritical('User choose not to confirm challenge') + # A managed policy can have up to 5 versions. # Before you create a new version, you must delete at least one existing version. versions = self.client.list_policy_versions(PolicyArn=policy_arn)['Versions'] diff --git a/cid/helpers/quicksight/__init__.py b/cid/helpers/quicksight/__init__.py index 14f08970..544b8f65 100644 --- a/cid/helpers/quicksight/__init__.py +++ b/cid/helpers/quicksight/__init__.py @@ -453,7 +453,7 @@ def create_data_source(self, athena_workgroup, datasource_id: str=None, role_arn create_status = self.client.create_data_source(**params) logger.debug(f'Data source creation result {create_status}') # Wait for the datasource completion - while True: + for _ in tqdm(range(60), desc='DataSet Creation', leave=False): time.sleep(1) datasource = self.describe_data_source(datasource_id, update=True) logger.debug(f'Waiting for datasource {datasource_id}. current status={datasource.status}')