# ################################### ## Rule Specification ## ##################################### # # Rule Identifier: # elasticache_repl_grp_encrypted_in_transit_check # # Description: # This control checks whether an Amazon ElastiCache replication group has encryption-in-transit enabled. # # Reports on: # AWS::ElastiCache::ReplicationGroup # # 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 ElastiCache ReplicationGroup resources # Then: SKIP # Scenario: 2 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains an ElastiCache ReplicationGroup resource # And: 'Engine' has not been provided or has been provided and is not set to 'redis' # Then: SKIP # Scenario: 3 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains an ElastiCache ReplicationGroup resource # And: 'Engine' has been provided and set to 'redis' # And: 'TransitEncryptionEnabled' has not been provided # Then: FAIL # Scenario: 4 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains an ElastiCache ReplicationGroup resource # And: 'Engine' has been provided and set to 'redis' # And: 'TransitEncryptionEnabled' has been provided and set to a value other than bool(true) # Then: FAIL # Scenario: 5 # Given: The input document is an AWS CloudFormation or CloudFormation hook document # And: The input document contains an ElastiCache ReplicationGroup resource # And: 'Engine' has been provided and set to 'redis' # And: 'TransitEncryptionEnabled' has been provided and set to bool(true) # Then: PASS # # Constants # let ELASTICACHE_REPLICATION_GROUP_TYPE = "AWS::ElastiCache::ReplicationGroup" let REDIS_ENGINE_TYPE = "redis" let INPUT_DOCUMENT = this # # Assignments # let elasticache_replication_groups = Resources.*[ Type == %ELASTICACHE_REPLICATION_GROUP_TYPE ] # # Primary Rules # rule elasticache_repl_grp_encrypted_in_transit_check when is_cfn_template(%INPUT_DOCUMENT) %elasticache_replication_groups not empty { check(%elasticache_replication_groups.Properties) << [CT.ELASTICACHE.PR.5]: Require an Amazon ElastiCache for Redis replication group to have encryption in transit activated [FIX]: Set the value of the 'TransitEncryptionEnabled' parameter to true. >> } rule elasticache_repl_grp_encrypted_in_transit_check when is_cfn_hook(%INPUT_DOCUMENT, %ELASTICACHE_REPLICATION_GROUP_TYPE) { check(%INPUT_DOCUMENT.%ELASTICACHE_REPLICATION_GROUP_TYPE.resourceProperties) << [CT.ELASTICACHE.PR.5]: Require an Amazon ElastiCache for Redis replication group to have encryption in transit activated [FIX]: Set the value of the 'TransitEncryptionEnabled' parameter to true. >> } # # Parameterized Rules # rule check(elasticache_replication_group) { %elasticache_replication_group [ # Scenario 2 Engine exists Engine == %REDIS_ENGINE_TYPE ] { # Scenarios 3, 4 and 5 TransitEncryptionEnabled exists TransitEncryptionEnabled == 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 }