Trying to create a script to migrate dashboards and data sets from one account to another

Hi there!

I’m working on a script to migrate Dashboards from one account (that will be deactivated in the future) to another. It’s a Python script using boto3 1.26.79

I’m able to create the data sets, but when I try to create the dashboard itself, a lot of errors show up. For example:

An error occurred (InvalidParameterValueException) when calling the CreateDashboard operation: The FieldId of ColorMap element: 2023-01-01 00:00:00.000, in VisualPalette, is not showing in FieldWells,  
         at Field fb43c5b1-271b-4012-81f6-32eac888aaee.period_start.0.1672940249338, 
         at Visual 377f32cc-85d0-4dce-9303-7eb6b1f92f90_930e56f9-1ea7-4495-889c-6bba99f13028, 
         at Sheet 377f32cc-85d0-4dce-9303-7eb6b1f92f90_bb24ab37-1e5e-4954-965e-c22fd5f65465.

It’s odd because if you open the dashboard in the original account, it shows up perfectly - all filters and calculations are working.

Here’s my code: qs_migration.py · GitHub

Any help is appreciated.

Thanks!

To create a dashboard programmatically, you need to create a Template and use it for creating dashboard. We have a video elaborating the work flow and demo. Also included sample code. you may found in below

1 Like

Thank you for answering. But do you know why the docs explicitly say that we can create a dashboard from either a template or directly with a DashboardDefinition? It seems much easier than creating a template…

Except Template, you may also use Describe Dashboard Definition API to get the Dashboard definition in JSON format. But you still need to manipulate the json file before it can be used for the Create Dashboard API

You cannot Create Dashboard by using the output from API Describe Dashboard

That’s what I’m trying to do.

I first DescribeDashboard to create the DataSets in the destination account, then I use DescribeDashboardDefinition to create the dashboard. I manipulate the json by changing the DataSets with the ones I’ve created in the destination account.

@royyung I’m following the tutorial you sent, but right at the beginning I can see that you must first assume a specific role in both accounts.

Can you share details about these roles and how to create them?

Thanks!

In the video(2:52), it was talking about the permission to create data source, you may refer to the IAM policy of QuickSight in here Permissions Reference for AWS IAM | aws.permissions.cloud

If you are using template to deploy cross account, you may also refer to this page which shows the step by step by IAM policy example

1 Like

Hi, @cgarcia-ld . Did Roy’s solution work for you? I am marking his reply as, “Solution,” but let us know if this is not resolved. Thanks for posting your questions on the QuickSight Community Q&A Forum!

1 Like