Skip to content

Commit 8831f14

Browse files
add config for quicksight
1 parent 084641b commit 8831f14

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

cdk/bin/cdk.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@
22
import "source-map-support/register";
33
import { App, Tags } from 'aws-cdk-lib';
44
import { CdkStack } from "../lib/cdk-stack";
5+
import { config } from "./config";
56

67
const name = `persons-cdk`;
78

89
const app = new App();
910
const cdkStack = new CdkStack(app, name, {
10-
/* If you don't specify 'env', this stack will be environment-agnostic.
11-
* Account/Region-dependent features and context lookups will not work,
12-
* but a single synthesized template can be deployed anywhere. */
13-
/* Uncomment the next line to specialize this stack for the AWS Account
14-
* and Region that are implied by the current CLI configuration. */
15-
// env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },
16-
/* Uncomment the next line if you know exactly what Account and Region you
17-
* want to deploy the stack to. */
18-
// env: { account: '123456789012', region: 'us-east-1' },
19-
/* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */
11+
config: config,
2012
});
2113

2214
Tags.of(cdkStack).add("Project", "test-aws-dynamodb-athena-cdk");

cdk/bin/config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface Config {
2+
isQuicksight: boolean;
3+
}
4+
5+
export const config: Config = {
6+
isQuicksight: false,
7+
}

cdk/lib/cdk-stack.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Construct } from 'constructs'
22
import {
33
Stack,
4-
StackProps,
54
RemovalPolicy,
65
Duration,
76
aws_kms as kms,
@@ -13,6 +12,7 @@ import {
1312
aws_glue as glue,
1413
aws_athena as athena,
1514
aws_logs as logs,
15+
StackProps,
1616
} from 'aws-cdk-lib'
1717

1818
import { LambdaFunctionProcessor as LambdaFunctionProcessorAlpha, DeliveryStream as DeliveryStreamAlpha } from '@aws-cdk/aws-kinesisfirehose-alpha'
@@ -24,9 +24,15 @@ import { Quicksight } from './quicksight/quicksight'
2424
import { QuicksightRole } from './quicksight/quicksight-role'
2525
import { DdbExport } from './ddb-export/ddb-export'
2626
import { DdbExportStepFunction } from './ddb-export/ddb-export-step-function'
27+
import { Config } from '../bin/config'
28+
29+
30+
export interface CdkStackProps extends StackProps {
31+
config: Config
32+
}
2733

2834
export class CdkStack extends Stack {
29-
constructor(scope: Construct, id: string, props?: StackProps) {
35+
constructor(scope: Construct, id: string, props?: CdkStackProps) {
3036
super(scope, id, props)
3137

3238
const name = `persons-cdk`
@@ -244,16 +250,19 @@ export class CdkStack extends Stack {
244250

245251
savedQueries.node.addDependency(athenaWorkgroup)
246252

247-
new Quicksight(this, 'quicksight', {
248-
bucket: firehoseBucket,
249-
name: name,
250-
prefix: ddbChangesPrefix,
251-
})
253+
if (props?.config.isQuicksight) {
252254

253-
new QuicksightRole(this, 'quicksight-role', {
254-
name: name,
255-
bucket: firehoseBucket,
256-
})
255+
new Quicksight(this, 'quicksight', {
256+
bucket: firehoseBucket,
257+
name: name,
258+
prefix: ddbChangesPrefix,
259+
})
260+
261+
new QuicksightRole(this, 'quicksight-role', {
262+
name: name,
263+
bucket: firehoseBucket,
264+
})
265+
}
257266

258267
new DdbExport(this, 'ddb-export', {
259268
name: name,

0 commit comments

Comments
 (0)