-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update
aws_cloudtrail_trail_event_selectors
schema
- Loading branch information
1 parent
95bf4bd
commit 0d5539f
Showing
3 changed files
with
23 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 11 additions & 3 deletions
14
transformations/aws_compliance/models/shared/aws_compliance__log_metric_filter_and_alarm.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
with af as ( | ||
select distinct a.arn, a.actions_enabled, a.alarm_actions, m->'MetricStat'->'Metric'->>'MetricName' as metric_name -- TODO check | ||
from aws_cloudwatch_alarms a, jsonb_array_elements(a.metrics) as m | ||
), | ||
tes as ( | ||
select trail_arn from aws_cloudtrail_trail_event_selectors | ||
where exists( | ||
select * from jsonb_array_elements(event_selectors) as es | ||
where es ->>'ReadWriteType' = 'All' and (es->>'IncludeManagementEvents')::boolean = TRUE | ||
) or exists( | ||
select * from jsonb_array_elements(advanced_event_selectors) as aes | ||
where not exists(select * from jsonb_array_elements(aes ->'FieldSelectors') as aes_fs where aes_fs ->>'Field' = 'readOnly') | ||
) | ||
) | ||
select | ||
t.account_id, | ||
t.region, | ||
t.cloud_watch_logs_log_group_arn, | ||
mf.filter_pattern as pattern | ||
from aws_cloudtrail_trails t | ||
inner join aws_cloudtrail_trail_event_selectors tes on t.arn = tes.trail_arn | ||
inner join tes on t.arn = tes.trail_arn | ||
inner join aws_cloudwatchlogs_metric_filters mf on mf.log_group_name = t.cloudwatch_logs_log_group_name | ||
inner join af on mf.filter_name = af.metric_name | ||
inner join aws_sns_subscriptions ss on ss.topic_arn = ANY(af.alarm_actions) | ||
where t.is_multi_region_trail = TRUE | ||
and (t.status->>'IsLogging')::boolean = TRUE | ||
and tes.include_management_events = TRUE | ||
and tes.read_write_type = 'All' | ||
and ss.arn like 'aws:arn:%' |