How to update-template ? I'm getting "Resource creation can only be done from one SourceEntity or Definition" error

When I try to update the template in the command line,

account_a_id=‘xxx’
aws quicksight update-template --aws-account-id $account_a_id --template-id ‘template_as_’ --cli-input-json file://template_.json

I get the following error :

An error occurred (InvalidParameterValueException) when calling the UpdateTemplate operation: Resource creation can only be done from one SourceEntity or Definition

template_.json file :

{
“Definition”: {
“DataSetConfigurations”: [
{
“Placeholder”: “xxxx”,
“DataSetSchema”: {
“ColumnSchemaList”: [,
]
},
“ColumnGroupSchemaList”:
}
],
“Sheets”: [
{
“SheetId”: “xx-4553-x-bf4d-670b10e5fe75”,
“Name”: “tab1”
},
{
“SheetId”: “xx-c50f-x-b4f3-1f57914994bd”,
“Name”: “tab2”
},
{
“SheetId”: “xx-a0be-x-9121-7e13c279d4ab”,
“Name”: “tab3”
},
{
“SheetId”: “xx-4474-x-bda0-c2f3bdacbd61”,
“Name”: “tab4”
}
]
},
“SourceEntity”: {
“SourceAnalysis”: {
“Arn”: “arn:aws:quicksight:us-east-1:xxx:analysis/xxx”,
“DataSetReferences”: [
{
“DataSetPlaceholder”: “xx”,
“DataSetArn”: “arn:aws:quicksight:us-east-1:xx:dataset/xxx”
}
]
}
},
“VersionDescription”: “1”
}

I can’t figure out what the problem is here.

Hi @tbdori ,

As the error states “Resource creation can only be done from one SourceEntity or Definition”

If you are updating an existing template, then use the SourceEntity . Remove the Definition.

{
“AwsAccountId”: “”,
“TemplateId”: “”,
“SourceEntity”: {
“SourceAnalysis”: {
“Arn”: “”,
“DataSetReferences”: [
{
“DataSetPlaceholder”: “”,
“DataSetArn”: “”
}
]
},
“SourceTemplate”: {
“Arn”: “”
}
},
“VersionDescription”: “”,
“Name”: “”
}

Kind regards,
Koushik

2 Likes

@Koushik_Muthanna But, what if I need to remove 2 sheets out of 6 sheets. Then, I need to change Definition > Sheets section , correct?

Or, is there another way to do such ?

My scenario :
[DEV account]
initial development - Analysis 6 sheet, Dashboard 6 sheet
updated (replace the existing dashboard) - Analysis 6 sheet, Dashboard 4 sheet

[STG account]
initial migration - Analysis 6 sheet, Dashboard 6 sheet
updated - ?? how to do ??


So, I have a dashboard template that has 6 sheets.
Now, I want to remove 2 sheets so it becomes 4 sheets in STG account

How do I do this?
I noticed that update-template actually overwrites the existing definition(4 sheets) as soon as I update it with the SourceEntity section. Same for the vice-versa case.

Hi @tbdori ,

If the requirement is to have only 4 sheets in your dashboard in the [STG account] , then you would have to work with template definition.
1/Extract the json definition ( describe-template-definition — AWS CLI 1.27.152 Command Reference )
2/Modify the json definition to remove the 2 sheets
3/Update the dashboard by using the new definition ( update-dashboard — AWS CLI 1.27.152 Command Reference )

Kind regards,
Koushik

1 Like

Hi, Koushik

As you suggested , I did the following but it seems that JSON output is not legit. What am I missing?

  1. ran this to get JSON output of template definition
    aws quicksight describe-template-definition --aws-account-id $account_a_id --template-id $template_id --version-number=$version_no --output json

  2. I deleted 2 sheets from this.

  3. tried updating dashboard

aws quicksight update-dashboard --aws-account-id $account_a_id --dashboard-id $dashboard_id --name $name_ --cli-input-json file://./spend_template_def_stg.json

  1. results : failure

Parameter validation failed:
Unknown parameter in input: “Status”, must be one of: AwsAccountId, DashboardId, Name, SourceEntity, Parameters, VersionDescription, DashboardPublishOptions, ThemeArn, Definition
Unknown parameter in input: “TemplateId”, must be one of: AwsAccountId, DashboardId, Name, SourceEntity, Parameters, VersionDescription, DashboardPublishOptions, ThemeArn, Definition
Unknown parameter in input: “ResourceStatus”, must be one of: AwsAccountId, DashboardId, Name, SourceEntity, Parameters, VersionDescription, DashboardPublishOptions, ThemeArn, Definition
Unknown parameter in input: “RequestId”, must be one of: AwsAccountId, DashboardId, Name, SourceEntity, Parameters, VersionDescription, DashboardPublishOptions, ThemeArn, Definition
Missing required parameter in Definition: “DataSetIdentifierDeclarations”
Unknown parameter in Definition: “DataSetConfigurations”, must be one of: DataSetIdentifierDeclarations, Sheets, CalculatedFields, ParameterDeclarations, FilterGroups, ColumnConfigurations, AnalysisDefaults

Hi @tbdori ,

Looking at the error itself, your json file has fields which are not required as input parameters .
Output the required json format for update dashboard using the CLI

aws quicksight update-dashboard --generate-cli-skeleton > ./Downloads/upddash.json

Update the json file with the details in those required values and use that file to update the dashboard

1 Like

So, a little more detailed info on this is for future reference :

  1. get the DS template definition in JSON
  2. edit JSON based on skeleton
  • remove sheets not needed from Sheets array
  • leave Definition block only
  • replace DataSetConfigurations with DataSetIdentifierDeclarations
  1. run update-dashboard

My update command still fails as the sheetId is used in many filters like 32 places.
Thus, it seems that I need to delete all those references and doing this in JSON seems to be very error prone.

An error occurred (InvalidParameterValueException) when calling the UpdateDashboard operation: SheetId present in FilterGroup is not found in the list of Sheets,
at Filter Group xxx-e321-4676-a5b5-402f9b8e6f82,
at Sheet xxx-0eb4-450e-9958-092dfb4fa433.

Is there any other easy way to do ?

@tbdori ,

The other easier way to do this which I can think of
1 : [ UI Based ] Make a copy of analysis in DEV account and delete the unwanted sheets. It would have only those 4 sheets which are required.
2 : [API Based ] Create your template based on this new analysis in DEV
3 : [API Based ] recreate relevant analysis and dashboard in STG account using the template from DEV

1 Like