Is reading a secret with a data source safe?
IntermediateProductionSecurity, Secrets and Access
Answer
Reading is fine from an IAM standpoint, but the value lands in state in plaintext (even if marked sensitive) and can show up in plans if used in a resource attribute. Better is to pass the secret's ARN and let the workload read it at runtime. Where Terraform must use the value, prefer ephemeral resources.
More on Security, Secrets and Access
How do you avoid hardcoded credentials in Terraform?BeginnerHow do ephemeral resources and write-only arguments keep secrets out of state?AdvancedWhat is the better pattern for RDS master passwords?BeginnerHow do you scope IAM for the Terraform deploy role?IntermediateWhat are dynamic provider credentials in HCP Terraform?IntermediateHow do you defend against supply-chain risk in providers and modules?Advanced