How do you rotate a secret that Terraform created?
IntermediateProductionSecurity, Secrets and Access
Answer
Avoid Terraform-owned rotation. Create the secret shell with Terraform, let Secrets Manager rotation or the service rotate it and add lifecycle { ignore_changes = [secret_string] } if Terraform sets the initial value. If you must rotate via Terraform, taint or replace random_password (or change its keepers) and apply, accepting the new value lands in state.
More on Security, Secrets and Access
How do you avoid hardcoded credentials in Terraform?BeginnerIs reading a secret with a data source safe?IntermediateHow 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?Intermediate