How to override dashboard, dataset's elements when using start_asset_bundle_import_job

I’m promoting QS dashboard from Account A to Account B.
I did it successfully without using the ‘asset as bundle’ function but now I’d like to try that out.
Upon exporting the dashboard and its dependencies ( theme, analysis, dataset,datasource) , I know I need to override some parameters esp. Arns.

[type or paste code here](https://docs.aws.amazon.com/cli/latest/reference/quicksight/start-asset-bundle-import-job.html)

But, the API doc shows only datasource has some detail parameters. For example, I am able to override manifest file location for s3 datasource.

Now, for Dashboard, it looks like I need to update themeArn, datasetArns. see below example.
However above Api doc doesn’t show I can override those as it only support id and name for overriding.

{"resourceType":"dashboard","dashboardId":"xx-ed2f-4805-b560-5c7e62be569e",
 "name":"ds_xx_dev",
 "themeArn":"arn:aws:quicksight:us-east-1:xx:theme/xxx-4c36-817f-042b0c15a390",
 "definition":{
     "dataSetIdentifierDeclarations":[
         {
             "identifier":"xx-snapshot-s3",
             "dataSetArn":"arn:aws:quicksight:us-east-1:xxx:dataset/xx7-44b1-bb59-f11ef9742e1f"
         },
         {
             "identifier":"xx-trend-s3",
             "dataSetArn":"arn:aws:quicksight:us-east-1:xx:dataset/xx-21d1-4b51-b36a-fe77a91a345b"
         }
     ],

The same concern goes to Dataset.
I need to override dataSourceArn as it currently has sourceAccountId. I need to replace it with targetAccountId. But, I don’t know how I can do this.

 "resourceType":"dataset",
 "dataSetId":"d0d7757f-21d1-4b51-b36a-fe77a91a345b",
 "name":"xx-trend-s3",
 "physicalTableMap":{
     "xx-f963-4b4f-b965-cfadc7ed1bf8":{
         "s3Source":{"dataSourceArn":"arn:aws:quicksight:us-east-1:xx:datasource/xxx-ce82-496a-9642-8bf2d1fecf02",
                     "uploadSettings":{
                         "format":"CSV","startFromRow":1,"containsHeader":true,"textQualifier":"DOUBLE_QUOTE","delimiter":","
                     },
                     "inputColumns":[{"name":"MondayDate","type":"STRING"},{"name":"SnapshotDate","type":"STRING"}

Before I was updating these myself but I wonder if these can be done automatically when I use import-job.

any idea?

qls-export-import-api

Basically, when I ran export command, it created .qs file with dashaboard/, dataset/ , datasource/ .
The configuration file under these folders came with accountId fixed based on source side.

I believe I need to update those accountId to target side along with manifest file location as I’m using different s3 file location.

But, I don’t see how to do so since import-api only support name / id change based on the documentation.

Hello @tbdori, luckily my team worked on a similar type of migration recently so I think I can explain the process. So as you discovered, there are a few different places where you will need to change IDs when transitioning from one account to another. What we did was create a data dictionary that mapped all of the IDs from the source account to the IDs that are needed in the destination account, then used a python mapping function to map each item between 2 json files. The mapping function looks like this:

def replaceFunc(x):
    for k, v in map_dict.items():
        x = x.replace(k, v)
    return x

The one thing you need to remember, is you need to convert the json file to a string to complete the mapping, and then convert it back to the original format. To convert the string back to the original format you can use this ast python package, linking documentation here, and use ast.literal_eval()

If that helps resolve your question, please mark my response as a solution. Otherwise feel free to follow up if you still have issues completing this task.

hi @tbdori, it sounds like you are implementing a release pipeline. In order to avoid the id mappings, you can perform an one-time sync between the accounts (using Asset bundle APIs). From that point on, you can use Asset Bundle APIs to deploy from Account A to B. The API will handle the replacement of account IDs and regions.

1 Like