IAM database authentication is not enabled for an RDS instance

Use IAM token authentication on supported RDS instances to reduce reliance on long-lived application passwords.

Description

On supported RDS instances, IAM authentication lets an application connect with a token in place of a database password. With the setting off, the database uses its configured authentication methods.

Potential impact

Copying passwords across applications makes it easier to miss a copy during rotation.

Remediation

Check engine, version, Region and client support, then set iam_database_authentication_enabled = true. Configure the database user for IAM authentication and grant the application rds-db:connect for that user. Test a token-based TLS connection before retiring replaced passwords for each account.

Examples

For this MySQL example, set db_instance_class to a class that supports the chosen version and IAM authentication in your Region. Configure networking, supply db_password securely and restrict access to the Terraform state that contains it.

Before

hcl
resource "aws_db_instance" "example" {
  allocated_storage                    = 20
  storage_type                         = "gp2"
  engine                               = "mysql"
  engine_version                       = "8.0"
  instance_class                       = var.db_instance_class
  db_name                              = "mydb"
  username                             = "foo"
  password                             = var.db_password
  iam_database_authentication_enabled  = false
}

After

hcl
resource "aws_db_instance" "example" {
  allocated_storage                    = 20
  storage_type                         = "gp2"
  engine                               = "mysql"
  engine_version                       = "8.0"
  instance_class                       = var.db_instance_class
  db_name                              = "mydb"
  username                             = "foo"
  password                             = var.db_password
  iam_database_authentication_enabled  = true
}

References