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.