I have an aws_db_instance with a password property that is required, and was already created long ago with the Random provider via:
resource "random_password" "my_db_password" {
length = 16
special = false
}
I read in the latest documentation that will Terraform 1.11.0 the password_wo property is available to use in place of password.
So currently the password my_db_password is stored in state, and that was created by the Terraform configuration shown above. It appears that what password_wo allows us to do is prevents us from creating the password via our Terraform configuration and let’s us pull it in during the terraform plan and/or terraform apply operation - say fetching that value from vault, but as the documentation states, “Note that this may show up in logs, and it will be stored in the state file.” So it doesn’t get us what we fully need.
Is our best option then to use the ephemeral { } block such as detailed here?
So it seems that we would be destroying our resource "random_password" "my_db_password" by removing that block of code from our Terraform configuration, satisfying the password property of the aws_db_instance by using password_wo in place of plain password property, and also then saving the password from being stored in plan files and/or state files by using the ephemeral block.
or should we use ephemeral is an argument/property for a variable such as detailed here?
Note that the actual DB password I do want to use is grabbed from somewhere else, so I’m just trying to fulfill the requirements of the aws_db_instance while not giving access to the DB instance via any credential/password created via code.
Just trying to find the cleanest/best way to use it given the context.
Thank you!