Content Porting

QuickSight assets can be ported across regions and accounts using APIs. In following exercises, we will use QuickSight APIs to create duplicates of a data source, data set, theme, analyses and dashboard.

Exercise 1 - Create data source copy

  1. Optional - In Cloud9, pull up the help for create-data-source. Synopsis section shows the mandatory and optional input components needed by the API.
aws quicksight create-data-source help
  1. Optional - Execute following describe-data-source command to see what parameters are used for S3 data source.
aws quicksight describe-data-source --aws-account-id $AAI --data-source-id QSTCF-DataSource
  1. Optional - Execute following describe-data-source-permissions command to get the permissions applied on the data source.
aws quicksight describe-data-source-permissions --aws-account-id $AAI --data-source-id QSTCF-DataSource
  1. Execute following create-data-source command to create a copy of the data source passing in the data source parameters and permissions parsed out from the above describe responses. jq is used to parse out the required sections, sed suppresses spaces and tr is used to get rid of new line characters to get the content in the format we need. This is much simpler when you are doing this via a programming language like Python or Java.
aws quicksight create-data-source --aws-account-id $AAI --name QSTCF-DataSource-V2 --data-source-id QSTCF-DataSource-V2 --data-source-parameters `aws quicksight describe-data-source --aws-account-id $AAI --data-source-id QSTCF-DataSource|jq '.DataSource.DataSourceParameters'|sed 's/ //g'|tr -d '\n'` --type S3 --permissions `aws quicksight describe-data-source-permissions --aws-account-id $AAI --data-source-id QSTCF-DataSource|jq '.Permissions'|sed 's/ //g'|tr -d '\n'`
  1. In QuickSight tab, open Datasets view and click on New dataset button.
  2. Scroll down to Existing data sources section. You should now see QSTCF-DataSource-V2.
  3. Click on QuickSight icon to exit data sources view.
AdminWorkshop-ContentPorting-Exercise

Exercise 2 - Create dataset copy

  1. Optional - Pull up help for create-data-set and check synopsis to see the mandatory and optional components.
aws quicksight create-data-set help
  1. Optional - Execute describe-data-set command to see the full definition of QSTCF-DataSet. Note that the PhysicalTableMap and LogicalTableMap sections can be picked up from here.
aws quicksight describe-data-set --aws-account-id $AAI --data-set-id QSTCF-DataSet
  1. Optional - Execute describe-data-set-permissions command to see current permissions on the dataset.
aws quicksight describe-data-set-permissions --aws-account-id $AAI --data-set-id QSTCF-DataSet
  1. Execute following command to take the required components from above two commands and create a JSON file that can be used as input to create-data-set command. When doing this via SDK, there is no need to create an input JSON file. We are doing this in CLI route just to keep things more structured. Optional - You can check the contents of the create-data-set.json file by double clicking it from left panel.
echo ['{"AwsAccountId":"'$AAI'"}', `aws quicksight describe-data-set --aws-account-id $AAI --data-set-id QSTCF-DataSet`, `aws quicksight describe-data-set-permissions --aws-account-id $AAI --data-set-id QSTCF-DataSet` ] |jq '{"AwsAccountId":.[0].AwsAccountId,"DataSetId":(.[1].DataSet.DataSetId + "-V2"),"Name":(.[1].DataSet.Name + "-V2"),"PhysicalTableMap":.[1].DataSet.PhysicalTableMap,"LogicalTableMap":.[1].DataSet.LogicalTableMap,"ImportMode":.[1].DataSet.ImportMode,"Permissions":.[2].Permissions}|.PhysicalTableMap.s3PhysicalTable.S3Source.DataSourceArn=(.PhysicalTableMap.s3PhysicalTable.S3Source.DataSourceArn+"-V2")'>~/environment/create-data-set.json
  1. Execute following create-data-set command to create the duplicate dataset
aws quicksight create-data-set --cli-input-json file://~/environment/create-data-set.json
  1. In QuickSight tab, open/refresh Datasets view.
  2. You should now see QSTCF-DataSet-V2.
AdminWorkshop-ContentPorting-Exercise

Exercise 3 - Create theme copy

  1. Optional - Pull up help for create-theme and check synopsis to see the mandatory and optional components.
aws quicksight create-theme help
  1. Optional - Execute describe-theme command to see the full definition of QSTCF-Theme. Note that the BaseThemeId and Configuration can be picked up from here.
aws quicksight describe-theme --aws-account-id $AAI --theme-id QSTCF-Theme
  1. Optional - Execute describe-theme-permissions command to see current permissions on the theme.
aws quicksight describe-theme-permissions --aws-account-id $AAI --theme-id QSTCF-Theme
  1. Execute following command to take the required components from above two commands and create a JSON file that can be used as input to create-theme command.
echo ['{"AwsAccountId":"'$AAI'"}', `aws quicksight describe-theme --aws-account-id $AAI --theme-id QSTCF-Theme`, `aws quicksight describe-theme-permissions --aws-account-id $AAI --theme-id QSTCF-Theme` ] |jq '{"AwsAccountId":.[0].AwsAccountId,"ThemeId":(.[1].Theme.ThemeId + "-V2"),"Name":(.[1].Theme.Name + "-V2"),"BaseThemeId":.[1].Theme.Version.BaseThemeId,"Configuration":.[1].Theme.Version.Configuration,"Permissions":.[2].Permissions}'>~/environment/create-theme.json
  1. Execute following create-theme command to create the duplicate theme.
aws quicksight create-theme --cli-input-json file://~/environment/create-theme.json
AdminWorkshop-ContentPorting-Exercise

Exercise 4 - Create template

  1. Optional - Pull up help for create-template and check synopsis to see the mandatory and optional components.
aws quicksight create-template help
  1. Optional - Execute describe-analysis command to see the full definition of QSTCF-Analysis. Note that the arn of dataset/s used in the analysis can be picked up from here.
aws quicksight describe-analysis --aws-account-id $AAI --analysis-id QSTCF-Analysis
  1. Execute following command to pull required details from describe-analysis and create a JSON file that can be used as input to create-template command.
echo ['{"AwsAccountId":"'$AAI'"}', `aws quicksight describe-analysis --aws-account-id $AAI --analysis-id QSTCF-Analysis`]|jq '{"AwsAccountId":.[0].AwsAccountId,"TemplateId":"QSTCF-Template-V2","Name":"QSTCF-Template-V2","SourceEntity":{"SourceAnalysis":{"Arn":.[1].Analysis.Arn,"DataSetReferences":[{"DataSetPlaceholder":"DS1","DataSetArn":.[1].Analysis.DataSetArns[0]}]}}}'>~/environment/create-template.json
  1. Execute following create-template command to take a point in time snap shot of QSTCF-Analysis. We are not adding a permissions section for this template as we are going to use this template within the scope of the current account only. If we want to use the template to create dashboard in another account, quicksight:DescribeTemplate permission has to be given to root of target account or to * (making it a public template).
aws quicksight create-template --cli-input-json file://~/environment/create-template.json
  1. Optional - Try describing the template since we can’t see it in the UI.
aws quicksight describe-template --aws-account-id $AAI --template-id QSTCF-Template-V2
AdminWorkshop-ContentPorting-Exercise

Exercise 5 - Create dashboard from the template
We can create dashboards directly from a template. It is to make this crystal clear that we are creating the dashboard ahead of creating an analysis from the template. While creating the dashboard, we can plug in a new dataset that has the same schema as used in original analysis.

  1. Optional - Pull up help for create-dashboard and check synopsis to see the mandatory and optional components.
aws quicksight create-dashboard help
  1. Optional - Execute describe-dashboard command to see dashboard’s metadata. Note that you can pick up the current dataset arn and theme arn from this response.
aws quicksight describe-dashboard --aws-account-id $AAI --dashboard-id QSTCF-Dashboard
  1. Optional - Execute describe-dashboard-permissions command to see the current perrmissions on QSTCF-Dashboard.
aws quicksight describe-dashboard-permissions --aws-account-id $AAI --dashboard-id QSTCF-Dashboard
  1. Execute following command to create JSON file that can be used as input to create-dashboard command.
echo ['{"AwsAccountId":"'$AAI'"}', `aws quicksight describe-template --aws-account-id $AAI --template-id QSTCF-Template-V2`, `aws quicksight describe-dashboard --aws-account-id $AAI --dashboard-id QSTCF-Dashboard`, `aws quicksight describe-dashboard-permissions --aws-account-id $AAI --dashboard-id QSTCF-Dashboard`]|jq '{"AwsAccountId":.[0].AwsAccountId,"DashboardId":(.[2].Dashboard.DashboardId+"-V2"),"Name":(.[2].Dashboard.Name+"-V2"),"SourceEntity":{"SourceTemplate":{"Arn":.[1].Template.Arn,"DataSetReferences":[{"DataSetPlaceholder":"DS1","DataSetArn":(.[2].Dashboard.Version.DataSetArns[0]+"-V2")}]}},"ThemeArn":(.[2].Dashboard.Version.ThemeArn+"-V2"),"Permissions":.[3].Permissions,"DashboardPublishOptions":{"AdHocFilteringOption":{"AvailabilityStatus":"DISABLED"}}}'>~/environment/create-dashboard.json
  1. Execute following create-dashboard command to create a new dashboard from the point in time snapshot of QSTCF-Analysis that was captured in template. This version is plugged into QSTCF-DataSet-V2 and uses QSTCF-Theme-V2.
 aws quicksight create-dashboard --cli-input-json file://~/environment/create-dashboard.json
  1. In QuickSight tab, open Dashboards view and click on new dashboard QSTCF-Dashboard-V2 to launch it.
  2. Click on QuickSight icon to exit from the dashboard.
AdminWorkshop-ContentPorting-Exercise

Exercise 6 - Optional - Create analysis from the template
We can create an analysis as well from the template. This is very similar to how we created the dashboard in last exercise.

  1. Optional - Pull up help for create-analysis and check synopsis to see the mandatory and optional components.
aws quicksight create-analysis help
  1. Optional - Execute describe-analysis command to see dashboard’s metadata. Note that you can pick up the current dataset arn and theme arn from this response.
aws quicksight describe-analysis --aws-account-id $AAI --analysis-id QSTCF-Analysis
  1. Optional - Execute describe-analysis-permissions command to see the current perrmissions on QSTCF-Dashboard.
aws quicksight describe-analysis-permissions --aws-account-id $AAI --analysis-id QSTCF-Analysis
  1. Execute following command to create JSON file that can be used as input to create-analysis command.
echo ['{"AwsAccountId":"'$AAI'"}', `aws quicksight describe-template --aws-account-id $AAI --template-id QSTCF-Template-V2`, `aws quicksight describe-analysis --aws-account-id $AAI --analysis-id QSTCF-Analysis`, `aws quicksight describe-analysis-permissions --aws-account-id $AAI --analysis-id QSTCF-Analysis`]|jq '{"AwsAccountId":.[0].AwsAccountId,"AnalysisId":(.[2].Analysis.AnalysisId+"-V2"),"Name":(.[2].Analysis.Name+"-V2"),"SourceEntity":{"SourceTemplate":{"Arn":.[1].Template.Arn,"DataSetReferences":[{"DataSetPlaceholder":"DS1","DataSetArn":(.[2].Analysis.DataSetArns[0]+"-V2")}]}},"ThemeArn":(.[2].Analysis.ThemeArn+"-V2"),"Permissions":.[3].Permissions}'>~/environment/create-analysis.json
  1. Execute following create-analysis command to create a new analysis from the point in time snapshot of QSTCF-Analysis that was captured in template.. This version is plugged into QSTCF-DataSet-V2 and uses QSTCF-Theme-V2.
aws quicksight create-analysis --cli-input-json file://~/environment/create-analysis.json
  1. In QuickSight tab, open/refresh Analyses view and click on new analysis QSTCF-Analysis-V2 to launch it.
  2. Note that this analysis is using V2 instances of dataset and theme.
  3. Click QuickSight icon to exit from the analysis.
AdminWorkshop-ContentPorting-Exercise