From 60111c29ace43a814e5a4839ea80d5eae5b5fe53 Mon Sep 17 00:00:00 2001 From: Daniel Bernstein Date: Mon, 25 Sep 2023 16:07:42 -0700 Subject: [PATCH] Use standard approach to passing aws profiles to boto3. --- core/cli.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/core/cli.py b/core/cli.py index 0216c77..114c081 100644 --- a/core/cli.py +++ b/core/cli.py @@ -19,8 +19,8 @@ log = logging.getLogger("core.cli") -def create_quicksight_client(aws_profile: str): - boto3.setup_default_session(profile_name=aws_profile) +def create_quicksight_client(): + boto3.setup_default_session() return boto3.client("quicksight") @@ -30,7 +30,6 @@ def cli(): @click.command() -@click.option("--aws-profile", required=True, help="The AWS account profile") @click.option("--aws-account-id", required=True, help="The ID of the AWS account") @click.option( "--analysis-id", required=True, help="The ID of the Analysis to be exported" @@ -40,19 +39,16 @@ def cli(): required=True, help="The path to the output directory to which resources will be exported", ) -def export_analysis( - aws_profile: str, aws_account_id: str, analysis_id: str, output_dir: str -): +def export_analysis(aws_account_id: str, analysis_id: str, output_dir: str): """ Exports a template and dependent data sets based on the specified analysis to JSON files. """ log.info(f"Create version") - log.info(f"aws_profile = {aws_profile}") log.info(f"analysis_id= {analysis_id}") log.info(f"aws_account_id={aws_account_id}") log.info(f"output_dir={output_dir}") result = ExportAnalysisOperation( - qs_client=create_quicksight_client(aws_profile=aws_profile), + qs_client=create_quicksight_client(), aws_account_id=aws_account_id, analysis_id=analysis_id, output_dir=output_dir, @@ -64,7 +60,6 @@ def export_analysis( @click.command -@click.option("--aws-profile", required=True, help="The AWS account profile") @click.option("--aws-account-id", required=True, help="The ID of the AWS account") @click.option( "--template-name", required=True, help="The name of the template to be restored" @@ -85,7 +80,6 @@ def export_analysis( help="The path to the input directory from which resources will be imported", ) def import_template( - aws_profile: str, aws_account_id: str, template_name: str, data_source_arn: str, @@ -97,14 +91,13 @@ def import_template( """ log.info(f"import_from_json") - log.info(f"aws_profile = {aws_profile}") log.info(f"aws_account_id = {aws_account_id}") log.info(f"template_name = {template_name}") log.info(f"data_source_arn = {data_source_arn}") log.info(f"input_dir= {input_dir}") result = ImportFromJsonOperation( - qs_client=create_quicksight_client(aws_profile), + qs_client=create_quicksight_client(), aws_account_id=aws_account_id, template_name=template_name, target_namespace=target_namespace, @@ -118,7 +111,6 @@ def import_template( @click.command -@click.option("--aws-profile", required=True, help="The AWS account profile") @click.option("--aws-account-id", required=True, help="The ID of the AWS account") @click.option( "--template-id", required=True, help="The ID of the template to be restored" @@ -130,7 +122,6 @@ def import_template( ) @click.option("--group-name", required=True, help="Name of the Quicksight User Group") def publish_dashboard( - aws_profile: str, aws_account_id: str, template_id: str, target_namespace: str, @@ -141,12 +132,11 @@ def publish_dashboard( """ log.info(f"publish dashboard from template") - log.info(f"aws_profile = {aws_profile}") log.info(f"aws_account_id = {aws_account_id}") log.info(f"template_id = {template_id}") log.info(f"group_name = {group_name}") result = PublishDashboardFromTemplateOperation( - qs_client=create_quicksight_client(aws_profile), + qs_client=create_quicksight_client(), aws_account_id=aws_account_id, template_id=template_id, target_namespace=target_namespace,