Interview Prep/Terraform/Security, Secrets and Access

How do ephemeral resources and write-only arguments keep secrets out of state?

AdvancedProductionSecurity, Secrets and Access
Answer

An ephemeral block reads a value (for example from Secrets Manager) only during the run and never writes it to plan or state; write-only arguments such as password_wo consume it without persisting it.

ephemeral "aws_secretsmanager_secret_version" "db" {
  secret_id = aws_secretsmanager_secret.db.id
}
resource "aws_db_instance" "main" {
  password_wo         = ephemeral.aws_secretsmanager_secret_version.db.secret_string
  password_wo_version = 1
}

Needs Terraform 1.11+ and provider support. Bump password_wo_version to apply a new password.

All Terraform questions Roadmap: Terraform in production

More on Security, Secrets and Access