From dbee3bbd27a5009f741bb326ffaa41af1910a7db Mon Sep 17 00:00:00 2001 From: Daniel Bernstein Date: Thu, 30 Nov 2023 12:42:51 -0800 Subject: [PATCH] * Make --output-json optional. * Add optional dashboard_alias parameter to publish command so that we can specify a logical alias in the dashboard info. * Use template-name in the combined import and publish as the dashboard alias. In this way the output can be passed directly into the QUICKSIGHT_AUTHORIZED_ARNS in the CM. --- core/cli.py | 13 +++++++------ core/operation/publish_dashboard_from_template.py | 10 ++++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/core/cli.py b/core/cli.py index 89a7c5f..283febb 100644 --- a/core/cli.py +++ b/core/cli.py @@ -196,11 +196,6 @@ def publish_dashboard( help="The path to the input directory from which resources will be imported", ) @click.option("--group-name", required=True, help="Name of the Quicksight User Group") -@click.option( - "--output-json", - required=False, - help="The file path to which operation output should be written as json", -) @click.option( "--result-bucket", required=False, @@ -211,16 +206,21 @@ def publish_dashboard( required=False, help="An S3 object key to save the results to. If used, result-bucket must be specified.", ) +@click.option( + "--output-json", + required=False, + help="(Optional) The file path to which operation output should be written as json", +) def import_and_publish( aws_account_id: str, template_name: str, data_source_arn: str, target_namespace: str, input_dir: str, - output_json: str, group_name: str, result_bucket: str, result_key: str, + output_json: str = None, ): log.info(f"import_and_publish") @@ -252,6 +252,7 @@ def import_and_publish( qs_client=create_quicksight_client(), s3_client=create_s3_client(), aws_account_id=aws_account_id, + dashboard_alias=template_name, template_id=template_id, target_namespace=target_namespace, group_name=group_name, diff --git a/core/operation/publish_dashboard_from_template.py b/core/operation/publish_dashboard_from_template.py index 79ee6af..7022a86 100644 --- a/core/operation/publish_dashboard_from_template.py +++ b/core/operation/publish_dashboard_from_template.py @@ -14,13 +14,15 @@ def __init__( template_id: str, target_namespace: str, group_name: str, - output_json: str, result_bucket: str, result_key: str, s3_client, + dashboard_alias: str = None, + output_json: str = None, *args, **kwargs, ): + self._dashboard_alias = dashboard_alias self._template_id = template_id self._target_namespace = target_namespace self._group_name = group_name @@ -125,7 +127,11 @@ def execute(self) -> dict: result = { "status": "success", - "dashboard_info": {self._template_id: [dashboard_arn]}, + "dashboard_info": { + self._dashboard_alias + if self._dashboard_alias + else self._template_id: [dashboard_arn] + }, } if self._output_json: