# ##################################### ## Gherkin ## ##################################### # Rule Identifier: # RDS_INSTANCE_PUBLIC_ACCESS_CHECK # # Description: # Checks if an RDS instances has Publicly Accessible not set. # # Reports on: # AWS::RDS::DBInstance # # Evaluates: # AWS CloudFormation # # Rule Parameters: # NA # # Scenarios: # a) SKIP: when there are no RDS instances present # b) PASS: when all RDS instances have PubliclyAccessible set to true # c) FAIL: when all RDS instances have PubliclyAccessible set to false # d) FAIL: when there are RDS instances with PubliclyAccessible property is not present # e) SKIP: when metadata includes the suppression for rule RDS_INSTANCE_PUBLIC_ACCESS_CHECK # # Select all RDS instance resources from incoming template (payload) # let aws_rds_instances_not_public = Resources.*[ Type == 'AWS::RDS::DBInstance' Metadata.guard.SuppressedRules not exists or Metadata.guard.SuppressedRules.* != "RDS_INSTANCE_PUBLIC_ACCESS_CHECK" ] rule RDS_INSTANCE_PUBLIC_ACCESS_CHECK when %aws_rds_instances_not_public !empty { # ALL RDS instances must have PubliclyAccessible set to false %aws_rds_instances_not_public.Properties.PubliclyAccessible == false << Violation: All RDS instances must not be publicly accessible. Fix: Set the PubliclyAccessible to false. >> }