hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.4k stars 9.5k forks source link

generating HASH using terraform for linux password - /etc/shadow #29750

Open VickyWinner opened 2 years ago

VickyWinner commented 2 years ago

I am trying to generate HASH from input variable which has a user's password in cleartext.
The HASH uses sha512_crypt scheme and uses the modular crypt prefix $6$. Here is an example of a hash generated by a function in NodeJS using crypt3-passwd library. I read some of terraform functions and think that they don't support.

const crypt = require('crypt3-passwd');
const hash = crypt.encrypt(password);

I need to generate a HASH and save it in /etc/shadow.

fullmetal-fred commented 1 year ago

Found a provider that allows this. See here: https://github.com/hashicorp/terraform/issues/26059

https://github.com/loafoe/terraform-provider-htpasswd https://registry.terraform.io/providers/loafoe/htpasswd/

crw commented 6 months ago

Thank you for your continued interest in this issue.

Terraform version 1.8 launches with support of provider-defined functions. It is now possible to implement your own functions! We would love to see this implemented as a provider-defined function.

Please see the provider-defined functions documentation to learn how to implement functions in your providers. If you are new to provider development, learn how to create a new provider with the Terraform Plugin Framework. If you have any questions, please visit the Terraform Plugin Development category in our official forum.

We hope this feature unblocks future function development and provides more flexibility for the Terraform community. Thank you for your continued support of Terraform!