Skip to content

Commit f857421

Browse files
committed
Merge branch 'main' into instrumentation
2 parents 05717cb + 1d6678a commit f857421

13 files changed

+262
-239
lines changed

data-collection/deploy/account-collector.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ Parameters:
2222
Type: String
2323
Description: "ARNs of KMS Keys for data buckets and/or Glue Catalog. Comma separated list, no spaces. Keep empty if data Buckets and Glue Catalog are not Encrypted with KMS. You can also set it to '*' to grant decrypt permission for all the keys."
2424
Default: ""
25+
EUCAccountIDs:
26+
Type: String
27+
Description: "Comma-separated list of account IDs that user has identified to have WorkSpaces running, used to collect WorkSpaces metrics from. If left blank, metrics will be checked from all linked accounts in Organization."
28+
Default: ""
29+
2530
Outputs:
2631
LambdaFunctionName:
2732
Value: !Ref LambdaFunction
@@ -143,6 +148,7 @@ Resources:
143148
LINKED_ACCOUNT_LIST_KEY = os.environ.get('LINKED_ACCOUNT_LIST_KEY', 'linked-account-list.json')
144149
PAYER_ACCOUNT_LIST_KEY = os.environ.get('PAYER_ACCOUNT_LIST_KEY', 'payer-account-list.json')
145150
EXCLUDED_ACCOUNT_LIST_KEY = os.environ.get('EXCLUDED_ACCOUNT_LIST_KEY', 'excluded-linked-account-list.csv')
151+
EUC_ACCOUNTS = os.environ.get('EUC_ACCOUNT_IDS', '').strip()
146152
147153
MODULE = ""
148154
@@ -165,6 +171,7 @@ Resources:
165171
166172
functions = { # keep keys same as boto3 services
167173
'linked': iterate_linked_accounts,
174+
'euc': partial(iterate_accounts_with_filter, EUC_ACCOUNTS),
168175
'payers': partial(iterate_admins_accounts, None),
169176
'organizations': partial(iterate_admins_accounts, 'organizations'),
170177
'compute-optimizer': partial(iterate_admins_accounts, 'compute-optimizer'),
@@ -236,6 +243,8 @@ Resources:
236243
try:
237244
account_id = ssm.get_parameter(Name=ssm_key)['Parameter']['Value']
238245
except ssm.exceptions.ParameterNotFound:
246+
logger.info(f'Not found ssm parameter {ssm_key}. Will use Management Account Id {payer_id}')
247+
yield {"account": json.dumps({'account_id': account_id, 'account_name': '', 'payer_id': payer_id})}
239248
logger.warning(f'Not found ssm parameter {ssm_key}. Will use Management Account Id {payer_id}')
240249
yield {"account": json.dumps({'account_id': account_id, 'account_name': '', 'payer_id': payer_id}), "main_exe_uuid": ""}
241250
@@ -271,6 +280,16 @@ Resources:
271280
yield format_account(account_id, account.get('Name'), payer_id)
272281
logger.info(f'Found {count} accounts for payer {payer_id}')
273282
283+
def iterate_accounts_with_filter(filter_accounts):
284+
''' same as iterate_linked_accounts but with additional filtering
285+
filter_accounts: a comma separated list of accounts OR '*'
286+
'''
287+
for acc in iterate_linked_accounts():
288+
account_id = json.loads(acc['account'])['account_id']
289+
if account_id in filter_accounts.split(',') or filter_accounts.strip() == '*':
290+
yield acc
291+
292+
274293
def get_defined_list(bucket, key):
275294
s3 = boto3.client("s3")
276295
exts = [".json", ".csv"]
@@ -400,6 +419,7 @@ Resources:
400419
PAYER_ACCOUNT_LIST_KEY: "payer-account-list.json"
401420
EXCLUDED_ACCOUNT_LIST_KEY: "excluded-linked-account-list.csv"
402421
DC_ACCOUNT: !Ref AWS::AccountId
422+
EUC_ACCOUNT_IDS: !Ref EUCAccountIDs
403423
Metadata:
404424
cfn_nag:
405425
rules_to_suppress:

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AWSTemplateFormatVersion: '2010-09-09'
2-
Description: CID Data Collection Stack v3.8.0
2+
Description: CID Data Collection Stack v3.9.0
33
Metadata:
44
AWS::CloudFormation::Interface:
55
ParameterGroups:
@@ -30,20 +30,16 @@ Metadata:
3030
- IncludeInventoryCollectorModule
3131
- IncludeOrgDataModule
3232
- IncludeRDSUtilizationModule
33-
- IncludeEUCUtilizationModule
3433
- IncludeRightsizingModule
3534
- IncludeTAModule
3635
- IncludeTransitGatewayModule
3736
- IncludeAWSFeedsModule
3837
- IncludeLicenseManagerModule
3938
- IncludeQuickSightModule
4039
- IncludeServiceQuotasModule
41-
- Label:
42-
default: 'EUC Module Configuration'
43-
Parameters:
4440
- IncludeEUCUtilizationModule
4541
- Label:
46-
default: 'EUC Module Settings'
42+
default: 'EUC (End User Compute) Module Configuration'
4743
Parameters:
4844
- EUCAccountIDs
4945
ParameterLabels:
@@ -225,11 +221,11 @@ Parameters:
225221
Type: String
226222
Description: Collects WorkSpaces CloudWatch metrics from your accounts
227223
AllowedValues: ['yes', 'no']
228-
Default: 'no'
224+
Default: 'no'
229225
EUCAccountIDs:
230226
Type: String
231-
Description: "Optional, If you enable EUC Utilization or Inventory module and you use Amazon WorkSpaces, please provide a comma-separated list of account IDs where WorkSpaces are deployed. If left blank, metrics will be collected from all linked accounts in the Organization."
232-
Default: ""
227+
Description: "Optional, If you enable EUC Utilization or Inventory module and you use Amazon WorkSpaces, please provide a comma-separated list of account IDs where WorkSpaces are deployed. Or you can set * to collect from all linked accounts in the Organization."
228+
Default: "*"
233229
IncludeOrgDataModule:
234230
Type: String
235231
Description: Collects AWS Organizations data such as account Id, account name, organization parent and specified tags
@@ -1259,7 +1255,6 @@ Resources:
12591255
StepFunctionTemplate: !FindInMap [StepFunctionCode, main-state-machine-v4, TemplatePath]
12601256
StepFunctionExecutionRoleARN: !GetAtt StepFunctionExecutionRole.Arn
12611257
SchedulerExecutionRoleARN: !GetAtt SchedulerExecutionRole.Arn
1262-
EUCAccountIDs: !Ref EUCAccountIDs
12631258
RegionsInScope:
12641259
Fn::If:
12651260
- RegionsInScopeIsEmpty
@@ -1453,6 +1448,7 @@ Resources:
14531448
DestinationBucket: !Ref S3Bucket
14541449
DestinationBucketARN: !GetAtt S3Bucket.Arn
14551450
DataBucketsKmsKeysArns: !Ref DataBucketsKmsKeysArns
1451+
EUCAccountIDs: !Ref EUCAccountIDs
14561452

14571453
DataCollectionReadAccess:
14581454
Type: AWS::IAM::ManagedPolicy

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AWSTemplateFormatVersion: "2010-09-09"
2-
Description: CID Data Collection - All-in-One for Management Account v3.8.0
2+
Description: CID Data Collection - All-in-One for Management Account v3.9.0
33
Metadata:
44
AWS::CloudFormation::Interface:
55
ParameterGroups:
@@ -196,7 +196,6 @@ Resources:
196196
ResourcePrefix: !Ref ResourcePrefix
197197
IncludeComputeOptimizerModule: !Ref IncludeComputeOptimizerModule
198198
IncludeCostAnomalyModule: !Ref IncludeCostAnomalyModule
199-
IncludeSupportCasesModule: !Ref IncludeSupportCasesModule
200199
IncludeRightsizingModule: !Ref IncludeRightsizingModule
201200
IncludeBackupModule: !Ref IncludeBackupModule
202201
IncludeHealthEventsModule: !Ref IncludeHealthEventsModule
@@ -216,14 +215,14 @@ Resources:
216215
IncludeInventoryCollectorModule: !Ref IncludeInventoryCollectorModule
217216
IncludeECSChargebackModule: !Ref IncludeECSChargebackModule
218217
IncludeRDSUtilizationModule: !Ref IncludeRDSUtilizationModule
219-
IncludeEUCUtilizationModule: !Ref IncludeEUCUtilizationModule
218+
IncludeEUCUtilizationModule: !Ref IncludeEUCUtilizationModule
220219
IncludeBudgetsModule: !Ref IncludeBudgetsModule
221220
IncludeTransitGatewayModule: !Ref IncludeTransitGatewayModule
222221
IncludeServiceQuotasModule: !Ref IncludeServiceQuotasModule
223222
DataCollectorOrgAccountModulesReadStackSet:
224223
Type: AWS::CloudFormation::StackSet
225224
Properties:
226-
Description: "StackSet in charge of deploying read roles across organization accounts v3.8.0"
225+
Description: "StackSet in charge of deploying read roles across organization accounts v3.9.0"
227226
PermissionModel: SERVICE_MANAGED
228227
AutoDeployment:
229228
Enabled: true
@@ -252,7 +251,7 @@ Resources:
252251
- ParameterKey: IncludeRDSUtilizationModule
253252
ParameterValue: !Ref IncludeRDSUtilizationModule
254253
- ParameterKey: IncludeEUCUtilizationModule
255-
ParameterValue: !Ref IncludeEUCUtilizationModule
254+
ParameterValue: !Ref IncludeEUCUtilizationModule
256255
- ParameterKey: IncludeBudgetsModule
257256
ParameterValue: !Ref IncludeBudgetsModule
258257
- ParameterKey: IncludeTransitGatewayModule

0 commit comments

Comments
 (0)