Skip to content

Commit f17160c

Browse files
author
Haydn Evans
committed
update documentation [retrigger pipelines]
1 parent d7719c7 commit f17160c

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

website/docs/r/postgresql_role.html.markdown

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ and all but the final ``postgresql_role`` must specify a `skip_drop_role`.
2424
~> **Note:** All arguments including role name and password will be stored in the raw state as plain-text.
2525
[Read more about sensitive data in state](https://www.terraform.io/docs/state/sensitive-data.html).
2626

27+
~> **Note:** For enhanced security, consider using the `password_wo` and `password_wo_version` attributes
28+
instead of `password`. The write-only password attributes prevent the password from being stored in
29+
the Terraform state file while still allowing password management through version-controlled updates.
30+
2731
## Usage
2832

2933
```hcl
@@ -40,6 +44,45 @@ resource "postgresql_role" "my_replication_role" {
4044
connection_limit = 5
4145
password = "md5c98cbfeb6a347a47eb8e96cfb4c4b890"
4246
}
47+
48+
# Example using write-only password (password not stored in state)
49+
resource "postgresql_role" "secure_role" {
50+
name = "secure_role"
51+
login = true
52+
password_wo = "secure_password_123"
53+
password_wo_version = "1"
54+
}
55+
```
56+
57+
## Write-Only Password Management
58+
59+
The `password_wo` and `password_wo_version` attributes provide a secure way to manage role passwords
60+
without storing them in the Terraform state file:
61+
62+
* **Security**: The password value is never stored in the state file, reducing the risk of exposure
63+
* **Version Control**: Password updates are controlled through the `password_wo_version` attribute
64+
* **Idempotency**: Terraform only updates the password when the version changes, not on every apply
65+
66+
To change a password when using write-only attributes:
67+
68+
1. Update the `password_wo` value with the new password
69+
2. Increment or change the `password_wo_version` value
70+
3. Apply the configuration
71+
72+
**Example of password rotation:**
73+
74+
```hcl
75+
# Initial password setup
76+
resource "postgresql_role" "app_user" {
77+
name = "app_user"
78+
login = true
79+
password_wo = "initial_password_123"
80+
password_wo_version = "1"
81+
}
82+
83+
# To rotate the password, update both attributes:
84+
# password_wo = "new_password_456"
85+
# password_wo_version = "2"
4386
```
4487

4588
## Argument Reference
@@ -85,6 +128,15 @@ resource "postgresql_role" "my_replication_role" {
85128
* `password` - (Optional) Sets the role's password. A password is only of use
86129
for roles having the `login` attribute set to true.
87130

131+
* `password_wo` - (Optional) Sets the role's password without storing it in the state file.
132+
This is useful for managing passwords securely. Must be used together with `password_wo_version`.
133+
Conflicts with `password`.
134+
135+
* `password_wo_version` - (Optional) Prevents applies from updating the role password on every
136+
apply unless the value changes. This version string should be updated whenever you want to
137+
change the password specified in `password_wo`. Must be used together with `password_wo`.
138+
Conflicts with `password`.
139+
88140
* `roles` - (Optional) Defines list of roles which will be granted to this new role.
89141

90142
* `search_path` - (Optional) Alters the search path of this new role. Note that

0 commit comments

Comments
 (0)