Company
Date Published
Author
Mariusz Michalowski
Word count
1605
Language
English
Hacker News points
None

Summary

The Terraform Random provider generates cryptographically secure pseudo-random values for use in Terraform configurations. It provides resources like `random_string`, `random_id`, and `random_pet` to create unique names, passwords, or tokens that persist in the Terraform state file but can be re-generated when their arguments change or when forced through lifecycle configurations. The `random_password` resource generates a secure, random password with specific length and complexity requirements, ensuring no hardcoded passwords exist in the configuration. It is useful for creating unique resources in both production and testing environments where unique identifiers or credentials are required. The `random_password` resource can be used to generate passwords for multiple users, store them in a secrets manager like AWS Secrets Manager, and use Terraform variables or external data sources to fetch existing passwords. It is recommended to use the `random_password` resource instead of `random_string` for password generation due to its pre-configured, more robust character set. Proper state management is critical to prevent unintended password exposure, and it is encouraged to store state in an encrypted backend, use a secure secrets manager, and leverage IAM roles for authentication. Spacelift makes it easy to work with Terraform by automating infrastructure provisioning, building complex workflows based on Terraform, and managing AWS credentials per run.