Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash changes even if password doesn't #1

Closed
ekristen opened this issue Mar 4, 2021 · 3 comments
Closed

Hash changes even if password doesn't #1

ekristen opened this issue Mar 4, 2021 · 3 comments

Comments

@ekristen
Copy link

ekristen commented Mar 4, 2021

First, thanks for the module.

Second, it looks like the hash is re-computed every time even if the password doesn't change (ie apr1). This shouldn't be recalculated every time especially when resources are depending on it.

It would appear that https://github.com/loafoe/terraform-provider-htpasswd/blob/main/htpasswd/data_source_password.go#L42 would keep that from happening, but it's definitely not. The resource isn't new and the password is not changing, yet it is still making it into the block and re-generating the hash.

@ekristen
Copy link
Author

ekristen commented Mar 5, 2021

This might be related to hashicorp/terraform-plugin-sdk#98, keeping the salt the same doesnt fix it either, regardless in terraform 14, it always generates a new hash.

@loafoe
Copy link
Owner

loafoe commented Mar 5, 2021

This worked for me during initial development:

resource "random_password" "password" {
  length = 30
}

data "htpasswd_password" "hash" {
  password = random_password.password.result
  salt     = substr(sha512(random_password.password.result), 0, 8)
}

I'll test it with the latest version of Terraform..

@loafoe
Copy link
Owner

loafoe commented Mar 5, 2021

@ekristen tested above with latest terraform and it produces stable state. I've modified the example in the documentation to include the salt attribute. Can you confirm it works for you?

@loafoe loafoe closed this as completed Apr 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants