# ################################### ## Rule Specification ## ##################################### # # Rule Identifier: # efs_automatic_backups_enabled_check # # Description: # This control checks whether your Amazon EFS file system has been configured with automatic backups through AWS Backup. # # Reports on: # AWS::EFS::FileSystem # # 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 EFS file system resources # Then: SKIP # Scenario: 2 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains an EFS file system resource # And: 'BackupPolicy' is not present # Then: FAIL # Scenario: 3 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains an EFS file system resource # And: 'BackupPolicy' is present and 'Status' is set to 'DISABLED' # Then: FAIL # Scenario: 4 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains an EFS file system resource # And: 'BackupPolicy' is present and 'Status' is set to 'ENABLED' # Then: PASS # # Constants # let RESOURCE_TYPE = "AWS::EFS::FileSystem" let INPUT_DOCUMENT = this # # Assignments # let efs_file_systems = Resources.*[ Type == %RESOURCE_TYPE ] # # Primary Rules # rule efs_automatic_backups_enabled_check when is_cfn_template(this) %efs_file_systems not empty { check(%efs_file_systems.Properties) << [CT.ELASTICFILESYSYSTEM.PR.2]: Require an Amazon EFS volume to have an automated backup plan [FIX]: Enable automatic backups by setting 'BackupPolicy.Status' to 'ENABLED'. >> } rule efs_automatic_backups_enabled_check when is_cfn_hook(%INPUT_DOCUMENT, %RESOURCE_TYPE) { check(%INPUT_DOCUMENT.%RESOURCE_TYPE.resourceProperties) << [CT.ELASTICFILESYSYSTEM.PR.2]: Require an Amazon EFS volume to have an automated backup plan [FIX]: Enable automatic backups by setting 'BackupPolicy.Status' to 'ENABLED'. >> } # # Parameterized Rules # rule check(efs_file_systems) { %efs_file_systems { # Scenario 2 BackupPolicy exists BackupPolicy is_struct BackupPolicy { # Scenario 3 and 4 Status exists Status == "ENABLED" } } } # # 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 }