constructor()

in source/cdk-infrastructure/lib/bi-reporting/quicksight/quicksight-construct.ts [37:107]


  constructor(scope: Construct, id: string, props: IQuickSightReportingProps) {
    super(scope, id);

    const { bucketName, manifestPrefix, machineInformationPrefix, machineConfigInformationPrefix } = props.metadataConfiguration;

    const solutionHelperQuickSightPolicy = new Policy(this, 'SolutionHelperQuickSightPolicy', {
      statements: [
        new PolicyStatement({
          effect: Effect.ALLOW,
          actions: [
            'quicksight:CreateDataSource',
            'quicksight:DeleteDataSource',
            'quicksight:PassDataSource'
          ],
          resources: [`arn:${Aws.PARTITION}:quicksight:${Aws.REGION}:${Aws.ACCOUNT_ID}:datasource/${Aws.STACK_NAME}*`]
        }),
        new PolicyStatement({
          effect: Effect.ALLOW,
          actions: [
            'quicksight:CreateDataSet',
            'quicksight:DeleteDataSet',
            'quicksight:PassDataSet'
          ],
          resources: [`arn:${Aws.PARTITION}:quicksight:${Aws.REGION}:${Aws.ACCOUNT_ID}:dataset/${Aws.STACK_NAME}*`]
        }),
        new PolicyStatement({
          effect: Effect.ALLOW,
          actions: [
            'quicksight:CreateAnalysis',
            'quicksight:DeleteAnalysis'
          ],
          resources: [`arn:${Aws.PARTITION}:quicksight:${Aws.REGION}:${Aws.ACCOUNT_ID}:analysis/${Aws.STACK_NAME}*`]
        }),
        new PolicyStatement({
          effect: Effect.ALLOW,
          actions: [
            'quicksight:CreateDashboard',
            'quicksight:DeleteDashboard'
          ],
          resources: [`arn:${Aws.PARTITION}:quicksight:${Aws.REGION}:${Aws.ACCOUNT_ID}:dashboard/${Aws.STACK_NAME}*`]
        }),
        new PolicyStatement({
          effect: Effect.ALLOW,
          actions: ['quicksight:DescribeTemplate'],
          resources: [props.quickSightTemplate]
        })
      ],
      roles: [props.solutionHelperFunction.role!]
    });

    const quickSightCustomResource = new CustomResource(this, 'QuickSightCustomResource', {
      serviceToken: props.solutionHelperFunction.functionArn,
      properties: {
        Action: 'CREATE_QUICKSIGHT',
        AccountId: Aws.ACCOUNT_ID,
        GlueDatabaseName: props.glueDatabaseName,
        GlueTableName: props.glueTableName,
        Metadata: {
          BucketName: bucketName,
          MachineInformationPrefix: machineInformationPrefix,
          MachineConfigInformationPrefix: machineConfigInformationPrefix,
          ManifestPrefix: manifestPrefix
        },
        PrincipalArn: props.quickSightPrincipalArn,
        QuickSightTemplate: props.quickSightTemplate,
        StackName: Aws.STACK_NAME
      }
    });
    quickSightCustomResource.node.addDependency(solutionHelperQuickSightPolicy);
    quickSightCustomResource.node.addDependency(props.glueCustomResource);
  }