Control: 3.1 Ensure CloudTrail is enabled in all regions
Description
AWS CloudTrail is a web service that records AWS API calls for your account and delivers log files to you. The recorded information includes the identity of the API caller, the time of the API call, the source IP address of the API caller, the request parameters, and the response elements returned by the AWS service. CloudTrail provides a history of AWS API calls for an account, including API calls made via the Management Console, SDKs, command line tools, and higher-level AWS services (such as CloudFormation).
The AWS API call history produced by CloudTrail enables security analysis, resource change tracking, and compliance auditing. Additionally,
ensuring that a multi-region trail exists will help detect unexpected activity occurring in otherwise unused regions
ensuring that a multi-region trail exists will ensure that
Global Service Loggingis enabled for a trail by default to capture recordings of events generated on AWS global servicesfor a multi-region trail, ensuring that management events are configured for all types of Read/Writes ensures the recording of management operations that are performed on all resources in an AWS account
Remediation
Perform the following to enable global (Multi-region) CloudTrail logging:
From Console
- Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/cloudtrail.
 - Click on 
Trailsin the left navigation pane. - Click 
Get Started Nowif it is presented, then: 
- Click 
Add new trail. - Enter a trail name in the 
Trail namebox. - A trail created in the console is a multi-region trail by default.
 - Specify an S3 bucket name in the 
S3 bucketbox. - Specify the AWS KMS alias under the 
Log file SSE-KMS encryptionsection, or create a new key. - Click 
Next. 
- Ensure the 
Management eventscheck box is selected. - Ensure both 
ReadandWriteare checked under API activity. - Click 
Next. - Review your trail settings and click 
Create trail. 
From Command Line
Create a multi-region trail:
aws cloudtrail create-trail --name <trail-name> --bucket-name <s3-bucket-for-cloudtrail> --is-multi-region-trail
Enable multi-region on an existing trail:
aws cloudtrail update-trail --name <trail-name> --is-multi-region-trail
Note: Creating a CloudTrail trail via the CLI without providing any overriding options configures all read and write Management Events to be logged by default.
Default Value
Not Enabled.
Usage
Run the control in your terminal:
powerpipe control run aws_compliance.control.cis_v500_3_1Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run aws_compliance.control.cis_v500_3_1 --shareSQL
This control uses a named query:
with event_selectors_trail_details as (  select    distinct account_id  from    aws_cloudtrail_trail,    jsonb_array_elements(event_selectors) as e  where    (is_logging and is_multi_region_trail and e ->> 'ReadWriteType' = 'All')),advanced_event_selectors_trail_details as (  select    distinct account_id  from    aws_cloudtrail_trail,    jsonb_array_elements_text(advanced_event_selectors) as a  where  -- when readOnly = true, then it is readOnly, when readOnly = false then it is writeOnly, if advanced_event_selectors is not null then it is both ReadWriteType    (is_logging and is_multi_region_trail and advanced_event_selectors is not null and (not a like '%readOnly%')))select  a.title as resource,  case    when d.account_id is null and ad.account_id is null then 'alarm'    else 'ok'  end as status,    case    when d.account_id is null and ad.account_id is null then 'CloudTrail disabled for account ' || a.account_id || '.'    else 'CloudTrail enabled for account ' || a.account_id || '.'  end as reason
  , a.account_idfrom  aws_account as a  left join event_selectors_trail_details as d on d.account_id = a.account_id  left join advanced_event_selectors_trail_details as ad on ad.account_id = a.account_id;