I am creating analysis using below code using boto3 python. I have created template using existing analysis and that template is being used to create another analysis, but just changing the dataset which has same schema.
# Create the new analysis based on the template
response = quicksight.create_analysis(
AwsAccountId=account_id,
AnalysisId=analysis_name.replace(' ', '-') + '_new',
Name=analysis_name + '_new',
SourceEntity={
'SourceTemplate': {
'Arn': template_arn,
'DataSetReferences': data_set_references
}
},
Permissions={["quicksight:UpdateAnalysisPermissions",
"quicksight:DeleteAnalysis",
"quicksight:DescribeAnalysisPermissions",
"quicksight:QueryAnalysis",
"quicksight:DescribeAnalysis",
"quicksight:CreateAnalysis"]}
)
I am also getting response as CREATION_SUCCESSFUL.
Response:
{
'ResponseMetadata': {
'RequestId': '50f0f62b-36a3-4287-923f-c717ca540671',
'HTTPStatusCode': 200,
'HTTPHeaders': {
'date': 'Thu, 30 Mar 2023 15:27:41 GMT',
'content-type': 'application/json',
'content-length': '1353',
'connection': 'keep-alive',
'x-amzn-requestid': '50f0f62b-36a3-4287-923f-c717ca540671'
},
'RetryAttempts': 0
},
'Status': 200,
'Analysis': {
'AnalysisId': 'tec_dspByCreative-analysis_new',
'Arn': 'arn:aws:quicksight:us-east-1:{account-id}:analysis/tec_dspByCreative-analysis_new',
'Name': 'tec_dspByCreative analysis_new',
'Status': 'CREATION_SUCCESSFUL',
'DataSetArns': ['arn:aws:quicksight:us-east-1:{account-id}:dataset/tec_dspByCreative', 'arn:aws:quicksight:us-east-1:{account-id}:dataset/tec_dspByProduct'],
'CreatedTime': datetime.datetime(2023, 3, 30, 20, 55, 32, 233000, tzinfo = tzlocal()),
'LastUpdatedTime': datetime.datetime(2023, 3, 30, 20, 55, 32, 804000, tzinfo = tzlocal()),
'Sheets': [{
'SheetId': '055a5755-66b0-48de-8dae-09d55f471626',
'Name': 'Sheet 1'
}, {
'SheetId': '75786a78-35eb-4bfb-83c2-346e7ca25cce',
'Name': 'Sheet 2'
}]
},
'RequestId': '50f0f62b-36a3-4287-923f-c717ca540671'
}
But the analysis is not showing in AWS console. I am not able to figure out what might be the problem here.
When I am calling describe_analysis, its showing arn and status as creation_successful.
Above is the permission issue. It is creating the Analysis in AWS Console which you can check in Manage Quicksight -> Manage Assets tab.
When you are creating analysis, Principal should be attached to it so that once the resource is created in AWS, it will be shared to that principal.
Since I didn't add any principal information, the resource is getting created because CLI credentials have permission to create resources.
Proper permissions are as follows:
Permissions=[{
'Principal': f'arn:aws:quicksight:{region}:{account_id}:user/default/{username}',
'Actions': ['quicksight:RestoreAnalysis',
'quicksight:UpdateAnalysisPermissions',
'quicksight:DeleteAnalysis',
'quicksight:QueryAnalysis',
'quicksight:DescribeAnalysisPermissions',
'quicksight:DescribeAnalysis',
'quicksight:UpdateAnalysis']
}]
)