Skip to content

Commit b3486ad

Browse files
iakov-awssouvanga
andauthored
Add license manager (#149)
* Feat: Gets Marketplace Licensing and Grants information across AWS Organization. Lambda gets Licenses from License Manager and stores it in Amazon S3. Glue crawler crawls through the data and creates Athena Tables. Template also creates Athena view which will be used in Amazon QuickSight dashboard. * refactoring licence-manager module * Readme and other fixes --------- Co-authored-by: Soumya Vanga <[email protected]>
1 parent d172713 commit b3486ad

File tree

7 files changed

+410
-1
lines changed

7 files changed

+410
-1
lines changed

data-collection/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ List of modules and objects collected:
3333
| `ecs-chargeback` | Amazon ECS | Linked Account | |
3434
| `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) |
3535
| `cost-optimization-hub` | AWS Cost Optimization Hub | Management Account | Collects Detailed Reccomendations. Requires [activation](https://aws.amazon.com/aws-cost-management/cost-optimization-hub/faqs/#:~:text=You%20can%20enable%20Cost%20Optimization%20Hub%20by%20going%20to%20the,navigation%20bar%2C%20and%20click%20Enable.) |
36+
| `health-evetns` | AWS Health | Management Accounts | Collect AWS Health notificaitons via AWS Organizational view |
37+
| `licence-manager` | AWS License Manager | Management Accounts | Collect Licences and Grants |
3638

3739

3840

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Metadata:
3333
- IncludeTAModule
3434
- IncludeTransitGatewayModule
3535
- IncludeAWSFeedsModule
36+
- IncludeLicenseManagerModule
3637
ParameterLabels:
3738
DestinationBucket:
3839
default: 'Destination S3 bucket'
@@ -82,6 +83,8 @@ Metadata:
8283
default: 'Include AWS Feeds Module'
8384
IncludeHealthEventsModule:
8485
default: 'Include AWS Health Events Module'
86+
IncludeLicenseManagerModule:
87+
default: 'Include Marketplace Licensing Collection'
8588

8689
Mappings:
8790
RegionMap:
@@ -105,7 +108,7 @@ Mappings:
105108
StepFunctionCode:
106109
main-v1: {TemplatePath: cfn/data-collection/source/step-functions/main-state-machine-v1.json}
107110
crawler-v1: {TemplatePath: cfn/data-collection/source/step-functions/crawler-state-machine-v1.json}
108-
awsfeeds-v1: {TemplatePath: cfn/data-collection/source/step-functions/awsfeeds-state-machine-v1.json}
111+
awsfeeds-v1: {TemplatePath: cfn/data-collection/source/step-functions/awsfeeds-state-machine-v1.json}
109112

110113
Parameters:
111114
DestinationBucket:
@@ -235,6 +238,12 @@ Parameters:
235238
AllowedValues:
236239
- "yes"
237240
- "no"
241+
IncludeLicenseManagerModule:
242+
Type: String
243+
Description: Collects Marketplace Licenses and Grants
244+
AllowedValues:
245+
- "yes"
246+
- "no"
238247

239248
Outputs:
240249
S3Bucket:
@@ -262,6 +271,7 @@ Conditions:
262271
DeployCostOptimizationHubModule: !Equals [ !Ref IncludeCostOptimizationHubModule, "yes"]
263272
DeployAWSFeedsModule: !Equals [ !Ref IncludeAWSFeedsModule, "yes"]
264273
DeployHealthEventsModule: !Equals [ !Ref IncludeHealthEventsModule, "yes"]
274+
DeployLicenseManagerModule: !Equals [ !Ref IncludeLicenseManagerModule, "yes"]
265275
DeployPricingModule: !Or
266276
- !Condition DeployInventoryCollectorModule
267277
- !Condition DeployRDSUtilizationModule
@@ -281,6 +291,7 @@ Conditions:
281291
- !Condition DeployTransitGatewayModule
282292
- !Condition DeployCostOptimizationHubModule
283293
- !Condition DeployHealthEventsModule
294+
- !Condition DeployLicenseManagerModule
284295
RegionsInScopeIsEmpty: !Equals
285296
- !Join [ '', !Split [ ' ', !Ref RegionsInScope ] ] # remove spaces
286297
- ""
@@ -874,6 +885,7 @@ Resources:
874885
Properties:
875886
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-trusted-advisor.yaml"
876887
Parameters:
888+
DatabaseName: !Ref DatabaseName
877889
DestinationBucket: !Ref S3Bucket
878890
DestinationBucketARN: !GetAtt S3Bucket.Arn
879891
GlueRoleARN: !GetAtt GlueRole.Arn
@@ -893,6 +905,7 @@ Resources:
893905
Properties:
894906
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-cost-explorer-rightsizing.yaml"
895907
Parameters:
908+
DatabaseName: !Ref DatabaseName
896909
DestinationBucket: !Ref S3Bucket
897910
DestinationBucketARN: !GetAtt S3Bucket.Arn
898911
ManagementRoleName: !Sub "${ResourcePrefix}${ManagementAccountRole}"
@@ -912,6 +925,7 @@ Resources:
912925
Properties:
913926
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-cost-optimization-hub.yaml"
914927
Parameters:
928+
DatabaseName: !Ref DatabaseName
915929
DestinationBucket: !Ref S3Bucket
916930
DestinationBucketARN: !GetAtt S3Bucket.Arn
917931
ManagementRoleName: !Sub "${ResourcePrefix}${ManagementAccountRole}"
@@ -931,6 +945,7 @@ Resources:
931945
Properties:
932946
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-cost-anomaly.yaml"
933947
Parameters:
948+
DatabaseName: !Ref DatabaseName
934949
DestinationBucket: !Ref S3Bucket
935950
DestinationBucketARN: !GetAtt S3Bucket.Arn
936951
ManagementRoleName: !Sub "${ResourcePrefix}${ManagementAccountRole}"
@@ -950,6 +965,7 @@ Resources:
950965
Properties:
951966
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-backup.yaml"
952967
Parameters:
968+
DatabaseName: !Ref DatabaseName
953969
DestinationBucket: !Ref S3Bucket
954970
DestinationBucketARN: !GetAtt S3Bucket.Arn
955971
ManagementRoleName: !Sub "${ResourcePrefix}${ManagementAccountRole}"
@@ -969,6 +985,7 @@ Resources:
969985
Properties:
970986
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-inventory.yaml"
971987
Parameters:
988+
DatabaseName: !Ref DatabaseName
972989
DestinationBucket: !Ref S3Bucket
973990
DestinationBucketARN: !GetAtt S3Bucket.Arn
974991
GlueRoleARN: !GetAtt GlueRole.Arn
@@ -994,6 +1011,7 @@ Resources:
9941011
Properties:
9951012
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-pricing.yaml"
9961013
Parameters:
1014+
DatabaseName: !Ref DatabaseName
9971015
DestinationBucket: !Ref S3Bucket
9981016
DestinationBucketARN: !GetAtt S3Bucket.Arn
9991017
GlueRoleARN: !GetAtt GlueRole.Arn
@@ -1039,6 +1057,7 @@ Resources:
10391057
Properties:
10401058
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-ecs-chargeback.yaml"
10411059
Parameters:
1060+
DatabaseName: !Ref DatabaseName
10421061
DestinationBucket: !Ref S3Bucket
10431062
DestinationBucketARN: !GetAtt S3Bucket.Arn
10441063
GlueRoleARN: !GetAtt GlueRole.Arn
@@ -1063,6 +1082,7 @@ Resources:
10631082
Properties:
10641083
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-rds-usage.yaml"
10651084
Parameters:
1085+
DatabaseName: !Ref DatabaseName
10661086
DestinationBucket: !Ref S3Bucket
10671087
DestinationBucketARN: !GetAtt S3Bucket.Arn
10681088
GlueRoleARN: !GetAtt GlueRole.Arn
@@ -1087,6 +1107,7 @@ Resources:
10871107
Properties:
10881108
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-organization.yaml"
10891109
Parameters:
1110+
DatabaseName: !Ref DatabaseName
10901111
DestinationBucket: !Ref S3Bucket
10911112
DestinationBucketARN: !GetAtt S3Bucket.Arn
10921113
GlueRoleARN: !GetAtt GlueRole.Arn
@@ -1106,6 +1127,7 @@ Resources:
11061127
Properties:
11071128
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-budgets.yaml"
11081129
Parameters:
1130+
DatabaseName: !Ref DatabaseName
11091131
DestinationBucket: !Ref S3Bucket
11101132
DestinationBucketARN: !GetAtt S3Bucket.Arn
11111133
GlueRoleARN: !GetAtt GlueRole.Arn
@@ -1125,6 +1147,7 @@ Resources:
11251147
Properties:
11261148
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-transit-gateway.yaml"
11271149
Parameters:
1150+
DatabaseName: !Ref DatabaseName
11281151
DestinationBucket: !Ref S3Bucket
11291152
DestinationBucketARN: !GetAtt S3Bucket.Arn
11301153
GlueRoleARN: !GetAtt GlueRole.Arn
@@ -1149,6 +1172,7 @@ Resources:
11491172
Properties:
11501173
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-aws-feeds.yaml"
11511174
Parameters:
1175+
DatabaseName: !Ref DatabaseName
11521176
DestinationBucket: !Ref S3Bucket
11531177
DestinationBucketARN: !GetAtt S3Bucket.Arn
11541178
Schedule: !Ref ScheduleFrequent
@@ -1166,6 +1190,7 @@ Resources:
11661190
Properties:
11671191
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-health-events.yaml"
11681192
Parameters:
1193+
DatabaseName: !Ref DatabaseName
11691194
DestinationBucket: !Ref S3Bucket
11701195
DestinationBucketARN: !GetAtt S3Bucket.Arn
11711196
Schedule: !Ref ScheduleFrequent
@@ -1179,6 +1204,26 @@ Resources:
11791204
StepFunctionExecutionRoleARN: !GetAtt StepFunctionExecutionRole.Arn
11801205
SchedulerExecutionRoleARN: !GetAtt SchedulerExecutionRole.Arn
11811206

1207+
LicenseManagerModule:
1208+
Type: AWS::CloudFormation::Stack
1209+
Condition: DeployLicenseManagerModule
1210+
Properties:
1211+
TemplateURL: !Sub "https://${CFNSourceBucket}.s3.amazonaws.com/cfn/data-collection/module-license-manager.yaml"
1212+
Parameters:
1213+
DatabaseName: !Ref DatabaseName
1214+
DestinationBucket: !Ref S3Bucket
1215+
DestinationBucketARN: !GetAtt S3Bucket.Arn
1216+
ManagementRoleName: !Sub "${ResourcePrefix}${ManagementAccountRole}"
1217+
Schedule: !Ref Schedule
1218+
GlueRoleARN: !GetAtt GlueRole.Arn
1219+
ResourcePrefix: !Ref ResourcePrefix
1220+
LambdaAnalyticsARN: !GetAtt LambdaAnalytics.Arn
1221+
AccountCollectorLambdaARN: !Sub "${AccountCollector.Outputs.LambdaFunctionARN}"
1222+
CodeBucket: !If [ ProdCFNTemplateUsed, !FindInMap [RegionMap, !Ref "AWS::Region", CodeBucket], !Ref CFNSourceBucket ]
1223+
StepFunctionTemplate: !FindInMap [StepFunctionCode, main-v1, TemplatePath]
1224+
StepFunctionExecutionRoleARN: !GetAtt StepFunctionExecutionRole.Arn
1225+
SchedulerExecutionRoleARN: !GetAtt SchedulerExecutionRole.Arn
1226+
11821227
AccountCollector:
11831228
Type: AWS::CloudFormation::Stack
11841229
Condition: DeployAccountCollector

data-collection/deploy/deploy-data-read-permissions.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Metadata:
2828
- IncludeRightsizingModule
2929
- IncludeTAModule
3030
- IncludeTransitGatewayModule
31+
- IncludeLicenseManagerModule
3132
ParameterLabels:
3233
ManagementAccountRole:
3334
default: "Management account role"
@@ -67,6 +68,8 @@ Metadata:
6768
default: "Include Cost Optimization Hub Module"
6869
IncludeHealthEventsModule:
6970
default: "Include AWS Health Events Module"
71+
IncludeLicenseManagerModule:
72+
default: "Include Marketplace Licensing Module"
7073
Parameters:
7174
ManagementAccountRole:
7275
Type: String
@@ -169,6 +172,12 @@ Parameters:
169172
AllowedValues:
170173
- "yes"
171174
- "no"
175+
IncludeLicenseManagerModule:
176+
Type: String
177+
Description: Collects Marketplace Licensing information
178+
AllowedValues:
179+
- "yes"
180+
- "no"
172181

173182
Conditions:
174183
DeployModuleReadInMgmt: !Equals [!Ref AllowModuleReadInMgmt, "yes"]
@@ -188,6 +197,7 @@ Resources:
188197
IncludeBackupModule: !Ref IncludeBackupModule
189198
IncludeCostOptimizationHubModule: !Ref IncludeCostOptimizationHubModule
190199
IncludeHealthEventsModule: !Ref IncludeHealthEventsModule
200+
IncludeLicenseManagerModule: !Ref IncludeLicenseManagerModule
191201
DataCollectorMgmtAccountModulesReadStack:
192202
Type: AWS::CloudFormation::Stack
193203
Condition: DeployModuleReadInMgmt

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Metadata:
1818
- IncludeCostOptimizationHubModule
1919
- IncludeHealthEventsModule
2020
- IncludeRightsizingModule
21+
- IncludeLicenseManagerModule
2122
ParameterLabels:
2223
ManagementAccountRole:
2324
default: "Management account role"
@@ -37,6 +38,8 @@ Metadata:
3738
default: "Include EnableCostOptimizationHub Module"
3839
IncludeHealthEventsModule:
3940
default: "Include Health Events Module"
41+
IncludeLicenseManagerModule:
42+
default: "Include Marketplace Licensing Module"
4043
Parameters:
4144
DataCollectionAccountID:
4245
Type: String
@@ -85,6 +88,12 @@ Parameters:
8588
AllowedValues:
8689
- "yes"
8790
- "no"
91+
IncludeLicenseManagerModule:
92+
Type: String
93+
Description: Collects Marketplace Licensing Information from your accounts
94+
AllowedValues:
95+
- "yes"
96+
- "no"
8897

8998
Conditions:
9099
EnableComputeOptimizerModule: !Equals [!Ref IncludeComputeOptimizerModule, "yes"]
@@ -93,6 +102,7 @@ Conditions:
93102
EnableBackupModule: !Equals [!Ref IncludeBackupModule, "yes"]
94103
EnableCostOptimizationHubModule: !Equals [!Ref IncludeCostOptimizationHubModule, "yes"]
95104
EnableHealthEventsModule: !Equals [!Ref IncludeHealthEventsModule, "yes"]
105+
EnableLicenceManagerModule: !Equals [!Ref IncludeLicenseManagerModule, "yes"]
96106

97107
Outputs:
98108
LambdaRole:
@@ -123,6 +133,7 @@ Resources:
123133
- !Sub "arn:aws:iam::${DataCollectionAccountID}:role/${ResourcePrefix}cost-optimization-hub-LambdaRole"
124134
- !Sub "arn:aws:iam::${DataCollectionAccountID}:role/${ResourcePrefix}backup-LambdaRole"
125135
- !Sub "arn:aws:iam::${DataCollectionAccountID}:role/${ResourcePrefix}health-events-LambdaRole"
136+
- !Sub "arn:aws:iam::${DataCollectionAccountID}:role/${ResourcePrefix}license-manager-LambdaRole"
126137
Path: /
127138
Metadata:
128139
cfn_nag:
@@ -402,3 +413,24 @@ Resources:
402413
rules_to_suppress:
403414
- id: W12
404415
reason: "Policy is used for scanning of a wide range of resources"
416+
LicenceManagerPolicy:
417+
Type: "AWS::IAM::Policy"
418+
Condition: EnableLicenceManagerModule
419+
Properties:
420+
PolicyName: LicenceManagerPolicy
421+
PolicyDocument:
422+
Version: "2012-10-17"
423+
Statement:
424+
- Effect: "Allow"
425+
Action:
426+
- "license-manager:ListReceivedGrants"
427+
- "license-manager:ListReceivedLicenses"
428+
- "license-manager:ListReceivedGrantsForOrganization"
429+
Resource: "*"
430+
Roles:
431+
- Ref: LambdaRole
432+
Metadata:
433+
cfn_nag:
434+
rules_to_suppress:
435+
- id: W12
436+
reason: "Policy is used for scanning of a wide range of resources"

0 commit comments

Comments
 (0)