Skip to content

Commit a8890c9

Browse files
committed
temp re-order operations for bug
1 parent 401ee98 commit a8890c9

File tree

1 file changed

+34
-32
lines changed
  • aws_sra_examples/solutions/guardduty/guardduty_org/lambda/src

1 file changed

+34
-32
lines changed

aws_sra_examples/solutions/guardduty/guardduty_org/lambda/src/app.py

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,40 @@ def process_create_update_event(params: dict, regions: list) -> None:
201201
detectors_exist = False
202202
run_count = 0
203203

204+
# temp move while loop around to configure GD first 061324
205+
# else:
206+
auto_enable_s3_logs = (params.get("AUTO_ENABLE_S3_LOGS", "false")).lower() in "true"
207+
enable_eks_audit_logs = (params.get("ENABLE_EKS_AUDIT_LOGS", "false")).lower() in "true"
208+
auto_enable_malware_protection = (params.get("AUTO_ENABLE_MALWARE_PROTECTION", "false")).lower() in "true"
209+
enable_rds_login_events = (params.get("ENABLE_RDS_LOGIN_EVENTS", "false")).lower() in "true"
210+
enable_eks_addon_management = (params.get("ENABLE_EKS_ADDON_MANAGEMENT", "false")).lower() in "true"
211+
enable_lambda_network_logs = (params.get("ENABLE_LAMBDA_NETWORK_LOGS", "false")).lower() in "true"
212+
enable_runtime_monitoring = (params.get("ENABLE_RUNTIME_MONITORING", "false")).lower() in "true"
213+
enable_ecs_fargate_agent_management = (params.get("ENABLE_ECS_FARGATE_AGENT_MANAGEMENT", "false")).lower() in "true"
214+
enable_ec2_agent_management = (params.get("ENABLE_EC2_AGENT_MANAGEMENT", "false")).lower() in "true"
215+
216+
gd_features = {
217+
"S3_DATA_EVENTS": auto_enable_s3_logs,
218+
"EKS_AUDIT_LOGS": enable_eks_audit_logs,
219+
"EBS_MALWARE_PROTECTION": auto_enable_malware_protection,
220+
"RDS_LOGIN_EVENTS": enable_rds_login_events,
221+
"LAMBDA_NETWORK_LOGS": enable_lambda_network_logs,
222+
"RUNTIME_MONITORING": enable_runtime_monitoring,
223+
"EKS_ADDON_MANAGEMENT": enable_eks_addon_management,
224+
"ECS_FARGATE_AGENT_MANAGEMENT": enable_ecs_fargate_agent_management,
225+
"EC2_AGENT_MANAGEMENT": enable_ec2_agent_management,
226+
}
227+
228+
guardduty.configure_guardduty(
229+
session,
230+
params["DELEGATED_ADMIN_ACCOUNT_ID"],
231+
gd_features,
232+
regions,
233+
params.get("FINDING_PUBLISHING_FREQUENCY", "FIFTEEN_MINUTES"),
234+
params["KMS_KEY_ARN"],
235+
params["PUBLISHING_DESTINATION_BUCKET_ARN"],
236+
)
237+
204238
while not detectors_exist and run_count < MAX_RUN_COUNT:
205239
run_count += 1
206240
detectors_exist = guardduty.check_for_detectors(session, regions)
@@ -210,38 +244,6 @@ def process_create_update_event(params: dict, regions: list) -> None:
210244

211245
if not detectors_exist:
212246
raise ValueError("GuardDuty Detectors did not get created in the allowed time. Check the Org Management delegated admin setup.")
213-
else:
214-
auto_enable_s3_logs = (params.get("AUTO_ENABLE_S3_LOGS", "false")).lower() in "true"
215-
enable_eks_audit_logs = (params.get("ENABLE_EKS_AUDIT_LOGS", "false")).lower() in "true"
216-
auto_enable_malware_protection = (params.get("AUTO_ENABLE_MALWARE_PROTECTION", "false")).lower() in "true"
217-
enable_rds_login_events = (params.get("ENABLE_RDS_LOGIN_EVENTS", "false")).lower() in "true"
218-
enable_eks_addon_management = (params.get("ENABLE_EKS_ADDON_MANAGEMENT", "false")).lower() in "true"
219-
enable_lambda_network_logs = (params.get("ENABLE_LAMBDA_NETWORK_LOGS", "false")).lower() in "true"
220-
enable_runtime_monitoring = (params.get("ENABLE_RUNTIME_MONITORING", "false")).lower() in "true"
221-
enable_ecs_fargate_agent_management = (params.get("ENABLE_ECS_FARGATE_AGENT_MANAGEMENT", "false")).lower() in "true"
222-
enable_ec2_agent_management = (params.get("ENABLE_EC2_AGENT_MANAGEMENT", "false")).lower() in "true"
223-
224-
gd_features = {
225-
"S3_DATA_EVENTS": auto_enable_s3_logs,
226-
"EKS_AUDIT_LOGS": enable_eks_audit_logs,
227-
"EBS_MALWARE_PROTECTION": auto_enable_malware_protection,
228-
"RDS_LOGIN_EVENTS": enable_rds_login_events,
229-
"LAMBDA_NETWORK_LOGS": enable_lambda_network_logs,
230-
"RUNTIME_MONITORING": enable_runtime_monitoring,
231-
"EKS_ADDON_MANAGEMENT": enable_eks_addon_management,
232-
"ECS_FARGATE_AGENT_MANAGEMENT": enable_ecs_fargate_agent_management,
233-
"EC2_AGENT_MANAGEMENT": enable_ec2_agent_management,
234-
}
235-
236-
guardduty.configure_guardduty(
237-
session,
238-
params["DELEGATED_ADMIN_ACCOUNT_ID"],
239-
gd_features,
240-
regions,
241-
params.get("FINDING_PUBLISHING_FREQUENCY", "FIFTEEN_MINUTES"),
242-
params["KMS_KEY_ARN"],
243-
params["PUBLISHING_DESTINATION_BUCKET_ARN"],
244-
)
245247

246248

247249
def process_sns_records(records: list) -> None:

0 commit comments

Comments
 (0)