How to create AWS QuickSight Data Source with AWS CloudFormation

Here is an example CloudFormation template for creating a QuickSight data source with a Redshift input parameter:

AWSTemplateFormatVersion: '2010-09-09'

Parameters: DataSourceId: Type: String RedshiftClusterId: Type: String Database: Type: String ClusterUsername: Type: String ClusterPassword: Type: String CredentialUsername: Type: String CredentialPassword: Type: String Federated: Type: String VpcConnectionArn: Type: String

Resources: MyDataSource: Type: AWS::QuickSight::DataSource Properties: DataSourceId: !Ref DataSourceId Name: MyDataSource Type: REDSHIFT DataSourceParameters: RedshiftClusterId: !Ref RedshiftClusterId Database: !Ref Database ClusterUsername: !Ref ClusterUsername ClusterPassword: !Ref ClusterPassword Credentials: CredentialPair: Username: !Ref CredentialUsername Password: !Ref CredentialPassword Permissions:

  • Principal: Federated: !Ref Federated Actions:

    • "quicksight:DescribeDataSource"
    • "quicksight:DescribeDataSourcePermissions"
    • "quicksight:PassDataSource" VpcConnectionProperties: VpcConnectionArn: !Ref VpcConnectionArn

    Outputs: DataSourceId: Value: !Ref DataSourceId RedshiftClusterId: Value: !Ref RedshiftClusterId Database: Value: !Ref Database ClusterUsername: Value: !Ref ClusterUsername CredentialUsername: Value: !Ref CredentialUsername Federated: Value: !Ref Federated VpcConnectionArn: Value: !Ref VpcConnectionArn

This template defines a resource of type **AWS::QuickSight::DataSource** with the following properties:

  • **DataSourceId**: The ID of the data source. This is a required parameter that you must specify when creating the data source.
  • **Name**: The name of the data source.
  • **Type**: The type of the data source. In this case, we are using a Redshift data source, so the type is set to **REDSHIFT**.
  • **DataSourceParameters**: The parameters for the data source. In this case, we are specifying the **RedshiftClusterId**, Database, **ClusterUsername**, and **ClusterPassword** parameters for connecting to a Redshift cluster.
  • **Credentials**: The credentials for accessing the data source. In this case, we are specifying a **CredentialPair** with a Username and Password.
  • **Permissions**: The permissions for the data source. In this case, we are giving the specified Principal (a federated user or group) permissions to **DescribeDataSource**, **DescribeDataSourcePermissions**, and **PassDataSource** on the data source.
  • **VpcConnectionProperties**: The VPC connection properties for the data source. In this case, we are specifying the **VpcConnectionArn** to use for the connection.

To create a QuickSight data source with this template, you can use the **aws cloudformation create-stack** command and specify the template file as the input. You will also need to provide values for the parameters in the **Parameters** section of the template.

The template also defines a number of parameters that you must specify when creating the data source. These include the **DataSourceId**, **RedshiftClusterId**, Database, **ClusterUsername**, **ClusterPassword**, **CredentialUsername**, **CredentialPassword**, **Federated**, and **VpcConnectionArn** parameters.

The Outputs section defines a number of output values that can be referenced after the stack is created. In this case, the output values include the **DataSourceId**, **RedshiftClusterId**, Database, **ClusterUsername**, **CredentialUsername**, Federated, and **VpcConnectionArn** parameters that were used to create the data source.

The post How to create AWS QuickSight Data Source with AWS CloudFormation appeared first on Abhay Singh.

Did you find this article valuable?

Support Abhay Singh by becoming a sponsor. Any amount is appreciated!