How to update Template and Dashboard using CloudFormation

CloudFormation manages Analysis, Template, and Dashboard.
When the Definition of Analysis is updated, Template and Dashboard are also updated, and Dashboard is expected to reflect the updates in Analysis.
However, only Analysis is actually updated.

Is updating CloudFormation alone not sufficient?
Do I need to update Template and Dashboard via CLI or other means?

Resources:
  QuickSightDataSet:
    Type: AWS::QuickSight::DataSet
    <snip>

  QuickSightAnalysis:
    Type: AWS::QuickSight::Analysis
    <snip>

  QuickSightTemplate:
    Type: AWS::QuickSight::Template
    Properties:
      AwsAccountId: !Sub ${AwsAccountId}
      Name: 'Example'
      TemplateId: 'Example'
      SourceEntity:
        SourceAnalysis:
          Arn: !GetAtt QuickSightAnalysis.Arn
          DataSetReferences:
            - DataSetArn: !GetAtt QuickSightDataSet.Arn
              DataSetPlaceholder: 'QuickSightDataSet'
      Permissions:
        - Principal: !Sub ${GroupArn}
          Actions:
            - 'quicksight:DescribeTemplate'

  QuickSightDashboardFromTemplate:
    Type: AWS::QuickSight::Dashboard
    Properties: 
      AwsAccountId: !Sub ${AwsAccountId}
      DashboardId: 'ExampleFromTemplate'
      Name: 'ExampleFromTemplate'
      SourceEntity:
        SourceTemplate:
          Arn: !GetAtt QuickSightTemplate.Arn
          DataSetReferences:
            - DataSetArn: !GetAtt QuickSightDataSet.Arn
              DataSetPlaceholder: QuickSightDataSet
      Permissions: 
        - Principal: !Sub ${GroupArn}
          Actions: 
            - 'quicksight:DescribeDashboard'
            - 'quicksight:ListDashboardVersions'
            - 'quicksight:UpdateDashboardPermissions'
            - 'quicksight:QueryDashboard'
            - 'quicksight:UpdateDashboard'
            - 'quicksight:DeleteDashboard'
            - 'quicksight:DescribeDashboardPermissions'
            - 'quicksight:UpdateDashboardPublishedVersion'

Hey @ss49919201 !

Can you try adding a DependsOn attribute so that the Analysis and the Dashboard only update after the Template?

@duncan
Thanks for your reply.
I tried setting DependsOn, but Template and Dashboard were not updated.
It doesn’t seem possible to reflect analysis changes in CloudFormation on the dashboard.

Hey @ss49919201!

Where did you add the DependsOn attribute?

@duncan
Here’s what I tried !

Resources:
  QuickSightDataSet:
    Type: AWS::QuickSight::DataSet
    <snip>

  QuickSightAnalysis:
    Type: AWS::QuickSight::Analysis
    <snip>

  QuickSightTemplate:
    Type: AWS::QuickSight::Template
    Properties:
      AwsAccountId: !Sub ${AwsAccountId}
      Name: 'Example'
      TemplateId: 'Example'
      SourceEntity:
        SourceAnalysis:
          Arn: !GetAtt QuickSightAnalysis.Arn
          DataSetReferences:
            - DataSetArn: !GetAtt QuickSightDataSet.Arn
              DataSetPlaceholder: 'QuickSightDataSet'
      Permissions:
        - Principal: !Sub ${GroupArn}
          Actions:
            - 'quicksight:DescribeTemplate'
      DependsOn: QuickSightAnalysis

  QuickSightDashboardFromTemplate:
    Type: AWS::QuickSight::Dashboard
    Properties: 
      AwsAccountId: !Sub ${AwsAccountId}
      DashboardId: 'ExampleFromTemplate'
      Name: 'ExampleFromTemplate'
      SourceEntity:
        SourceTemplate:
          Arn: !GetAtt QuickSightTemplate.Arn
          DataSetReferences:
            - DataSetArn: !GetAtt QuickSightDataSet.Arn
              DataSetPlaceholder: QuickSightDataSet
      Permissions: 
        - Principal: !Sub ${GroupArn}
          Actions: 
            - 'quicksight:DescribeDashboard'
            - 'quicksight:ListDashboardVersions'
            - 'quicksight:UpdateDashboardPermissions'
            - 'quicksight:QueryDashboard'
            - 'quicksight:UpdateDashboard'
            - 'quicksight:DeleteDashboard'
            - 'quicksight:DescribeDashboardPermissions'
            - 'quicksight:UpdateDashboardPublishedVersion'
      DependsOn: QuickSightTemplate

Hello @ss49919201 !

Did that work for updating your dashboard?

Hello @duncan !
Updated Definition in Analysis, but Template and Dashboard were not updated.

Hey @ss49919201!

Can you try changing the order so that the Analysis depends on the Template and the Dashboard depends on the Analysis?

1 Like

Hey @ss49919201 ! Did that change work to update everything as expected?

@duncan
Since making Analysis the source of the template is what I am trying to achieve, if Analysis depends on Template, it becomes a circular reference.
Would it be undesirable to generate Template from Analysis?

Resources:
  QuickSightDataSet:
    Type: AWS::QuickSight::DataSet
    <snip>

  QuickSightAnalysis:
    Type: AWS::QuickSight::Analysis
    DependsOn: QuickSightTemplate
    <snip>

  QuickSightTemplate:
    Type: AWS::QuickSight::Template
    Properties:
      AwsAccountId: !Sub ${AwsAccountId}
      Name: 'Example'
      TemplateId: 'Example'
      SourceEntity:
        SourceAnalysis:
          Arn: !GetAtt QuickSightAnalysis.Arn
          DataSetReferences:
            - DataSetArn: !GetAtt QuickSightDataSet.Arn
              DataSetPlaceholder: 'QuickSightDataSet'
      Permissions:
        - Principal: !Sub ${GroupArn}
          Actions:
            - 'quicksight:DescribeTemplate'

  QuickSightDashboardFromTemplate:
    Type: AWS::QuickSight::Dashboard
    Properties: 
      AwsAccountId: !Sub ${AwsAccountId}
      DashboardId: 'ExampleFromTemplate'
      Name: 'ExampleFromTemplate'
      SourceEntity:
        SourceTemplate:
          Arn: !GetAtt QuickSightTemplate.Arn
          DataSetReferences:
            - DataSetArn: !GetAtt QuickSightDataSet.Arn
              DataSetPlaceholder: QuickSightDataSet
      Permissions: 
        - Principal: !Sub ${GroupArn}
          Actions: 
            - 'quicksight:DescribeDashboard'
            - 'quicksight:ListDashboardVersions'
            - 'quicksight:UpdateDashboardPermissions'
            - 'quicksight:QueryDashboard'
            - 'quicksight:UpdateDashboard'
            - 'quicksight:DeleteDashboard'
            - 'quicksight:DescribeDashboardPermissions'
            - 'quicksight:UpdateDashboardPublishedVersion'
      DependsOn: QuickSightAnalysis

An error occurred (ValidationError) when calling the CreateChangeSet operation: Circular dependency between resources: [QuickSightDashboardFromTemplate, QuickSightAnalysis, QuickSightDashboard, QuickSightTemplate]

Hey @ss49919201 , I’m sorry about the late reply, I was OOO recently and trying to catch up with old messages!

Are you still running into this issue? I don’t think it would be be bad to generate a template from an analysis as long as its the analysis that you would like to deploy to each new account.

1 Like

Hey @duncan , thanks to reply!
I’ll redesign the whole structure.

1 Like

Hey @duncan and team ,

I am trying to create the analysis, dataset , dashboard in the target account (prod) taking assets from the dev account. Here is my cloud formation template. It is first creating a dataset, followed by template, analysis and dashboard. The datasource is already there in prod.

But it is failing while uploading even if the template is valid.

Wanted to ask, the specifics that we are providing below is of the source account or target account?

For example: Please check code below, and could anyone let me know, what details to specify in DataSourceArn? Is it the ARN present in the source account dataset or some new arn we have to give?

Resources:
QSTCFBuildQSDataSet:
Type: AWS::QuickSight::DataSet
Properties:
DataSetId: !Join
- ‘’
- - QSTCF-DataSet
- !Ref Suffix
Name: !Join
- ‘’
- - QSTCF-DataSet
- !Ref Suffix
AwsAccountId: !Ref AWS::AccountId
PhysicalTableMap:
PhysicalTable1:
S3Source:
DataSourceArn: arn:aws:rds:us-east-1:885770418550:db:data-monitoring-20200102184109387500000001

#move to prod


BELOW IS THE TOTAL CODE: Please suggest

AWSTemplateFormatVersion: "2010-09-09"
Description: "Automated deployment of QuickSight Analysis"

Parameters:
  1stReadMe:
    Type: String
    Default: README
    Description: 'PREREQUISITES - 1) QuickSight should be setup on the aws account, 2) An user with author/admin role should be setup in QuickSight. 3)SPICE capacity should be available in the region where you are creating this stack.'

  QuickSightIdentityRegion:
    Type: String
    MinLength: 1
    Default: us-east-1
    Description: REQUIRED - QuickSight identity region (region where your users are managed; run list-users command and check the user arn if you are not sure of the identity region).

  QuickSightUser:
    Type: String
    MinLength: 1
    Default: ****
    Description: REQUIRED - User name of QuickSight author/admin from default namespace (as displayed in QuickSight admin panel). Dashboard created by this template with be shared with this user.

  AppEnvironment:
    Type: String
    Default: dev
  
  AccountVpc:
    Type: AWS::EC2::VPC::Id
    Description: Account VPC
    Default: ****

  Suffix:
    Type: String
    Description: OPTIONAL - If you need to create multiple instances of this sample on same aws account, add a short NUMERIC suffix here.

Resources:
  QSTCFBuildQSDataSet:
    Type: AWS::QuickSight::DataSet
    Properties:
      DataSetId: !Join
        - ''
        - - QSTCF-DataSet
          - !Ref Suffix
      Name: !Join
        - ''
        - - QSTCF-DataSet
          - !Ref Suffix
      AwsAccountId: !Ref AWS::AccountId
      PhysicalTableMap:
          PhysicalTable1:
            S3Source:
              DataSourceArn: arn:aws:rds:us-east-1:885770418550:db:data-monitoring-20200102184109387500000001
              InputColumns:
              - Name: datasetname
                Type: STRING
              - Name: datasettype
                Type: STRING
              - Name: bucketname
                Type: STRING
              - Name: datasetcreatetime
                Type: STRING
              - Name: arrival_time
                Type: STRING
              - Name: time
                Type: STRING
              - Name: fileparsedate
                Type: STRING
              - Name: date
                Type: STRING
              - Name: carr_acctg_cd
                Type: STRING
              - Name: CARR_ACCTG_CD
                Type: STRING
              - Name: CARR_NM_1
                Type: STRING
              - Name: MIN_HOUR
                Type: STRING
              - Name: MinHour in Minutes from Zero hour
                Type: STRING
              - Name: MAX_HOUR
                Type: STRING
              - Name: MaxHour in Minutes from Zero hour
                Type: STRING
              # UploadSettings:
              #   ContainsHeader: true
              #   Delimiter: ','
              #   Format: CSV
              #   StartFromRow: 1
              #   TextQualifier: DOUBLE_QUOTE
      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: SPICE

  QSTCFBuildQSTemplate:
    Type: 'AWS::QuickSight::Template'
    Properties:
      TemplateId: "missing_files_parse_date_compare_date_trend-Template"
      Name: "missing_files_parse_date_compare_date_trend-Template"
      AwsAccountId: !Ref AWS::AccountId
      SourceEntity:
        SourceTemplate:
          Arn: 'arn:aws:quicksight:us-east-1:885770418550:template/missing_files_parse_date_compare_date_trend-Template'          
      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
      
  QSRSBuildQSAnalysis:
    Type: 'AWS::QuickSight::Analysis'
    Properties:
      AnalysisId: 'fdb55fdb-831c-472e-805d-e00b9051d10a'
      Name: 'missing_files_parse_date_compare_date_trend analysis'
      AwsAccountId: !Ref AWS::AccountId
      SourceEntity:
        SourceTemplate:
          Arn: !GetAtt  QSTCFBuildQSTemplate.Arn
          DataSetReferences:
            - DataSetPlaceholder: 'missing_files_parse_date_compare_date_trend'
              DataSetArn: !GetAtt  QSTCFBuildQSTemplate.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'
            
  QSTCFBuildQSDashboard:
    Type: AWS::QuickSight::Dashboard
    Properties:
      DashboardId: !Join
        - ''
        - - QSTCF-Dashboard
          - !Ref Suffix
      Name: !Join
        - ''
        - - QSTCF-Dashboard
          - !Ref Suffix
      AwsAccountId: !Ref AWS::AccountId
      SourceEntity:
        SourceTemplate:
          Arn: !GetAtt QSTCFBuildQSTemplate.Arn
          DataSetReferences:
            - DataSetPlaceholder: missing_files_parse_date_compare_date_trend
              DataSetArn: !GetAtt QSTCFBuildQSDataSet.Arn
      Permissions:
        - Principal: !Join
            - ''
            - - 'arn:aws:quicksight:'
              - !Ref QuickSightIdentityRegion
              - ':'
              - !Ref AWS::AccountId
              - ':user/default/'
              - !Ref QuickSightUser
          Actions:
            - quicksight:DescribeDashboard
            - quicksight:ListDashboardVersions
            - quicksight:UpdateDashboardPermissions
            - quicksight:QueryDashboard
            - quicksight:UpdateDashboard
            - quicksight:DeleteDashboard
            - quicksight:DescribeDashboardPermissions
            - quicksight:UpdateDashboardPublishedVersion
      # ThemeArn: !GetAtt QSTCFBuildQSTheme.Arn
      # DashboardPublishOptions:
      #   AdHocFilteringOption:
      #     AvailabilityStatus: DISABLED

Hey @ss49919201 !

Because this post is older and has a marked solution, can you repost this question to the top of the community as a new post? This way it will be at the top of the priority list for the community experts.

You can add the link to this post for reference as well.