# ##################################### ## Gherkin ## ##################################### # Rule Identifier: # CLOUD_TRAIL_ENABLED # # Description: # Checks if AWS CloudTrail is enabled. # # Reports on: # AWS::CloudTrail::Trail # # Evaluates: # AWS CloudFormation # # Rule Parameters: # NA # # Scenarios: # a) SKIP: when there are no CloudTrail Trails present # b) PASS: when all CloudTrail Trails have IsLogging parameter set true # c) FAIL: when there are CloudTrail Trails with the IsLogging parameter is set to false # d) FAIL: when there are CloudTrail Trails with IsLogging property not present # e) SKIP: when metada has rule suppression for CLOUD_TRAIL_ENABLED # # Select all CloudTrail Trail resources from incoming template (payload) # let cloudtrail_trails_enabled = Resources.*[ Type == 'AWS::CloudTrail::Trail' Metadata.guard.SuppressedRules not exists or Metadata.guard.SuppressedRules.* != "CLOUD_TRAIL_ENABLED" ] rule CLOUD_TRAIL_ENABLED when %cloudtrail_trails_enabled !empty { %cloudtrail_trails_enabled.Properties.IsLogging EXISTS %cloudtrail_trails_enabled.Properties.IsLogging == true << Violation: CloudTrail Trail should be enabled. Fix: Set the IsLogging parameter to true. >> }