Replace Deleted Datasource in Dataset

In Quicksight I accidentally deleted a datasource that a few datasets were connected to. I have attempted to replace the missing datasource in the dataset via using CLI in AWS CloudShell with an identical one using aws quicksight update-data-set --aws-account-id --data-set-id --cli-input-json file://update-data-source.json. However, i receive the following error:

An error occurred (InvalidParameterValueException) when calling the UpdateDataSet operation: Invalid dataSourceArn: datasource:

How do I avoid this error to update the datasource in the dataset?

Hi @JarrettD

Please create datasource first either through QuickSight UI or through create datasource API .

Once the datasource is created you can get the new ARN of the datasource and use it to update the existing datasets.

Please user describe dataset to get the dataset definition and change the datasource with new ARN and use update dataset API to use the new dataset definition .

Please refer to this article for sample steps on how to use the describe & create dataset API.

Thanks
VInod

Thank you for your response. What you have described and linked to is exactly what i have attempted, and each time I receive an error message that references the deleted datasource ARN.

The new datasource was created in the UI and replacement of the deleted datasource within the dataset was attempted through CLI using
–cli-input-json file://
–cli-input-json
–physical-table-map

They all provide the same result. Which is an error message that references the ARN of the deleted datasource

An error occurred (InvalidParameterValueException) when calling the UpdateDataSet operation: Invalid dataSourceArn: datasource:

Hello @JarrettD and @apjvinod !

@JarrettD were you able to find a resolution to this issue or are you still running into this problem?

My recommendation for this would be to try and workaround the issue and try reuploading the dataset via the data source connection and then replacing the dataset in your analyses with your identical one.

Hi @JarrettD,
Since we have not received a response from you on this question, we are going to archive the question. If you still need this question answered, please create a new question topic.
Thanks,
Andrew

I resolved my issue by uploading a blank dataset with the same id as the deleted dataset. This enabled me to update the datasource of each impacted dataset without receiving an error stating the datasource was deleted. All of this was done in the CLI.

2 Likes

The solution here didn’t quite work for us to restore a deleted data source.

I re-created the data source via the CLI with the same ID and properties as the deleted one, however there was still an error

“The data source or dataset being referenced here is not the same. The resource might have been deleted and created with same id through APIs.”

To make this go away I needed to call update-data-set on every dataset with the same table definitions which presumably resets the internal IDs.

I had a few to to do so this scripts was useful:

#!/bin/bash

set -e

AWS_PROFILE=$1
DATASET_ID=$2

account_id=$(aws sts get-caller-identity \
    --profile $AWS_PROFILE \
    --query Account \
    --output text)

ds_name=$(aws quicksight describe-data-set \
    --profile $AWS_PROFILE \
    --aws-account-id ${account_id} \
    --data-set-id $DATASET_ID \
    --output text \
    --query=DataSet.Name)

echo Fixing up: $ds_name

aws quicksight describe-data-set \
    --profile $AWS_PROFILE \
    --aws-account-id ${account_id} \
    --data-set-id $DATASET_ID \
    --query=DataSet.PhysicalTableMap > "${ds_name}.json"

aws quicksight describe-data-set \
    --profile $AWS_PROFILE \
    --aws-account-id ${account_id} \
    --data-set-id $DATASET_ID \
    --query=DataSet.LogicalTableMap > "${ds_name}.logical.json"

aws quicksight update-data-set \
    --profile $AWS_PROFILE \
    --aws-account-id ${account_id} \
    --data-set-id $DATASET_ID \
    --name "$ds_name" \
    --import-mode SPICE \
    --physical-table-map=file://"${ds_name}.json" \
    --logical-table-map=file://"${ds_name}.logical.json"