Skip to content

Commit 3aa7f1d

Browse files
author
Sebastian Schürmann
committed
refactor: quicksight datasource name moved to a static property
1 parent c4adb17 commit 3aa7f1d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

typescript/quicksight/lib/quicksight-example-stack.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import {logicalColumns} from './logical-columns';
88
import {physicalColumns} from './physical-columns';
99

1010
export class QuicksightExampleStack extends Stack {
11+
// location of the manifest json file in the s3 bucket.
12+
// Used by quicksight to discover the csv files.
1113
public static MANIFEST_KEY = 'manifests/manifest.json';
14+
/**
15+
* foo bar
16+
*/
17+
public static QUICKSIGHT_DATASOURCE_NAME = 's3DataSourceExample';
1218

1319
constructor(scope: Construct, id: string, props?: StackProps) {
1420
super(scope, id, props);
@@ -55,10 +61,6 @@ export class QuicksightExampleStack extends Stack {
5561
}
5662

5763
public createQuicksightResources(bucket: Bucket, deployment: BucketDeployment, quicksightAccountArn: string) {
58-
const quicksightS3DataSourceName = 's3DataSourceExample';
59-
// make it a stack parameter so users dont have to change the code
60-
// make sure here it is clear that the acc cant be created
61-
// replace with your own values here
6264

6365
const quicksightDataSourcePermissions: CfnTemplate.ResourcePermissionProperty[] = [
6466
{
@@ -104,8 +106,8 @@ export class QuicksightExampleStack extends Stack {
104106
'S3DataSource',
105107
{
106108
awsAccountId: this.account,
107-
dataSourceId: quicksightS3DataSourceName,
108-
name: quicksightS3DataSourceName,
109+
dataSourceId: QuicksightExampleStack.QUICKSIGHT_DATASOURCE_NAME,
110+
name: QuicksightExampleStack.QUICKSIGHT_DATASOURCE_NAME,
109111
dataSourceParameters: {
110112
s3Parameters: {
111113
manifestFileLocation: {
@@ -131,7 +133,7 @@ export class QuicksightExampleStack extends Stack {
131133
const logicalTableProperties = {
132134
alias: 's3-extract-data-cast',
133135
source: {
134-
physicalTableId: quicksightS3DataSourceName
136+
physicalTableId: QuicksightExampleStack.QUICKSIGHT_DATASOURCE_NAME
135137
},
136138
dataTransforms: transformOperations
137139
}
@@ -154,8 +156,8 @@ export class QuicksightExampleStack extends Stack {
154156
'quicksightExampleDataset',
155157
{
156158
awsAccountId: this.account,
157-
physicalTableMap: {[quicksightS3DataSourceName]: physicalTableProperties},
158-
logicalTableMap: {[quicksightS3DataSourceName]: logicalTableProperties},
159+
physicalTableMap: {[QuicksightExampleStack.QUICKSIGHT_DATASOURCE_NAME]: physicalTableProperties},
160+
logicalTableMap: {[QuicksightExampleStack.QUICKSIGHT_DATASOURCE_NAME]: logicalTableProperties},
159161
name: 'quicksightExampleDataset',
160162
dataSetId: 'quicksightExampleDataset',
161163
permissions: quicksightDatasetPermissions,

0 commit comments

Comments
 (0)