# ################################### ## Rule Specification ## ##################################### # # Rule Identifier: # redshift_cluster_public_access_check # # Description: # This control checks whether Amazon Redshift clusters are configured to not be publicly accessible. # # Reports on: # AWS::Redshift::Cluster # # Evaluates: # AWS CloudFormation, AWS CloudFormation hook # # Rule Parameters: # None # # Scenarios: # Scenario: 1 # Given: The input document is an AWS CloudFormation document or CloudFormation hook document # And: The input document does not contain any Redshift cluster resources # Then: SKIP # Scenario: 2 # Given: The input document is an AWS CloudFormation document or CloudFormation hook document # And: The input document contains a Redshift cluster resource # And: 'PubliclyAccessible' has not been specified # Then: FAIL # Scenario: 3 # Given: The input document is an AWS CloudFormation document or CloudFormation hook document # And: The input document contains a Redshift cluster resource # And: 'PubliclyAccessible' has been specified # And: 'PubliclyAccessible' has been set to bool(true) # Then: FAIL # Scenario: 4 # Given: The input document is an AWS CloudFormation document or CloudFormation hook document # And: The input document contains a Redshift cluster resource # And: 'PubliclyAccessible' has been specified # And: 'PubliclyAccessible' has been set to bool(false) # Then: PASS # # Constants # let REDSHIFT_CLUSTER_TYPE = "AWS::Redshift::Cluster" let INPUT_DOCUMENT = this # # Assignments # let redshift_clusters = Resources.*[ Type == %REDSHIFT_CLUSTER_TYPE ] # # Primary Rules # rule redshift_cluster_public_access_check when is_cfn_template(%INPUT_DOCUMENT) %redshift_clusters not empty { check(%redshift_clusters.Properties) << [CT.REDSHIFT.PR.1]: Require an Amazon Redshift cluster to prohibit public access [FIX]: Set 'PubliclyAccessible' to 'false'. >> } rule redshift_cluster_public_access_check when is_cfn_hook(%INPUT_DOCUMENT, %REDSHIFT_CLUSTER_TYPE) { check(%INPUT_DOCUMENT.%REDSHIFT_CLUSTER_TYPE.resourceProperties) << [CT.REDSHIFT.PR.1]: Require an Amazon Redshift cluster to prohibit public access [FIX]: Set 'PubliclyAccessible' to 'false'. >> } # # Parameterized Rules # rule check(redshift_cluster) { %redshift_cluster { # Scenario 2 PubliclyAccessible exists # Scenario 3 & 4 PubliclyAccessible == false } } # # Utility Rules # rule is_cfn_template(doc) { %doc { AWSTemplateFormatVersion exists or Resources exists } } rule is_cfn_hook(doc, RESOURCE_TYPE) { %doc.%RESOURCE_TYPE.resourceProperties exists }