# ################################### ## Rule Specification ## ##################################### # # Rule Identifier: # redshift_cluster_allow_version_upgrade_check # # Description: # This control checks whether automatic major version upgrades are enabled for your Amazon Redshift cluster. # # 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 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 or CloudFormation hook document # And: The input document contains a Redshift cluster resource # And: 'AllowVersionUpgrade' has been provided # And: 'AllowVersionUpgrade' has been set to bool(false) # Then: FAIL # Scenario: 3 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains a Redshift cluster resource # And: 'AllowVersionUpgrade' has not been provided # Then: PASS # Scenario: 4 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains a Redshift cluster resource # And: 'AllowVersionUpgrade' has been provided # And: 'AllowVersionUpgrade' has been set to bool(true) # 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_allow_version_upgrade_check when is_cfn_template(%INPUT_DOCUMENT) %redshift_clusters not empty { check(%redshift_clusters.Properties) << [CT.REDSHIFT.PR.4]: Require an Amazon Redshift cluster to have automatic upgrades to major versions configured [FIX]: Set the 'AllowVersionUpgrade' property to true or do not specify it (default). >> } rule redshift_cluster_allow_version_upgrade_check when is_cfn_hook(%INPUT_DOCUMENT, %REDSHIFT_CLUSTER_TYPE) { check(%INPUT_DOCUMENT.%REDSHIFT_CLUSTER_TYPE.resourceProperties) << [CT.REDSHIFT.PR.4]: Require an Amazon Redshift cluster to have automatic upgrades to major versions configured [FIX]: Set the 'AllowVersionUpgrade' property to true or do not specify it (default). >> } # # Parameterized Rules # rule check(redshift_cluster) { %redshift_cluster { # Scenario 3 AllowVersionUpgrade not exists or # Scenario 2 & 4 AllowVersionUpgrade == true } } # # 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 }