# ################################### ## Rule Specification ## ##################################### # # Rule Identifier: # redshift_backup_enabled_check # # Description: # This control checks whether Amazon Redshift clusters have automated snapshots enabled, and set with an automated snapshot retention period greater than or equal to seven (7) days. # # 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: 'AutomatedSnapshotRetentionPeriod' has not been specified # 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: 'AutomatedSnapshotRetentionPeriod' has been specified # And: 'AutomatedSnapshotRetentionPeriod' has been set to '0' # Then: FAIL # Scenario: 4 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains a Redshift cluster resource # And: 'AutomatedSnapshotRetentionPeriod' has been specified # And: 'AutomatedSnapshotRetentionPeriod' has been set to a value < 7 # Then: FAIL # Scenario: 5 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains a Redshift cluster resource # And: 'AutomatedSnapshotRetentionPeriod' has been specified # And: 'AutomatedSnapshotRetentionPeriod' has been set to a value >= 7 # 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_backup_enabled_check when is_cfn_template(%INPUT_DOCUMENT) %redshift_clusters not empty { check(%redshift_clusters.Properties) << [CT.REDSHIFT.PR.2]: Require an Amazon Redshift cluster to have automatic snapshots configured [FIX]: Set 'AutomatedSnapshotRetentionPeriod' to an integer value greater than or equal to 7 days. >> } rule redshift_backup_enabled_check when is_cfn_hook(%INPUT_DOCUMENT, %REDSHIFT_CLUSTER_TYPE) { check(%INPUT_DOCUMENT.%REDSHIFT_CLUSTER_TYPE.resourceProperties) << [CT.REDSHIFT.PR.2]: Require an Amazon Redshift cluster to have automatic snapshots configured [FIX]: Set 'AutomatedSnapshotRetentionPeriod' to an integer value greater than or equal to 7 days. >> } # # Parameterized Rules # rule check(redshift_cluster) { %redshift_cluster { # Scenario 2 AutomatedSnapshotRetentionPeriod exists # Scenario 3, 4 & 5 AutomatedSnapshotRetentionPeriod >= 7 } } # # 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 }