Skip to content

Commit

Permalink
* Make --output-json optional.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
dbernstein committed Nov 30, 2023
1 parent c180e33 commit 5a26c18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 7 additions & 6 deletions core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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")
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 8 additions & 2 deletions core/operation/publish_dashboard_from_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 5a26c18

Please sign in to comment.