# ################################### ## Rule Specification ## ##################################### # # Rule Identifier: # rds_cluster_deletion_protection_enabled_check # # Description: # This control checks whether your Amazon Relational Database Service (Amazon RDS) cluster has deletion protection activated. # # Reports on: # AWS::RDS::DBCluster # # 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 Amazon RDS DB cluster resources # Then: SKIP # Scenario: 2 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains an Amazon RDS DB cluster resource # And: 'DeletionProtection' 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 an Amazon RDS DB cluster resource # And: 'DeletionProtection' has been specified # And: 'DeletionProtection' has been set to bool(false) # Then: FAIL # Scenario: 4 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains an Amazon RDS DB cluster resource # And: 'DeletionProtection' has been specified # And: 'DeletionProtection' has been set to bool(true) # Then: PASS # # Constants # let RDS_DB_CLUSTER_TYPE = "AWS::RDS::DBCluster" let INPUT_DOCUMENT = this # # Assignments # let db_clusters = Resources.*[ Type == %RDS_DB_CLUSTER_TYPE ] # # Primary Rules # rule rds_cluster_deletion_protection_enabled_check when is_cfn_template(%INPUT_DOCUMENT) %db_clusters not empty { check(%db_clusters.Properties) << [CT.RDS.PR.3]: Require an Amazon RDS cluster to have deletion protection configured [FIX]: Set the value of the 'DeletionProtection' parameter to true. >> } rule rds_cluster_deletion_protection_enabled_check when is_cfn_hook(%INPUT_DOCUMENT, %RDS_DB_CLUSTER_TYPE) { check(%INPUT_DOCUMENT.%RDS_DB_CLUSTER_TYPE.resourceProperties) << [CT.RDS.PR.3]: Require an Amazon RDS cluster to have deletion protection configured [FIX]: Set the value of the 'DeletionProtection' parameter to true. >> } rule check(properties) { %properties { # Scenario 2 DeletionProtection exists # Scenario 3 and 4 DeletionProtection == 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 }