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]