For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/cloudformation-aws-cmk-unencrypted-storage.md.
A documentation index is available at /llms.txt.
Storage encryption must be enabled for database and analytics clusters to protect data at rest and prevent exposure of sensitive data in volumes, snapshots, and backups if storage media or snapshots are compromised. In CloudFormation, the StorageEncrypted property must be defined and set to true for AWS::RDS::DBInstance, AWS::RDS::DBCluster, AWS::RDS::GlobalCluster, AWS::DocDB::DBCluster, and AWS::Neptune::DBCluster. For AWS::Redshift::Cluster, the Encrypted property must be defined and set to true. Resources missing these properties or with the properties set to false will be flagged.
AWSTemplateFormatVersion:2010-09-09Description:RDS Storage EncryptedParameters:SourceDBInstanceIdentifier:Type:StringDBInstanceType:Type:StringSourceRegion:Type:StringResources:MyKey:Type:"AWS::KMS::Key"Properties:KeyPolicy:Version:2012-10-17Id:key-default-1Statement:- Sid:Enable IAM User PermissionsEffect:AllowPrincipal:AWS:!Join- ""- - "arn:aws:iam::"- !Ref "AWS::AccountId"- ":root"Action:"kms:*"Resource:"*"MyDBSmall:Type:"AWS::RDS::DBInstance"Properties:DBInstanceClass:!Ref DBInstanceTypeSourceDBInstanceIdentifier:!Ref SourceDBInstanceIdentifierSourceRegion:!Ref SourceRegionKmsKeyId:!Ref MyKeyStorageEncrypted:true
AWSTemplateFormatVersion:2010-09-09Description:>- AWS CloudFormation Sample TemplateParameters:DBUsername:NoEcho:'true'Description:Username for MySQL database accessType:StringMinLength:'1'MaxLength:'16'AllowedPattern:'[a-zA-Z][a-zA-Z0-9]*'ConstraintDescription:must begin with a letter and contain only alphanumeric characters.DBPassword:NoEcho:'true'Description:Password MySQL database accessType:StringMinLength:'8'MaxLength:'41'AllowedPattern:'[a-zA-Z0-9]*'ConstraintDescription:must contain only alphanumeric characters.Resources:MyKey-0:Type:"AWS::KMS::Key"Properties:KeyPolicy:Version:2012-10-17Id:key-default-1Statement:- Sid:Enable IAM User PermissionsEffect:AllowPrincipal:AWS:!Join- ""- - "arn:aws:iam::"- !Ref "AWS::AccountId"- ":root"Action:"kms:*"Resource:"*"RDSCluster:Type:'AWS::RDS::DBCluster'Properties:MasterUsername:!Ref DBUsernameMasterUserPassword:!Ref DBPasswordDBClusterIdentifier:my-serverless-clusterEngine:auroraEngineVersion:5.6.10aEngineMode:serverlessScalingConfiguration:AutoPause:trueMinCapacity:4MaxCapacity:32SecondsUntilAutoPause:1000KmsKeyId:!Ref MyKey-0StorageEncrypted:true
{"AWSTemplateFormatVersion":"2010-09-09T00:00:00Z","Description":"RDS Storage Encrypted","Parameters":{"SourceDBInstanceIdentifier":{"Type":"String"},"DBInstanceType":{"Type":"String"},"SourceRegion":{"Type":"String"}},"Resources":{"MyKey":{"Type":"AWS::KMS::Key","Properties":{"KeyPolicy":{"Version":"2012-10-17T00:00:00Z","Id":"key-default-1","Statement":[{"Principal":{"AWS":["",["arn:aws:iam::","AWS::AccountId",":root"]]},"Action":"kms:*","Resource":"*","Sid":"Enable IAM User Permissions","Effect":"Allow"}]}}},"MyDBSmall":{"Type":"AWS::RDS::DBInstance","Properties":{"SourceRegion":"SourceRegion","KmsKeyId":"MyKey","StorageEncrypted":true,"DBInstanceClass":"DBInstanceType","SourceDBInstanceIdentifier":"SourceDBInstanceIdentifier"}}}}
Non-Compliant Code Examples
AWSTemplateFormatVersion:2010-09-09Description:>- AWS CloudFormation SampleParameters:DBInstanceID:Default:mydbinstanceDescription:My database instanceType:StringMinLength:'1'MaxLength:'63'AllowedPattern:'[a-zA-Z][a-zA-Z0-9]*'ConstraintDescription:>- Must begin with a letter and must not end with a hyphen or contain two
consecutive hyphens.DBName:Default:mydbDescription:My databaseType:StringMinLength:'1'MaxLength:'64'AllowedPattern:'[a-zA-Z][a-zA-Z0-9]*'ConstraintDescription:Must begin with a letter and contain only alphanumeric characters.DBInstanceClass:Default:db.m5.largeDescription:DB instance classType:StringConstraintDescription:Must select a valid DB instance type.DBAllocatedStorage:Default:'50'Description:The size of the database (GiB)Type:NumberMinValue:'5'MaxValue:'1024'ConstraintDescription:must be between 20 and 65536 GiB.DBUsername:NoEcho:'true'Description:Username for MySQL database accessType:StringMinLength:'1'MaxLength:'16'AllowedPattern:'[a-zA-Z][a-zA-Z0-9]*'ConstraintDescription:must begin with a letter and contain only alphanumeric characters.DBPassword:NoEcho:'true'Description:Password MySQL database accessType:StringMinLength:'8'MaxLength:'41'AllowedPattern:'[a-zA-Z0-9]*'ConstraintDescription:must contain only alphanumeric characters.Resources:MyDB:Type:'AWS::RDS::DBInstance'Properties:DBInstanceIdentifier:!Ref DBInstanceIDDBName:!Ref DBNameDBInstanceClass:!Ref DBInstanceClassAllocatedStorage:!Ref DBAllocatedStorageEngine:MySQLEngineVersion:8.0.16MasterUsername:!Ref DBUsernameMasterUserPassword:!Ref DBPasswordMonitoringInterval:'60'MonitoringRoleArn:'arn:aws:iam::123456789012:role/rds-monitoring-role'
AWSTemplateFormatVersion:2010-09-09Description:>- AWS CloudFormation Sample TemplateParameters:DBUsername:NoEcho:"true"Description:Username for MySQL database accessType:StringMinLength:"1"MaxLength:"16"AllowedPattern:"[a-zA-Z][a-zA-Z0-9]*"ConstraintDescription:must begin with a letter and contain only alphanumeric characters.DBPassword:NoEcho:"true"Description:Password MySQL database accessType:StringMinLength:"8"MaxLength:"41"AllowedPattern:"[a-zA-Z0-9]*"ConstraintDescription:must contain only alphanumeric characters.Resources:RDSCluster1:Type:"AWS::RDS::DBCluster"Properties:MasterUsername:!Ref DBUsernameMasterUserPassword:!Ref DBPasswordDBClusterIdentifier:my-serverless-clusterEngine:auroraEngineVersion:5.6.10aEngineMode:serverlessScalingConfiguration:AutoPause:trueMinCapacity:4MaxCapacity:32SecondsUntilAutoPause:1000
AWSTemplateFormatVersion:2010-09-09Description:>- AWS CloudFormation Sample Template AuroraServerlessDBClusterParameters:DBUsername:NoEcho:'true'Description:Username for MySQL database accessType:StringMinLength:'1'MaxLength:'16'AllowedPattern:'[a-zA-Z][a-zA-Z0-9]*'ConstraintDescription:must begin with a letter and contain only alphanumeric characters.DBPassword:NoEcho:'true'Description:Password MySQL database accessType:StringMinLength:'8'MaxLength:'41'AllowedPattern:'[a-zA-Z0-9]*'ConstraintDescription:must contain only alphanumeric characters.Resources:RDSCluster-2:Type:'AWS::RDS::DBCluster'Properties:MasterUsername:!Ref DBUsernameMasterUserPassword:!Ref DBPasswordDBClusterIdentifier:my-serverless-clusterEngine:auroraEngineVersion:5.6.10aEngineMode:serverlessScalingConfiguration:AutoPause:trueMinCapacity:4MaxCapacity:32SecondsUntilAutoPause:1000StorageEncrypted:false
1
2
rulesets:- CloudFormation / AWS # Rules to enforce / AWS.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.