SKY-D401 · Deployment and infrastructure
Terraform creates an RDS database with storage encryption turned off
Amazon RDS can encrypt a database's disks, backups and snapshots. SKY-D401 reports a Terraform aws_db_instance that creates a new database with storage_encrypted = false.
- Languages
- Terraform
- Quality gate
- counted toward the gate limits (full and diff scans). Reported under security (
danger). It counts towardmax_highandmax_security; the rule never reports CRITICAL. - Finding type
- review
- Catalog name
- Terraform AWS new database storage encryption disabled
Why it matters
An unencrypted database stays unencrypted: RDS cannot turn encryption on for an existing instance, so fixing it later means a snapshot, an encrypted copy and a migration. Unencrypted snapshots can also be shared or copied without a key to stop them.
What Skylos flags
resource "aws_db_instance" "orders" { identifier = "orders" engine = "postgres" engine_version = "16.4" instance_class = "db.t3.medium" allocated_storage = 50 username = "orders" manage_master_user_password = true storage_encrypted = false}What Skylos leaves alone
resource "aws_db_instance" "orders" { identifier = "orders" engine = "postgres" engine_version = "16.4" instance_class = "db.t3.medium" allocated_storage = 50 username = "orders" manage_master_user_password = true storage_encrypted = true kms_key_id = aws_kms_key.rds.arn}Why Skylos leaves it alone
Encryption is requested explicitly, with a customer-managed key. The key's ARN comes from another resource and stays unknown, but storage_encrypted = true alone settles the rule.
How Skylos decides
- Runs with
--danger(or-a). Reads.tfand.tf.jsonfiles, skipping.terraform,.git,node_modules,vendor,build,distand virtual-environment folders, and parses them as HCL without running Terraform or contacting AWS. - Resolves only literal values and
localvalues of the same module. Input variables, data sources, attributes of other resources and module outputs stay unknown, and an unknown value never produces a finding. - Skips a resource with
count = 0or an emptyfor_each, and needs the official AWS provider (hashicorp/aws, which anaws_resource uses unless another provider is configured). - Checks
aws_db_instanceresources. - Reports when
storage_encryptedis the literalfalse. A database restored or copied from elsewhere (snapshot_identifier,replicate_source_db,restore_to_point_in_time,s3_import) is not judged, because it inherits its encryption. - Reports HIGH on the
resourceline.
How to fix it
Set storage_encrypted = true, ideally with your own KMS key. For a database that already exists, take a snapshot, copy it with encryption and restore from the copy.
resource "aws_db_instance" "orders" { identifier = "orders" engine = "postgres" engine_version = "16.4" instance_class = "db.t3.medium" allocated_storage = 50 username = "orders" manage_master_user_password = trueRemoved: storage_encrypted = falseAdded: storage_encrypted = trueAdded: kms_key_id = aws_kms_key.rds.arn}When it can be wrong
- Leaving
storage_encryptedout is not reported, although AWS then creates an unencrypted database. Write the value explicitly. - Values that come from variables, modules or other resources are not checked, because Skylos does not run Terraform:
cidr_blocks = var.admin_cidrsis not reported even when its default is0.0.0.0/0. - It judges the declaration only. It does not know what is deployed, and other settings (account defaults, security groups, routing) can make the real exposure smaller or larger.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Terraform rules read no inline marker:
# skylos: ignore[SKY-D401]on the resource line does not hide the finding.[tool.skylos] ignore = ["SKY-D401"]turns the rule off for the project.A baseline (
skylos baseline ., then--baseline) accepts the declarations that exist today and reports new ones.