# ################################### ## Rule Specification ## ##################################### # # Rule Identifier: # rds_cluster_iam_authentication_enabled_check # # Description: # This control checks whether an Amazon Relational Database Service (RDS) database (DB) cluster has AWS IAM database authentication 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 document or CloudFormation hook document # And: The input document does not contain any RDS DB cluster resources # Then: SKIP # Scenario: 2 # Given: The input document is an AWS CloudFormation document or CloudFormation hook document # And: The input document contains an RDS DB cluster resource # And: 'Engine' provided is not one of 'aurora' or 'aurora-mysql' or 'aurora-postgresql' # Then: SKIP # Scenario: 3 # Given: The input document is an AWS CloudFormation document or CloudFormation hook document # And: The input document contains an RDS DB cluster resource # And: 'Engine' provided is one of 'aurora' or 'aurora-mysql' or 'aurora-postgresql' # And: 'EnableIAMDatabaseAuthentication' has not been provided # Then: FAIL # Scenario: 4 # Given: The input document is an AWS CloudFormation document or CloudFormation hook document # And: The input document contains an RDS DB cluster resource # And: 'Engine' provided is one of 'aurora' or 'aurora-mysql' or 'aurora-postgresql' # And: 'EnableIAMDatabaseAuthentication' has been provided # And: 'EnableIAMDatabaseAuthentication' has been set to a value other than bool(true) # Then: FAIL # Scenario: 5 # Given: The input document is an AWS CloudFormation document or CloudFormation hook document # And: The input document contains an RDS DB cluster resource # And: 'Engine' provided is one of 'aurora' or 'aurora-mysql' or 'aurora-postgresql' # And: 'EnableIAMDatabaseAuthentication' has been provided # And: 'EnableIAMDatabaseAuthentication' has been set to bool(true) # Then: PASS # # Constants # let RDS_DB_CLUSTER_TYPE = "AWS::RDS::DBCluster" let SUPPORTED_DB_CLUSTER_ENGINES = ["aurora", "aurora-mysql","aurora-postgresql"] let INPUT_DOCUMENT = this # # Assignments # let db_clusters = Resources.*[ Type == %RDS_DB_CLUSTER_TYPE ] # # Primary Rules # rule rds_cluster_iam_authentication_enabled_check when is_cfn_template(%INPUT_DOCUMENT) %db_clusters not empty { check(%db_clusters.Properties) << [CT.RDS.PR.4]: Require an Amazon RDS database cluster to have AWS IAM database authentication configured [FIX]: Set 'EnableIAMDatabaseAuthentication' to 'true'. >> } rule rds_cluster_iam_authentication_enabled_check when is_cfn_hook(%INPUT_DOCUMENT, %RDS_DB_CLUSTER_TYPE) { check(%INPUT_DOCUMENT.%RDS_DB_CLUSTER_TYPE.resourceProperties) << [CT.RDS.PR.4]: Require an Amazon RDS database cluster to have AWS IAM database authentication configured [FIX]: Set 'EnableIAMDatabaseAuthentication' to 'true'. >> } rule check(db_cluster) { %db_cluster [ # Scenario 2 filter_engine(this) ] { # Scenario 3 EnableIAMDatabaseAuthentication exists # Scenario 4 and 5 EnableIAMDatabaseAuthentication == true } } rule filter_engine(cluster_properties) { %cluster_properties { Engine exists Engine in %SUPPORTED_DB_CLUSTER_ENGINES } } # # 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 }