Skip to content

Commit d78417f

Browse files
Add QuickSight data collection in Data Collection Account (#212)
Co-authored-by: SohamMajumder <[email protected]>
1 parent 9e55876 commit d78417f

File tree

8 files changed

+434
-30
lines changed

8 files changed

+434
-30
lines changed

data-collection/README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This projects demonstrates usage of AWS API for collecting various types of usag
99
![Architecture](/data-collection/images/archi.png)
1010

1111
1. Amazon EventBridge rule invokes Step Function of every every deployed data collection module. based on schedule.
12-
2. The Step Function launches a Lambda function Account Collector that assumes Read Role role in the Management account and retrieves linked accounts list via AWS Organizations API
12+
2. The Step Function launches a Lambda function Account Collector that assumes Read Role role in the Management accounts and retrieves linked accounts list via AWS Organizations API
1313
3. Step Functions launches Data Collection Lambda function for each collected Account.
1414
4. Each data collection module Lambda function assumes IAM role in linked accounts and retrieves respective optimization data via AWS SDK for Python. Retrieved data aggregated in Amazon S3 bucket
1515
5. Once data stored in S3 bucket, Step Functions triggers AWS Glue crawler which creates or updates the table in Glue Data Catalog
@@ -20,33 +20,34 @@ This projects demonstrates usage of AWS API for collecting various types of usag
2020
List of modules and objects collected:
2121
| Module Name | AWS Services | Collected In | Details |
2222
| --- | --- | --- | --- |
23-
| `organization` | AWS Organizations | Management Account | |
24-
| `budgets` | AWS Budgest | Linked Account | |
25-
| `compute-optimizer` | AWS Compute Optimizer | Management Account | Requires [Enablement of Compute Optimizer](https://aws.amazon.com/compute-optimizer/getting-started/#:~:text=Opt%20in%20for%20Compute%20Optimizer,created%20automatically%20in%20your%20account.) |
26-
| `trusted-advisor` | AWS Trusted Advisor | Linked Account | Requires Enterpriso or OnRamp Support Level |
27-
| `support-cases` | AWS Support | Linked Account | Requires Business, Enterprise On-Ramp, or Enterprise Support plan |
28-
| `cost-explorer-cost-anomaly` | AWS Anomalies | Management Account | |
29-
| `cost-explorer-rightsizing` | AWS Cost Explorer | Management Account | DEPRECATED. Please use `Data Exports` for `Cost Optimization Hub` |
30-
| `inventory` | Various services | Linked Account | Collects `Amazon OpenSearch Domains`, `Amazon ElastiCache Clusters`, `RDS DB Instances`, `EBS Volumes`, `AMI`, `EC2 Instances`, `EBS Snapshot`, `RDS Snapshot`, `Lambda`, `RDS DB Clusters`, `EKS Clusters` |
31-
| `pricing` | Various services | N/A | Collects pricing for `Amazon RDS`, `Amazon EC2`, `Amazon ElastiCache`, `AWS Lambda`, `Amazon OpenSearch`, `AWS Compute Savings Plan` |
32-
| `rds-usage` | Amazon RDS | Linked Account | Collects CloudWatch metrics for chargeback |
33-
| `transit-gateway` | AWS Transit Gateway | Linked Account | Collects CloudWatch metrics for chargeback |
34-
| `ecs-chargeback` | Amazon ECS | Linked Account | |
35-
| `backup` | AWS Backup | Management Account | Collects Backup Restore and Copy Jobs. Requires [activation of cross-account](https://docs.aws.amazon.com/aws-backup/latest/devguide/manage-cross-account.html#enable-cross-account) |
36-
| `health-events` | AWS Health | Management Accounts | Collect AWS Health notificaitons via AWS Organizational view |
37-
| `licence-manager` | AWS License Manager | Management Accounts | Collect Licences and Grants |
38-
23+
| `organization` | AWS Organizations | Management Accounts | |
24+
| `budgets` | AWS Budgest | Linked Accounts | |
25+
| `compute-optimizer` | AWS Compute Optimizer | Management Accounts | Requires [Enablement of Compute Optimizer](https://aws.amazon.com/compute-optimizer/getting-started/#:~:text=Opt%20in%20for%20Compute%20Optimizer,created%20automatically%20in%20your%20account.) |
26+
| `trusted-advisor` | AWS Trusted Advisor | Linked Accounts | Requires Enterpriso or OnRamp Support Level |
27+
| `support-cases` | AWS Support | Linked Accounts | Requires Business, Enterprise On-Ramp, or Enterprise Support plan |
28+
| `cost-explorer-cost-anomaly` | AWS Anomalies | Management Accounts | |
29+
| `cost-explorer-rightsizing` | AWS Cost Explorer | Management Accounts | DEPRECATED. Please use `Data Exports` for `Cost Optimization Hub` |
30+
| `inventory` | Various services | Linked Accounts | Collects `Amazon OpenSearch Domains`, `Amazon ElastiCache Clusters`, `RDS DB Instances`, `EBS Volumes`, `AMI`, `EC2 Instances`, `EBS Snapshot`, `RDS Snapshot`, `Lambda`, `RDS DB Clusters`, `EKS Clusters` |
31+
| `pricing` | Various services | Data Collection Account | Collects pricing for `Amazon RDS`, `Amazon EC2`, `Amazon ElastiCache`, `AWS Lambda`, `Amazon OpenSearch`, `AWS Compute Savings Plan` |
32+
| `rds-usage` | Amazon RDS | Linked Accounts | Collects CloudWatch metrics for chargeback |
33+
| `transit-gateway` | AWS Transit Gateway | Linked Accounts | Collects CloudWatch metrics for chargeback |
34+
| `ecs-chargeback` | Amazon ECS | Linked Accounts | |
35+
| `backup` | AWS Backup | Management Accounts | Collects Backup Restore and Copy Jobs. Requires [activation of cross-account](https://docs.aws.amazon.com/aws-backup/latest/devguide/manage-cross-account.html#enable-cross-account) |
36+
| `health-events` | AWS Health | Management Accounts | Collect AWS Health notificaitons via AWS Organizational view |
37+
| `licence-manager` | AWS License Manager | Management Accounts | Collect Licences and Grants |
38+
| `aws-feeds` | N/A | Data Collection Account |Collects Blog posts and News Feeds|
39+
| `quicksight` | Amazon QuickSight | Data Collection Account |Collects Quicksight User and Group information in the Data Collection Account only|
3940

4041

4142
### Installation
4243

4344
#### 1. In Management Account(s)
4445

45-
The Management Account stack makes use of [stack sets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/what-is-cfnstacksets.html) configured to use [service-managed permissions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-concepts.html#stacksets-concepts-stackset-permission-models) to deploy stack instances to linked accounts in the AWS Organization.
46+
The Management Accounts stack makes use of [stack sets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/what-is-cfnstacksets.html) configured to use [service-managed permissions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-concepts.html#stacksets-concepts-stackset-permission-models) to deploy stack instances to linked accounts in the AWS Organization.
4647

47-
Before creating the Management Account stack, please make sure [trusted access with AWS Organizations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-activate-trusted-access.html) is activated.
48+
Before creating the Management Accounts stack, please make sure [trusted access with AWS Organizations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-activate-trusted-access.html) is activated.
4849

49-
The Management Account Stack creates a read role in the Management Account and also a StackSet that will deploy another read role in each linked Account. Permissions depend on the set of modules you activate via parameters of the stack:
50+
The Management Accounts Stack creates a read role in the Management Accounts and also a StackSet that will deploy another read role in each linked Account. Permissions depend on the set of modules you activate via parameters of the stack:
5051

5152
* <kbd> <br> [Launch Stack >>](https://console.aws.amazon.com/cloudformation/home#/stacks/create/review?&templateURL=https://aws-managed-cost-intelligence-dashboards-us-east-1.s3.amazonaws.com/cfn/data-collection/deploy-data-read-permissions.yaml&stackName=CidDataCollectionDataReadPermissionsStack&param_DataCollectionAccountID=REPLACE%20WITH%20DATA%20COLLECTION%20ACCOUNT%20ID&param_AllowModuleReadInMgmt=yes&param_OrganizationalUnitID=REPLACE%20WITH%20ORGANIZATIONAL%20UNIT%20ID&param_IncludeBudgetsModule=no&param_IncludeComputeOptimizerModule=no&param_IncludeCostAnomalyModule=no&param_IncludeECSChargebackModule=no&param_IncludeInventoryCollectorModule=no&param_IncludeRDSUtilizationModule=no&param_IncludeRightsizingModule=no&param_IncludeTAModule=no&param_IncludeTransitGatewayModule=no) <br> </kbd>
5253

data-collection/deploy/deploy-data-collection.yaml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Metadata:
3434
- IncludeTransitGatewayModule
3535
- IncludeAWSFeedsModule
3636
- IncludeLicenseManagerModule
37+
- IncludeQuickSightModule
3738
ParameterLabels:
3839
DestinationBucket:
3940
default: 'Destination S3 bucket prefix'
@@ -85,6 +86,8 @@ Metadata:
8586
default: 'Include AWS Health Events Module'
8687
IncludeLicenseManagerModule:
8788
default: 'Include Marketplace Licensing Collection'
89+
IncludeQuickSightModule:
90+
default: 'Include QuickSight User Collection Module'
8891

8992
Mappings:
9093
RegionMap:
@@ -108,7 +111,7 @@ Mappings:
108111
StepFunctionCode:
109112
main-v2: {TemplatePath: cfn/data-collection/source/step-functions/main-state-machine-v2.json}
110113
crawler-v1: {TemplatePath: cfn/data-collection/source/step-functions/crawler-state-machine-v1.json}
111-
awsfeeds-v1: {TemplatePath: cfn/data-collection/source/step-functions/awsfeeds-state-machine-v1.json}
114+
standalone-v1: {TemplatePath: cfn/data-collection/source/step-functions/awsfeeds-state-machine-v1.json}
112115

113116
Parameters:
114117
DestinationBucket:
@@ -229,6 +232,11 @@ Parameters:
229232
Description: Collects Marketplace Licenses and Grants
230233
AllowedValues: ['yes', 'no']
231234
Default: 'no'
235+
IncludeQuickSightModule:
236+
Type: String
237+
Description: Collects Marketplace Licenses and Grants
238+
AllowedValues: ['yes', 'no']
239+
Default: 'no'
232240

233241
Conditions:
234242
DeployTAModule: !Equals [ !Ref IncludeTAModule, "yes"]
@@ -246,6 +254,7 @@ Conditions:
246254
DeployAWSFeedsModule: !Equals [ !Ref IncludeAWSFeedsModule, "yes"]
247255
DeployHealthEventsModule: !Equals [ !Ref IncludeHealthEventsModule, "yes"]
248256
DeployLicenseManagerModule: !Equals [ !Ref IncludeLicenseManagerModule, "yes"]
257+
DeployQuickSightModule: !Equals [ !Ref IncludeQuickSightModule, "yes"]
249258
DeployPricingModule: !Or
250259
- !Condition DeployInventoryCollectorModule
251260
- !Condition DeployRDSUtilizationModule
@@ -266,6 +275,7 @@ Conditions:
266275
- !Condition DeployTransitGatewayModule
267276
- !Condition DeployHealthEventsModule
268277
- !Condition DeployLicenseManagerModule
278+
- !Condition DeployQuickSightModule
269279
RegionsInScopeIsEmpty: !Equals
270280
- !Join [ '', !Split [ ' ', !Ref RegionsInScope ] ] # remove spaces
271281
- ""
@@ -1169,7 +1179,7 @@ Resources:
11691179
ResourcePrefix: !Ref ResourcePrefix
11701180
LambdaAnalyticsARN: !GetAtt LambdaAnalytics.Arn
11711181
CodeBucket: !If [ ProdCFNTemplateUsed, !FindInMap [RegionMap, !Ref "AWS::Region", CodeBucket], !Ref CFNSourceBucket ]
1172-
StepFunctionTemplate: !FindInMap [StepFunctionCode, awsfeeds-v1, TemplatePath]
1182+
StepFunctionTemplate: !FindInMap [StepFunctionCode, standalone-v1, TemplatePath]
11731183
StepFunctionExecutionRoleARN: !GetAtt StepFunctionExecutionRole.Arn
11741184
SchedulerExecutionRoleARN: !GetAtt SchedulerExecutionRole.Arn
11751185

@@ -1213,6 +1223,24 @@ Resources:
12131223
StepFunctionExecutionRoleARN: !GetAtt StepFunctionExecutionRole.Arn
12141224
SchedulerExecutionRoleARN: !GetAtt SchedulerExecutionRole.Arn
12151225

1226+
QuickSightModule:
1227+
Type: AWS::CloudFormation::Stack
1228+
Condition: DeployQuickSightModule
1229+
Properties:
1230+
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-quicksight.yaml"
1231+
Parameters:
1232+
DatabaseName: !Ref DatabaseName
1233+
DestinationBucket: !Ref S3Bucket
1234+
DestinationBucketARN: !GetAtt S3Bucket.Arn
1235+
Schedule: !Ref ScheduleFrequent
1236+
GlueRoleARN: !GetAtt GlueRole.Arn
1237+
ResourcePrefix: !Ref ResourcePrefix
1238+
LambdaAnalyticsARN: !GetAtt LambdaAnalytics.Arn
1239+
CodeBucket: !If [ ProdCFNTemplateUsed, !FindInMap [RegionMap, !Ref "AWS::Region", CodeBucket], !Ref CFNSourceBucket ]
1240+
StepFunctionTemplate: !FindInMap [StepFunctionCode, standalone-v1, TemplatePath]
1241+
StepFunctionExecutionRoleARN: !GetAtt StepFunctionExecutionRole.Arn
1242+
SchedulerExecutionRoleARN: !GetAtt SchedulerExecutionRole.Arn
1243+
12161244
AccountCollector:
12171245
Type: AWS::CloudFormation::Stack
12181246
Condition: DeployAccountCollector

data-collection/deploy/deploy-in-linked-account.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Metadata:
4040
default: 'Include Budgets Collection Module'
4141
IncludeTransitGatewayModule:
4242
default: 'Include Transit Gateway Module'
43+
4344
Parameters:
4445
DataCollectionAccountID:
4546
Type: String
@@ -301,4 +302,4 @@ Resources:
301302
cfn_nag:
302303
rules_to_suppress:
303304
- id: W12
304-
reason: "Policy is used for scanning of a wide range of resources"
305+
reason: "Policy is used for scanning of a wide range of resources"

data-collection/deploy/deploy-in-management-account.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,4 +352,4 @@ Resources:
352352
cfn_nag:
353353
rules_to_suppress:
354354
- id: W12
355-
reason: "Policy is used for scanning of a wide range of resources"
355+
reason: "Policy is used for scanning of a wide range of resources"

0 commit comments

Comments
 (0)