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

5

10

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?

Merline answered 13/12, 2019 at 8:15 Comment(0)
E
6

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"
    ]
  }
]
Exorbitance answered 25/3, 2020 at 10:49 Comment(1)
Any reference to create RDS dataset for quicksight using boto3 ?Carrick
H
1

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.

Hilleary answered 16/12, 2019 at 13:38 Comment(2)
Thanks a lot. For my use case, creating a dashboard with an already created template will work. But I'm running into an issue when I call the create_dashboard function in boto3. When I run the function with permissions (Principal and Actions), I get the following error: botocore.errorfactory.InvalidParameterValueException: An error occurred (InvalidParameterValueException) when calling the CreateDashboard operation: Given action combination: [quicksight:DescribeDashboard] is invalid. Any ideas on how to fix this? No combination of actions seems to be working.Merline
@Merline I'm using the node SDK so forgive differences, but here are the permissions I'm assigning, you may want to swap group for user and use a user ID rather than a group, I don't know your exact use case: gist.github.com/mjgpy3/b72487a9e261bf9405bff36ac7d9fe79Hilleary
H
0

There are multiple ways you can find analysis id associated. Use any of the following.

  1. A dashboard url has dashboard id included, Use this ID to execute API call describe-dashboard and you would see analysis ARN in the source entity.

  2. Click on "save as" option on the dashboard and it would take you to the associated analysis. [ One might not see this option if a dashboard is created from a template ]

  3. A dashboard ID can also be found by using list_dashboards API call. Print all the dashboard ID and name. You can match the ID with the given dashboard name.Look at the whole list because a dashboard id is unique but the dashboard name is not. One can have multiple dashboards with the same name.

Hin answered 29/3, 2020 at 23:38 Comment(0)
U
0

Yes you can create lambda and trigger using cron Job

import boto3

      quicksight = boto3.client('quicksight')
     response = quicksight.create_ingestion(AwsAccountId=XXXXXXX, 
       DataSetId=YYYY,IngestionId=ZZZZ)
Umbilical answered 28/6, 2022 at 0:23 Comment(0)
S
-1

I've been playing with this as well and ran into the same issue. Make sure that your permissions are set up properly for the data source and the data set by referencing the quicksight user as follows:

arn:aws:quicksight:{region}:xxxxxxxxxx:user/default/{user}

I would include all the quicksight permissions found in the docs to start with and shave down from there. If nothing else, create the data source/set from the console, and then use the describe-* CLI call to see what they use.

It's kind of wonky.

Stricture answered 13/12, 2019 at 18:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.