Automate deployment of an Amazon QuickSight analysis connecting to an Amazon Redshift data warehouse with an AWS CloudFormation template
What matters here for platform teams is the shift from manual BI setup to repeatable infrastructure-as-code for analytics assets. Packaging the QuickSight data source, dataset, template, and analysis into CloudFormation gives architects a way to promote a reporting stack across environments with the same deployment discipline used for application infrastructure. That reduces configuration drift, but it also means the analytics definition becomes subject to the same change control, code review, and release management process as any other workload.
The architecture has a few dependencies that need to be treated explicitly. The source and target accounts must both support QuickSight enterprise access, the Redshift connection must exist in the destination environment, and the template must reference ARNs and permissions that are valid in each account. In practice, this introduces a clear separation between design-time assets in the source account and runtime data access in the target account, which is useful for multi-account governance but easy to break if identity, Region, or cluster details are not aligned.
There is also a meaningful trade-off in the dataset layer. The example uses direct query, which keeps data current and avoids SPICE refresh planning, but it shifts more dependency onto Redshift availability, query tuning, and warehouse capacity. Teams standardizing this pattern should think about whether template portability is enough, or whether they also need consistent performance behavior across environments when the underlying warehouse size or workload mix changes.
Operationally, the most valuable aspect is that the analysis becomes deployable and versionable rather than disposable. That makes rollback, reproducibility, and promotion between dev and prod more predictable, especially for teams that need to manage multiple dashboards or segregated tenant environments. It also creates a maintainable path for integrating BI deployment into CI/CD without relying on console recreation.
Solution overview
Our solution consists of the following steps:- Create a QuickSight analysis using an Amazon Redshift data source.
- Create a QuickSight template for your analysis.
- Create a CloudFormation template for your analysis using theย AWS Command Line Interfaceย (AWS CLI).
- Use the generated CloudFormation template to deploy a QuickSight analysis to a target environment.
Prerequisites
Before setting up the CloudFormation stacks, you must have an AWS account and anย AWS Identity and Access Managementย (IAM) user with sufficient permissions to interact with theย AWS Management Consoleย and the services listed in the architecture. The migration requires the following prerequisites:- A QuickSight enterprise account in the source and target accounts. For instructions, seeย Setting up for Amazon QuickSight.
- A connection between QuickSight and the Amazon Redshift instance. For instructions, refer toย Authorizing connections from Amazon QuickSight to Amazon Redshift clusters.
- An Amazon Redshift cluster with sample data loaded. For instructions, seeย Using a sample dataset.
- You can useย AWS Cloud9ย orย AWS CloudShellย from the console to run AWS CLI commands.
Create a QuickSight analysis in your dev environment
In this section, we walk through the steps to set up your QuickSight analysis using an Amazon Redshift data source.Create an Amazon Redshift data source
To connect to your Amazon Redshift data warehouse, you need to create a data source in QuickSight. As shown in the following screenshot, you have two options:- Auto-discovered
- Manual connect
Create an Amazon Redshift dataset
The next step is to create a QuickSight dataset, which identifies the specific data in a data source you want to use. For this post, we use the TICKIT database created in an Amazon Redshift data warehouse, which consists of seven tables: two fact tables and five dimensions, as shown in the following figure.
- On theย Datasetsย page, chooseย New dataset.
- Choose the data source you created in the previous step.
- Chooseย Use custom SQL.
- Enter the custom SQL as shown in the following screenshot.
|
|
Create a QuickSight analysis
The next step is to create an analysis that utilizes this dataset. In QuickSight, you analyze and visualize your data in analyses. When youโre finished, you can publish your analysis as a dashboard to share with others in your organization.- On theย All analysesย tab of the QuickSight start page, chooseย New analysis.
- Choose a dataset, then chooseย Use in analysis.
- Create a visual. For more information about creating visuals, seeย Adding visuals to Amazon QuickSight analyses.
Create a QuickSight template from your analysis
A QuickSight template is a named object in your AWS account that contains the definition of your analysis and references to the datasets used. You can create a template using the QuickSight API by providing the details of the source analysis via a parameter file. You can use templates to easily create a new analysis. You can use AWS Cloud9 from the console to run AWS CLI commands.
aws quicksight create-template --aws-account-id <DEVACCOUNT>--template-id QS-RS-SalesAnalysis-Template --cli-input-json file://parameters.json
parameter.jsonย file contains the following details (provide your source QuickSight user ARN, analysis ARN, and dataset ARN):
{
"Name": "QS-RS-SalesAnalysis-Temp",
"Permissions": [
{"Principal": "<QS-USER-ARN>",
"Actions": [ "quicksight:CreateTemplate",
"quicksight:DescribeTemplate",
"quicksight:DescribeTemplatePermissions",
"quicksight:UpdateTemplate"
] } ] ,
"SourceEntity": {
"SourceAnalysis": {
"Arn": "<QS-ANALYSIS-ARN>",
"DataSetReferences": [
{
"DataSetPlaceholder": "sales",
"DataSetArn": "<QS-DATASET-ARN>"
}
]
}
},
"VersionDescription": "1"
}
parameter.jsonย file to AWS Cloud9, chooseย Fileย from the tool bar and chooseย Upload local file.
describe-templateย command:
aws quicksight describe-template --aws-account-id <DEVACCOUNT> --template-id "QS-RS-SalesAnalysis-Temp"
aws quicksight update-template-permissions --aws-account-id <DEVACCOUNT> --template-id โQS-RS-SalesAnalysis-Tempโ --grant-permissions file://TemplatePermission.json
TemplatePermission.jsonย contains the following details (provide your target AWS account ID):
[
{
"Principal": "arn:aws:iam::<TARGET ACCOUNT>",
"Actions": [
"quicksight:UpdateTemplatePermissions",
"quicksight:DescribeTemplate"
]
}
]
TemplatePermission.jsonย file to AWS Cloud9, choose theย Fileย menu from the tool bar and chooseย Upload local file.
Create a CloudFormation template
In this section, we create a CloudFormation template containing our QuickSight assets. In this example, we use a YAML formatted template saved on our local machine. We update the following different sections of the template:- AWS::QuickSight::DataSource
- AWS::QuickSight::DataSet
- AWS::QuickSight::Template
- AWS::QuickSight::Analysis
describeย AWS CLI commands, and some information needs to be updated for the target account.
Create an Amazon Redshift data source in AWS CloudFormation
In this step, we add theย AWS::QuickSight::DataSourceย section of the CloudFormation template. Gather the following information on the Amazon Redshift cluster in the target AWS account (production environment):- VPC connection ARN
- Host
- Port
- Database
- User
- Password
- Cluster ID
DataSourceID. This ID is unique per Region for each AWS account.
Add the following information to the template:
Resources:
RedshiftBuildQSDataSource:
Type: 'AWS::QuickSight::DataSource'
Properties:
DataSourceId: "RS-Sales-DW"
AwsAccountId: !Sub ${AWS::ACCOUNT ID}
VpcConnectionProperties:
VpcConnectionArn: <VPC-CONNECTION-ARN>
Type: REDSHIFT
DataSourceParameters:
RedshiftParameters:
Host: "<HOST>"
Port: <PORT>
Clusterid: "<CLUSTER ID>"
Database: "<DATABASE>"
Name: "RS-Sales-DW"
Credentials:
CredentialPair:
Username: <USER>
Password: <PASSWORD>
Permissions:
Create an Amazon Redshift dataset in AWS CloudFormation
In this step, we add theย AWS::QuickSight::DataSetย section in the CloudFormation template to match the dataset definition from the source account. Gather the dataset details and run theยlist-data-setsย command to get all datasets from the source account (provide your source dev account ID):
aws quicksight list-data-sets --aws-account-id <DEVACCOUNT>
describe-data-setย command, specifying the dataset ID from the previous commandโs response:
aws quicksight describe-data-set --aws-account-id <DEVACCOUNT> --data-set-id "<YOUR-DATASET-ID>"
AWS::Quicksight::DataSetย resource in the CloudFormation template, as shown in the following code. Note that you can also create a customย DataSetID. This ID is unique per Region for each AWS account.
QSRSBuildQSDataSet:
Type: 'AWS::QuickSight::DataSet'
Properties:
DataSetId: "RS-Sales-DW"
Name: "sales"
AwsAccountId: !Sub ${AWS::ACCOUNT ID}
PhysicalTableMap:
PhysicalTable1:
CustomSql:
SqlQuery: "select sellerid, username, (firstname ||' '|| lastname) as name,city, sum(qtysold) as sales
from sales, date, users
where sales.sellerid = users.userid and sales.dateid = date.dateid and year = 2008
group by sellerid, username, name, city
order by 5 desc
limit 10"
DataSourceArn: !GetAtt RedshiftBuildQSDataSource.Arn
Name"RS-Sales-DW"
Columns:
- Type: INTEGER
Name: sellerid
- Type: STRING
Name: username
- Type: STRING
Name: name
- Type: STRING
Name: city
- Type: DECIMAL
Name: sales
LogicalTableMap:
LogicalTable1:
Alias: sales
Source:
PhysicalTableId: PhysicalTable1
DataTransforms:
- CastColumnTypeOperation:
ColumnName: sales
NewColumnType: DECIMAL
Permissions:
- Principal: !Join
- ''
- - 'arn:aws:quicksight:'
- !Ref QuickSightIdentityRegion
- ':'
- !Ref 'AWS::AccountId'
- ':user/default/'
- !Ref QuickSightUser
Actions:
- 'quicksight:UpdateDataSetPermissions'
- 'quicksight:DescribeDataSet'
- 'quicksight:DescribeDataSetPermissions'
- 'quicksight:PassDataSet'
- 'quicksight:DescribeIngestion'
- 'quicksight:ListIngestions'
- 'quicksight:UpdateDataSet'
- 'quicksight:DeleteDataSet'
- 'quicksight:CreateIngestion'
- 'quicksight:CancelIngestion'
ImportMode: DIRECT_QUERY
ImportModeย to choose betweenย Direct_Queryย orย Spice.
Create a QuickSight template in AWS CloudFormation
In this step, we add theย AWS::QuickSight::Templateย section in the CloudFormation template, representing the analysis template. Use the source template ARN you created earlier and add theยAWS::Quicksight::Templateย resource in the CloudFormation template:
QSTCFBuildQSTemplate:
Type: 'AWS::QuickSight::Template'
Properties:
TemplateId: "QS-RS-SalesAnalysis-Temp"
Name: "QS-RS-SalesAnalysis-Temp"
AwsAccountId:!Sub ${AWS::ACCOUNT ID}
SourceEntity:
SourceTemplate:
Arn: '<SOURCE-TEMPLATE-ARN>'
Permissions:
- Principal: !Join
- ''
- - 'arn:aws:quicksight:'
- !Ref QuickSightIdentityRegion
- ':'
- !Ref 'AWS::AccountId'
- ':user/default/'
- !Ref QuickSightUser
Actions:
- 'quicksight:DescribeTemplate'
VersionDescription: Initial version - Copied over from AWS account.
Create a QuickSight analysis
In this last step, we add theย AWS::QuickSight::Analysisย section in the CloudFormation template. The analysis is linked to the template created in the target account. Add theยAWS::Quicksight::Analysisย resource in the CloudFormation template as shown in the following code:
QSRSBuildQSAnalysis:
Type: 'AWS::QuickSight::Analysis'
Properties:
AnalysisId: 'Sales-Analysis'
Name: 'Sales-Analysis'
AwsAccountId:!Sub ${AWS::ACCOUNT ID}
SourceEntity:
SourceTemplate:
Arn: !GetAtt QSTCFBuildQSTemplate.Arn
DataSetReferences:
- DataSetPlaceholder: 'sales'
DataSetArn: !GetAtt QSRSBuildQSDataSet.Arn
Permissions:
- Principal: !Join
- ''
- - 'arn:aws:quicksight:'
- !Ref QuickSightIdentityRegion
- ':'
- !Ref 'AWS::AccountId'
- ':user/default/'
- !Ref QuickSightUser
Actions:
- 'quicksight:RestoreAnalysis'
- 'quicksight:UpdateAnalysisPermissions'
- 'quicksight:DeleteAnalysis'
- 'quicksight:DescribeAnalysisPermissions'
- 'quicksight:QueryAnalysis'
- 'quicksight:DescribeAnalysis'
- 'quicksight:UpdateAnalysis'
Deploy the CloudFormation template in the production account
To create a new CloudFormation stack that uses the preceding template via the AWS CloudFormation console, complete the following steps:- On the AWS CloudFormation console, chooseย Create Stack.
- On the drop-down menu, chooseย with new resources (standard).
- Forย Prepare template, selectย Template is ready.
- Forย Specify template, chooseย Upload a template file.
- Save the provided CloudFormation template in a .yaml file and upload it.
- Chooseย Next.
- Enter a name for the stack. For this post, we useย
QS-RS-CF-Stack. - Chooseย Next.
- Chooseย Nextย again.
- Chooseย Create Stack.
CREATE_IN_PROGRESS, then toย CREATE_COMPLETE.
| QuickSight Object Type | Object Name (Dev) | Object Name ( Prod) |
| Data Source | RS-Sales-DW | RS-Sales-DW |
| Dataset | Sales | Sales |
| Template | QS-RS-Sales-Temp | QS-RS-SalesAnalysis-Temp |
| Analysis | Sales Analysis | Sales-Analysis |
Sales Analysisย was created in the target account.
Conclusion
This post demonstrated an approach to migrate a QuickSight analysis with an Amazon Redshift data source from one QuickSight account to another with a CloudFormation template. For more information about automating dashboard deployment, customizing access to the QuickSight console, configuring for team collaboration, and implementing multi-tenancy and client user segregation, check out the videosย Virtual Admin Workshop: Working with Amazon QuickSight APIsย andย Admin Level-Up Virtual Workshop, V2ย on YouTube.About the author
Sandeep Bajwa is a Sr. Analytics Specialist based out of Northern Virginia, specialized in the design and implementation of analytics and data lake solutions.Enjoyed this article? Sign up for our newsletter to receive regular insights and stay connected.


