Control: GuardDuty EC2 runtime monitoring should be enabled
Description
This control checks whether the Amazon GuardDuty automated security agent is enabled for runtime monitoring of Amazon EC2 instances. For a standalone account, the control fails if the security agent is disabled for the account. In a multi-account environment, the control fails if the security agent is disabled for the delegated GuardDuty administrator account and all member accounts.
Usage
Run the control in your terminal:
powerpipe control run aws_compliance.control.guardduty_detector_ec2_runtime_monitoring_enabledSnapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run aws_compliance.control.guardduty_detector_ec2_runtime_monitoring_enabled --shareSQL
This control uses a named query:
with ec2_runtime_monitoring as (  select    arn  from    aws_guardduty_detector,    jsonb_array_elements(features) as f,    jsonb_array_elements(f -> 'AdditionalConfiguration') as c  where    f ->> 'Name' = 'RUNTIME_MONITORING'    and c ->> 'Name' = 'EC2_AGENT_MANAGEMENT'    and c ->> 'Status' = 'ENABLED')select  d.arn as resource,  case    when m.arn is not null then 'ok'    else 'alarm'  end as status,  case    when m.arn is not null then title || ' has EC2 runtime monitoring enabled.'    else title || ' has EC2 runtime monitoring disabled.'  end as reason    , region, account_idfrom  aws_guardduty_detector as d  left join ec2_runtime_monitoring as m on m.arn = d.arn