Skip to main content

SKY-D401 · Deployment and infrastructure

Terraform creates an RDS database with storage encryption turned off

High

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 toward max_high and max_security; the rule never reports CRITICAL.
Finding type
review
Catalog name
Terraform AWS new database storage encryption disabled
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

main.tf · TerraformReported on line 1
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

main.tf · Terraform
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

  1. Runs with --danger (or -a). Reads .tf and .tf.json files, skipping .terraform, .git, node_modules, vendor, build, dist and virtual-environment folders, and parses them as HCL without running Terraform or contacting AWS.
  2. Resolves only literal values and local values 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.
  3. Skips a resource with count = 0 or an empty for_each, and needs the official AWS provider (hashicorp/aws, which an aws_ resource uses unless another provider is configured).
  4. Checks aws_db_instance resources.
  5. Reports when storage_encrypted is the literal false. 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.
  6. Reports HIGH on the resource line.

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.

main.tf · Terraform · the fix, against the flagged file
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_encrypted out 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_cidrs is not reported even when its default is 0.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.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.