Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to create Quicksight analysis purely through code (boto3)?

What I currently have in my Quicksight account is a Data Source (Redshift), some datasets (some Redshift views) and an analysis (graphs and charts that use the datasets). I can view all of these on the AWS Quicksight Console. But when I use boto3 to create a data source and datasets, nothing shows up on the console. They do however show up when I use the list_data_sources and list_data_sets calls.

After this, I need to create all the graphs by code that I created manually. I can't currently find an option to do this through code. There is a 'create_template' api call which is supposed to create a template through an existing Quicksight analysis. But it requires the ARN of the analysis which I can't find.

Any suggestions on what to do?

like image 698
ashirhs Avatar asked Dec 13 '19 08:12

ashirhs


People also ask

What programming language is used in QuickSight?

One or more programming languages, such as JavaScript, Java, Python, or C#.

Can QuickSight be automated?

Processes such as this provide quality, consistency, auditability, and accountability for the code being released. The QuickSight API provides functionality for automation pipelines.

Can you use Python in QuickSight?

You can analyze data using python and create an output dataset for import in Quicksight. This opens up a wide range of possibilities for highly flexible text visualizations!

How do I make a QuickSight data set?

To create a dataset, choose New data set on the Datasets page. You can then create a dataset based on an existing dataset or data source, or connect to a new data source and base the dataset on that. To use the Amazon Web Services Documentation, Javascript must be enabled.


2 Answers

Note: this only answers why the data sets/sources do not appear in the console. As for the other question, I assume mjgpy3 was of some help.

Summary

Add the permissions at the bottom of this post to your data set and data source in order for them to appear in the console. Make sure to fill in the principal arn with your details.

Details

In order for data sets and data sources to appear in the console when created via the API, you must ensure that the correct permissions have been added to them. Without adding the correct permissions, it is true that the CLI lists them whereas the console does not.

If you have created data sets/sources via the console, you can use the CLI (aws quicksight describe-data-set-permissions and aws quicksight describe-data-source-permissions) to view what permissions AWS gives them so that your account can interact with them.

I've tested this and these are what AWS assigns them as of 25/03/2020.

Data Set permissions:

"permissions": [
  {
    "Principal": "arn:aws:quicksight:<region>:<aws_account_id>:user/default/{IAM user name}",
    "Actions": [
      "quicksight:UpdateDataSetPermissions",
      "quicksight:DescribeDataSet",
      "quicksight:DescribeDataSetPermissions",
      "quicksight:PassDataSet",
      "quicksight:DescribeIngestion",
      "quicksight:ListIngestions",
      "quicksight:UpdateDataSet",
      "quicksight:DeleteDataSet",
      "quicksight:CreateIngestion",
      "quicksight:CancelIngestion"
    ]
  }
]

Data Source permissions:

"permissions": [
  {
    "Principal": "arn:aws:quicksight:<region>:<aws_account_id>:user/default/{IAM user name}",
    "Actions": [
      "quicksight:UpdateDataSourcePermissions",
      "quicksight:DescribeDataSource",
      "quicksight:DescribeDataSourcePermissions",
      "quicksight:PassDataSource",
      "quicksight:UpdateDataSource",
      "quicksight:DeleteDataSource"
    ]
  }
]
like image 135
M4C4R Avatar answered Sep 20 '22 11:09

M4C4R


It sounds like your smaller question is regarding the ARN of the analysis.

The format of analysis ARNs is

arn:aws:quicksight:$AWS_REGION:$AWS_ACCOUNT_ID:analysis/$ANALYSIS_ID

Where

  • $AWS_REGION is replaced with the region in which the analysis lives
  • $AWS_ACCOUNT_ID is replaced with your AWS account ID
  • $ANALYSIS_ID is replaced with the analysis ID

If you're looking for the $ANALYSIS_ID it's the GUID-looking thing on the end of the URL for the analysis in the QuickSight URL

So, if you were on an analysis at the URL

https://quicksight.aws.amazon.com/sn/analyses/018ef6393-2c71-4842-9798-1aa2f0902804

the analysis ID would be 018ef6393-2c71-4842-9798-1aa2f0902804 (this is a fake ID I injected for this example).

Your larger question seems to be whether you can use the create_template API to duplicate your analysis. The answer at this moment (12/16/19) is, unfortunately, no.

You can use the create_dashboard API to publish a Dashboard from a template made with create_template but you can't create an Analysis from a template.

I'm answering this bit just to clarify since you may actually be okay with creating a dashboard (basically the published version of an analysis) rather than another analysis.

like image 45
mjgpy3 Avatar answered Sep 21 '22 11:09

mjgpy3