Skip to content

Commit 63d0cf7

Browse files
SGhotra1Sebastian SchürmannKathiHaecarrequesebs
authored
feat(typescript/quicksight): Add an example that creates a useable dataset in Quicksight (#1085)
* Initial quicksight example commit * Used world population data, created logical columns, refactored naming of variables * refactor: improving naming and sorting the code * fix: re-add deployment to dependencies of the quicksight data source * refactor: cleanup imports * refactor: quicksight datasource name moved to a static property * refactor: policy generation and cleanup * refactor: naming of definitions for the quicksight table * refactor: move dataset name to a static * docs: add instructions * refactor: Fixed some links for Cloudformation resources docs, quicksightAccountArn needs to be passed as context * docs: a tad more info in the readme * chore: readme updated * chore: add resources information * docs: Added explanation of the quicksight arn, removed test scripts * chore: Add DO_NOT_AUTOTEST file --------- Co-authored-by: Sebastian Schürmann <[email protected]> Co-authored-by: KathiHae <[email protected]> Co-authored-by: Carlos Revuelto Quero <[email protected]> Co-authored-by: Sebastian Schürmann <[email protected]>
1 parent ec0aab1 commit 63d0cf7

File tree

10 files changed

+1148
-0
lines changed

10 files changed

+1148
-0
lines changed

typescript/quicksight/DO_NOT_AUTOTEST

Whitespace-only changes.

typescript/quicksight/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!--BEGIN STABILITY BANNER-->
2+
---
3+
4+
![Stability: Cfn-Only](https://img.shields.io/badge/stability-Cfn--Only-important.svg?style=for-the-badge)
5+
6+
> **This is an experimental example. It may not build out of the box**
7+
>
8+
> This example is built on Cfn resources.
9+
>
10+
> It requires additional infrastructure prerequisites that must be created before successful build, see below.
11+
>
12+
> If build is unsuccessful, please create an [issue](https://github.com/aws-samples/aws-cdk-examples/issues/new) so that we may debug the problem
13+
---
14+
<!--END STABILITY BANNER-->
15+
16+
## Overview
17+
18+
This project demonstrates how to set up Amazon Quicksight. It will set up a S3 Bucket, import some test data and makes it available as a datasource to quicksight.
19+
20+
With this setup you can create analysis in the console to view e.g. the world-population data:
21+
world-population.csv file in data directory taken from https://data.worldbank.org/indicator/SP.POP.TOTL
22+
License: CC BY-4.0
23+
24+
## Build
25+
26+
To build this app, you need to be in this example's root folder. Then run the following:
27+
28+
```bash
29+
npm install -g aws-cdk
30+
npm install
31+
npm run build
32+
```
33+
34+
## Resources
35+
36+
1. * `Bucket` (aws-s3): Creates an Amazon S3 bucket with encryption and full access control, used to store data files and the manifest for QuickSight.
37+
2. * `BucketDeployment` (aws-s3-deployment): Deploys world population data and manifest JSON files to the S3 bucket, making them accessible for analysis in QuickSight.
38+
3. * `CfnDataSource` (aws-quicksight): Defines an Amazon QuickSight data source that connects to the S3 bucket to access the uploaded CSV files.
39+
4. * `CfnDataSet` (aws-quicksight): Configures a QuickSight dataset that organizes and structures the CSV data from the S3 bucket for reporting and analysis.
40+
5. * `CfnManagedPolicy` (aws-iam): Creates an IAM policy granting permissions to the QuickSight service role, allowing access to the S3 bucket and other necessary actions.
41+
42+
## Deploy
43+
44+
1. Create a quicksight account [by following these instructions](https://docs.aws.amazon.com/quicksight/latest/user/signing-up.html).
45+
2. Use the arn of the quicksight account and pass it to cdk using a context `cdk deploy --context quicksightAccountArn=<arn>`
46+
47+
The Quicksight account arn should look like this 'arn:aws:quicksight:\<region>:\<accountid>:user/\<namespace>/\<username>'
48+
49+
#### \<region>
50+
The aws region that contains the quicksight resources.
51+
#### \<accountid>
52+
This is your AWS account id.
53+
#### \<namespace>
54+
You can create a separate namespace, but if you haven't created one it should be 'default'.
55+
#### \<username>
56+
You can find the username in Quicksight. It should be the same as your IAM Account name
57+
and if you are using a role it will be added to the name as well like: \<role>/\<username>
58+
59+
## Useful commands
60+
61+
* `npm run build` compile typescript to js
62+
* `npm run watch` watch for changes and compile
63+
* `npm run test` perform the jest unit tests
64+
* `npx cdk deploy` deploy this stack to your default AWS account/region
65+
* `npx cdk diff` compare deployed stack with current state
66+
* `npx cdk synth` emits the synthesized CloudFormation template
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env node
2+
import 'source-map-support/register';
3+
import * as cdk from 'aws-cdk-lib';
4+
import { QuicksightExampleStack } from '../lib/quicksight-example-stack';
5+
6+
const app = new cdk.App();
7+
8+
// Quicksight account arn should look like this 'arn:aws:quicksight:<region>:<accountid>:user/<namespace>/<username>'
9+
const quicksightExampleProps = {quicksightAccountArn: app.node.tryGetContext('quicksightAccountArn')};
10+
if (quicksightExampleProps.quicksightAccountArn == null) {
11+
console.log('quicksightAccountArn is empty! Please provide it via the cdk context');
12+
process.exit(1);
13+
}
14+
new QuicksightExampleStack(app, 'QuicksightExampleStack', quicksightExampleProps);

typescript/quicksight/cdk.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"app": "npx ts-node --prefer-ts-exts bin/quicksight-example.ts",
3+
"watch": {
4+
"include": [
5+
"**"
6+
],
7+
"exclude": [
8+
"README.md",
9+
"cdk*.json",
10+
"**/*.d.ts",
11+
"**/*.js",
12+
"tsconfig.json",
13+
"package*.json",
14+
"yarn.lock",
15+
"node_modules",
16+
"test"
17+
]
18+
},
19+
"context": {
20+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
21+
"@aws-cdk/core:checkSecretUsage": true,
22+
"@aws-cdk/core:target-partitions": [
23+
"aws",
24+
"aws-cn"
25+
],
26+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
27+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
28+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
29+
"@aws-cdk/aws-iam:minimizePolicies": true,
30+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
31+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
32+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
33+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
34+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
35+
"@aws-cdk/core:enablePartitionLiterals": true,
36+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
37+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
38+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
39+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
40+
"@aws-cdk/aws-route53-patters:useCertificate": true,
41+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
42+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
43+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
44+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
45+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
46+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
47+
"@aws-cdk/aws-redshift:columnId": true,
48+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
49+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
50+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
51+
"@aws-cdk/aws-kms:aliasNameRef": true,
52+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
53+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
54+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
55+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
56+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
57+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
58+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
59+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
60+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
61+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
62+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
63+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
64+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
65+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
66+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
67+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
68+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
69+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
70+
"@aws-cdk/aws-s3:keepNotificationInImportedBucket": false
71+
}
72+
}

0 commit comments

Comments
 (0)