Skip to content

Commit 1fde781

Browse files
authored
Revert "Instrumentation phase 1 (#275)" (#356)
This reverts commit 7746a4d.
1 parent 8702b42 commit 1fde781

28 files changed

+136
-1542
lines changed

data-collection/deploy/account-collector.yaml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ Resources:
128128
ZipFile: |
129129
import os
130130
import json
131-
import uuid
132131
import logging
133-
from datetime import datetime
134132
from functools import partial
135133
136134
import boto3
@@ -143,7 +141,6 @@ Resources:
143141
EXCLUDED_ACCOUNT_LIST_KEY = os.environ.get('EXCLUDED_ACCOUNT_LIST_KEY')
144142
EUC_ACCOUNTS = os.environ.get('EUC_ACCOUNT_IDS', '').strip()
145143
TMP_FILE = "/tmp/data.json"
146-
START_TIME = str(datetime.now().isoformat())
147144
148145
logger = logging.getLogger(__name__)
149146
logger.setLevel(getattr(logging, os.environ.get('LOG_LEVEL', 'INFO').upper(), logging.INFO))
@@ -167,7 +164,7 @@ Resources:
167164
'compute-optimizer': partial(iterate_admins_accounts, 'compute-optimizer'),
168165
'backup': partial(iterate_admins_accounts, 'backup'),
169166
}
170-
account_type = event.get("type", '').lower()
167+
account_type = event.get("Type", '').lower()
171168
if account_type not in functions:
172169
raise Exception(f"Lambda event must have 'Type' parameter with value = ({list(functions.keys())})") #pylint: disable=broad-exception-raised
173170
@@ -176,14 +173,6 @@ Resources:
176173
count = 0
177174
f.write("[\n")
178175
for account in account_iterator():
179-
account['main_exe_uuid'] = event.get("main_exe_uuid", str(uuid.uuid4()))
180-
account['module'] = event.get("module", '').lower()
181-
account['bucket'] = BUCKET
182-
account['dc_account'] = boto3.client('sts').get_caller_identity()['Account']
183-
account['dc_region'] = boto3.session.Session().region_name
184-
account['params'] = event.get("params", '')
185-
account['prefix'] = RESOURCE_PREFIX
186-
account['stack_version'] = event.get("stack_version", '')
187176
if count > 0:
188177
f.write(",\n")
189178
f.write(json.dumps(account))
@@ -296,7 +285,6 @@ Resources:
296285
aws_secret_access_key=credentials['SecretAccessKey'],
297286
aws_session_token=credentials['SessionToken'],
298287
)
299-
300288
Handler: 'index.lambda_handler'
301289
MemorySize: 2688
302290
Timeout: 600
@@ -310,7 +298,6 @@ Resources:
310298
PREDEF_ACCOUNT_LIST_KEY: "account-list/account-list"
311299
EXCLUDED_ACCOUNT_LIST_KEY: "account-list/excluded-linked-account-list.csv"
312300
EUC_ACCOUNT_IDS: !Ref EUCAccountIDs
313-
314301
Metadata:
315302
cfn_nag:
316303
rules_to_suppress:
@@ -323,4 +310,4 @@ Resources:
323310
Type: AWS::Logs::LogGroup
324311
Properties:
325312
LogGroupName: !Sub "/aws/lambda/${LambdaFunction}"
326-
RetentionInDays: 60
313+
RetentionInDays: 60

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

Lines changed: 27 additions & 97 deletions
Large diffs are not rendered by default.

data-collection/deploy/module-aws-feeds.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,4 +932,4 @@ Resources:
932932
Type: Custom::LambdaAnalyticsExecutor
933933
Properties:
934934
ServiceToken: !Ref LambdaAnalyticsARN
935-
Name: !Ref CFDataName
935+
Name: !Ref CFDataName

data-collection/deploy/module-backup.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ Resources:
320320
DeployRegion: !Ref AWS::Region
321321
Account: !Ref AWS::AccountId
322322
Prefix: !Ref ResourcePrefix
323-
Bucket: !Ref DestinationBucket
324323
'RefreshSchedule${AwsObject}':
325324
Type: AWS::Scheduler::Schedule
326325
Properties:
@@ -339,4 +338,4 @@ Resources:
339338
Type: Custom::LambdaAnalyticsExecutor
340339
Properties:
341340
ServiceToken: !Ref LambdaAnalyticsARN
342-
Name: !Ref CFDataName
341+
Name: !Ref CFDataName

data-collection/deploy/module-budgets.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ Resources:
290290
DeployRegion: !Ref AWS::Region
291291
Account: !Ref AWS::AccountId
292292
Prefix: !Ref ResourcePrefix
293-
Bucket: !Ref DestinationBucket
294293

295294
ModuleRefreshSchedule:
296295
Type: 'AWS::Scheduler::Schedule'

data-collection/deploy/module-compute-optimizer.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ Resources:
501501
DeployRegion: !Ref AWS::Region
502502
Account: !Ref AWS::AccountId
503503
Prefix: !Ref ResourcePrefix
504-
Bucket: !Ref DestinationBucket
505504

506505
ModuleRefreshSchedule:
507506
Type: 'AWS::Scheduler::Schedule'

data-collection/deploy/module-cost-anomaly.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ Resources:
425425
DeployRegion: !Ref AWS::Region
426426
Account: !Ref AWS::AccountId
427427
Prefix: !Ref ResourcePrefix
428-
Bucket: !Ref DestinationBucket
429428

430429
ModuleRefreshSchedule:
431430
Type: "AWS::Scheduler::Schedule"

data-collection/deploy/module-cost-explorer-rightsizing.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ Resources:
262262
DeployRegion: !Ref AWS::Region
263263
Account: !Ref AWS::AccountId
264264
Prefix: !Ref ResourcePrefix
265-
Bucket: !Ref DestinationBucket
266265

267266
ModuleRefreshSchedule:
268267
Type: 'AWS::Scheduler::Schedule'

data-collection/deploy/module-ecs-chargeback.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ Resources:
274274
DeployRegion: !Ref AWS::Region
275275
Account: !Ref AWS::AccountId
276276
Prefix: !Ref ResourcePrefix
277-
Bucket: !Ref DestinationBucket
278277

279278
ModuleRefreshSchedule:
280279
Type: 'AWS::Scheduler::Schedule'

data-collection/deploy/module-health-events.yaml

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ Parameters:
5151
Type: String
5252
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."
5353
Default: ""
54-
DetailStepFunctionTemplate:
55-
Type: String
56-
Description: JSON representation of the detail retrieval StepFunction template
5754

5855
Conditions:
5956
NeedDataBucketsKms: !Not [ !Equals [ !Ref DataBucketsKmsKeysArns, "" ] ]
@@ -482,7 +479,6 @@ Resources:
482479
DeployRegion: !Ref AWS::Region
483480
Account: !Ref AWS::AccountId
484481
Prefix: !Ref ResourcePrefix
485-
Bucket: !Ref DestinationBucket
486482

487483
ModuleRefreshSchedule:
488484
Type: 'AWS::Scheduler::Schedule'
@@ -501,12 +497,84 @@ Resources:
501497
StepFunctionDetail:
502498
Type: AWS::StepFunctions::StateMachine
503499
Properties:
504-
StateMachineName: !Sub '${ResourcePrefix}${CFDataName}-StateMachine'
500+
StateMachineName: !Sub '${ResourcePrefix}${CFDataName}-detail-StateMachine'
505501
StateMachineType: STANDARD
506502
RoleArn: !Ref StepFunctionExecutionRoleARN
507-
DefinitionS3Location:
508-
Bucket: !Ref CodeBucket
509-
Key: !Ref DetailStepFunctionTemplate
503+
DefinitionString: |
504+
{
505+
"Comment": "Collects Health Events",
506+
"StartAt": "DetailProcessor Map",
507+
"States": {
508+
"DetailProcessor Map": {
509+
"Type": "Map",
510+
"ItemProcessor": {
511+
"ProcessorConfig": {
512+
"Mode": "DISTRIBUTED",
513+
"ExecutionType": "STANDARD"
514+
},
515+
"StartAt": "DetailLambda Invoke",
516+
"States": {
517+
"DetailLambda Invoke": {
518+
"Type": "Task",
519+
"Resource": "arn:${Partition}:states:::lambda:invoke",
520+
"OutputPath": "$.Payload",
521+
"Parameters": {
522+
"Payload.$": "$",
523+
"FunctionName": "${ModuleLambdaARN}"
524+
},
525+
"Retry": [
526+
{
527+
"ErrorEquals": [
528+
"Lambda.ServiceException",
529+
"Lambda.AWSLambdaException",
530+
"Lambda.SdkClientException",
531+
"Lambda.TooManyRequestsException"
532+
],
533+
"IntervalSeconds": 1,
534+
"MaxAttempts": 3,
535+
"BackoffRate": 2
536+
}
537+
],
538+
"End": true
539+
}
540+
}
541+
},
542+
"Label": "DetailProcessorMap",
543+
"MaxConcurrency": ${MaxConcurrentBatches},
544+
"ItemReader": {
545+
"Resource": "arn:${Partition}:states:::s3:getObject",
546+
"ReaderConfig": {
547+
"InputType": "CSV",
548+
"CSVHeaderLocation": "FIRST_ROW"
549+
},
550+
"Parameters": {
551+
"Bucket.$": "$.bucket",
552+
"Key.$": "$.file"
553+
}
554+
},
555+
"ItemBatcher": {
556+
"MaxItemsPerBatch": ${ItemsPerBatch},
557+
"BatchInput": {
558+
"account.$": "$.account",
559+
"ingestion_time.$": "$.ingestion_time"
560+
}
561+
},
562+
"Next": "CrawlerStepFunctionStartExecution"
563+
},
564+
"CrawlerStepFunctionStartExecution": {
565+
"Type": "Task",
566+
"Resource": "arn:${Partition}:states:::states:startExecution.sync:2",
567+
"Parameters": {
568+
"StateMachineArn": "arn:${Partition}:states:${DeployRegion}:${Account}:stateMachine:${Prefix}CrawlerExecution-StateMachine",
569+
"Input": {
570+
"crawlers": ${Crawlers}
571+
}
572+
},
573+
"End": true
574+
}
575+
},
576+
"TimeoutSeconds": 14400
577+
}
510578
DefinitionSubstitutions:
511579
ModuleLambdaARN: !GetAtt LambdaFunction.Arn
512580
Crawlers: !Sub '["${ResourcePrefix}${CFDataName}-detail-Crawler"]'
@@ -519,7 +587,6 @@ Resources:
519587
ItemsPerBatch: 50
520588
MaxConcurrentBatches: 1
521589
Partition: !Ref AWS::Partition
522-
Bucket: !Ref DestinationBucket
523590
Metadata:
524591
cfn-lint:
525592
config:
@@ -529,4 +596,4 @@ Resources:
529596
Type: Custom::LambdaAnalyticsExecutor
530597
Properties:
531598
ServiceToken: !Ref LambdaAnalyticsARN
532-
Name: !Ref CFDataName
599+
Name: !Ref CFDataName

0 commit comments

Comments
 (0)