Table: aws_guardduty_detectors

This table shows data for Amazon GuardDuty Detectors.

https://docs.aws.amazon.com/guardduty/latest/APIReference/API_GetDetector.html (opens in a new tab)

The composite primary key for this table is (account_id, region, id).

Relations

The following tables depend on aws_guardduty_detectors:

Columns

NameType
_cq_iduuid
_cq_parent_iduuid
account_id (PK)utf8
region (PK)utf8
arnutf8
id (PK)utf8
service_roleutf8
statusutf8
created_attimestamp[us, tz=UTC]
data_sourcesjson
featuresjson
finding_publishing_frequencyutf8
tagsjson
updated_attimestamp[us, tz=UTC]
result_metadatajson

Example Queries

These SQL queries are sampled from CloudQuery policies and are compatible with PostgreSQL.

GuardDuty should be enabled

WITH
  enabled_detector_regions
    AS (
      SELECT
        account_id, region
      FROM
        aws_guardduty_detectors
      WHERE
        status = 'ENABLED'
    )
SELECT
  'GuardDuty should be enabled' AS title,
  r.account_id,
  r.region AS resource_id,
  CASE
  WHEN enabled = true AND e.region IS NULL THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  aws_regions AS r
  LEFT JOIN enabled_detector_regions AS e ON
      e.region = r.region AND e.account_id = r.account_id
UNION
  SELECT
    'GuardDuty should be enabled (detectors)' AS title,
    account_id,
    region AS resource_id,
    CASE
    WHEN data_sources->'S3Logs'->>'Status' != 'ENABLED'
    AND data_sources->'DNSLogs'->>'Status' != 'ENABLED'
    AND data_sources->'CloudTrail'->>'Status' != 'ENABLED'
    AND data_sources->'FlowLogs'->>'Status' != 'ENABLED'
    THEN 'fail'
    ELSE 'pass'
    END
      AS status
  FROM
    aws_guardduty_detectors
  WHERE
    status = 'ENABLED';