Skip to content

Commit

Permalink
use region alias along with region_name (#870)
Browse files Browse the repository at this point in the history
* use region alias along with region_name

* better use of paramters
  • Loading branch information
iakov-aws authored Jul 5, 2024
1 parent 06075d1 commit 5709a4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions cid/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ def wrapper(ctx, **kwargs):
if len(ctx.args) % 2 != 0:
print(f"Unknown extra argument, or an option without value {ctx.args}")
exit(-1)
params = {}
for i in range(0, len(ctx.args), 2):
kwargs[ctx.args[i][2:].replace('-', '_')] = ctx.args[i+1]
key = ctx.args[i][2:].replace('-', '_')
params[key] = ctx.args[i+1]
set_parameters(params, all_yes=ctx.obj.all_yes)

set_parameters(kwargs, all_yes=ctx.obj.all_yes)
res = None
try:
res = func(ctx, **kwargs)
Expand Down Expand Up @@ -59,7 +61,7 @@ def wrapper(ctx, **kwargs):

@click.group()
@click.option('--profile_name', '--profile', help='AWS Profile name to use', default=None)
@click.option('--region_name', help="AWS Region (default:'us-east-1')", default=None)
@click.option('--region_name', help="AWS Region", default=None)
@click.option('--aws_access_key_id', help='', default=None)
@click.option('--aws_secret_access_key', help='', default=None)
@click.option('--aws_session_token', help='', default=None)
Expand All @@ -75,7 +77,6 @@ def main(ctx, **kwargs):

ctx.obj = Cid(**kwargs)


@click.option('-v', '--verbose', count=True)
@click.option('-y', '--yes', help='confirm all', is_flag=True, default=False)
@cid_command
Expand Down
9 changes: 6 additions & 3 deletions cid/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def __init__(self, **kwargs) -> None:
self.qs_url = 'https://{region}.quicksight.{domain}/sn/dashboards/{dashboard_id}'
self.all_yes = kwargs.get('yes')
self.verbose = kwargs.get('verbose')
set_parameters(kwargs, self.all_yes)
# save main parameters to global parameters but do not override parameters that were set from outside
set_parameters({key: val for key, val in kwargs.items() if key.replace('_', '-') not in get_parameters()}, self.all_yes)
self._logger = None
self.catalog_urls = [
'https://raw.githubusercontent.com/aws-samples/aws-cudos-framework-deployment/main/dashboards/catalog.yaml',
Expand All @@ -60,9 +61,11 @@ def aws_login(self):
'aws_session_token': None
}
for key in params.keys():
value = get_parameters().get(key.replace('_', '-'))
if value != None:
value = get_parameters().get(key.replace('_', '-'), '<NO VALUE>')
if value != '<NO VALUE>':
params[key] = value
if get_parameters().get('region'):
params['region_name'] = get_parameters().get('region') # use region as a synonym of region_name

print('Checking AWS environment...')
try:
Expand Down

0 comments on commit 5709a4f

Please sign in to comment.