Skip to content

Commit 712f30f

Browse files
committed
docs(provider): update comprehensive user resource documentation
1 parent 04a217c commit 712f30f

File tree

4 files changed

+177
-3
lines changed

4 files changed

+177
-3
lines changed

docs/data-sources/user.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ terraform {
2727
# Configure the provider for local Redis
2828
provider "redisacl" {
2929
address = "localhost:6379"
30-
username = "redis" # Change this to your Redis username
30+
username = "redis" # Change this to your Redis username
3131
password = "your-redis-password" # Change this to your Redis password
3232
}
3333

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ terraform {
2626
# Configure the provider for local Redis
2727
provider "redisacl" {
2828
address = "localhost:6379"
29-
username = "redis" # Change this to your Redis username
29+
username = "redis" # Change this to your Redis username
3030
password = "your-redis-password" # Change this to your Redis password
3131
}
3232

docs/resources/user.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
page_title: "redisacl_user Resource - redisacl"
3+
subcategory: ""
4+
description: |-
5+
Manages a Redis ACL user.
6+
---
7+
8+
# redisacl_user (Resource)
9+
10+
Manages a Redis ACL user.
11+
12+
## Example Usage
13+
14+
```terraform
15+
# Basic Redis ACL User Management Example
16+
# This example demonstrates basic user creation and management
17+
18+
terraform {
19+
required_providers {
20+
redisacl = {
21+
source = "B3ns44d/redisacl"
22+
version = "1.0.1"
23+
}
24+
}
25+
}
26+
27+
# Configure the provider for local Redis
28+
provider "redisacl" {
29+
address = "localhost:6379"
30+
username = "redis" # Change this to your Redis username
31+
password = "your-redis-password" # Change this to your Redis password
32+
}
33+
34+
# Create a read-only user for applications
35+
resource "redisacl_user" "readonly_app" {
36+
name = "readonly-app"
37+
enabled = true
38+
passwords = ["app-readonly-password"]
39+
40+
# Allow access to application keys only
41+
keys = "~app:* ~cache:*"
42+
43+
# Allow all pub/sub channels
44+
channels = "&*"
45+
46+
# Only allow read operations
47+
commands = "+@read -@write -@dangerous"
48+
}
49+
50+
# Create a write user for data ingestion
51+
resource "redisacl_user" "write_app" {
52+
name = "write-app"
53+
enabled = true
54+
passwords = ["app-write-password"]
55+
56+
# Allow access to specific key patterns
57+
keys = "~data:* ~temp:*"
58+
59+
# Allow specific pub/sub channels
60+
channels = "&notifications:* &events:*"
61+
62+
# Allow read and write, but not dangerous operations
63+
commands = "+@read +@write -@dangerous"
64+
}
65+
66+
# Create an admin user with full access
67+
resource "redisacl_user" "admin" {
68+
name = "admin-user"
69+
enabled = true
70+
passwords = ["secure-admin-password"]
71+
72+
# Full access to all keys and channels
73+
keys = "~*"
74+
channels = "&*"
75+
commands = "+@all"
76+
77+
# Allow self-modification (needed for admin operations)
78+
allow_self_mutation = true
79+
}
80+
81+
# Create a monitoring user with limited access
82+
resource "redisacl_user" "monitoring" {
83+
name = "monitoring-user"
84+
enabled = true
85+
passwords = ["monitoring-password"]
86+
87+
# No key access needed for monitoring
88+
keys = "~"
89+
90+
# No pub/sub access needed
91+
channels = "&"
92+
93+
# Only allow monitoring and info commands
94+
commands = "+ping +info +client +config|get +memory +latency +slowlog"
95+
}
96+
97+
# Data source to read the default user
98+
data "redisacl_user" "default" {
99+
name = "default"
100+
}
101+
102+
# Data source to list all users
103+
data "redisacl_users" "all" {}
104+
105+
# Outputs
106+
output "default_user_info" {
107+
description = "Information about the default Redis user"
108+
value = {
109+
enabled = data.redisacl_user.default.enabled
110+
keys = data.redisacl_user.default.keys
111+
commands = data.redisacl_user.default.commands
112+
}
113+
}
114+
115+
output "all_users" {
116+
description = "List of all Redis ACL users"
117+
value = [for user in data.redisacl_users.all.users : {
118+
name = user.name
119+
enabled = user.enabled
120+
}]
121+
}
122+
123+
output "created_users" {
124+
description = "Information about created users"
125+
value = {
126+
readonly_app = {
127+
name = redisacl_user.readonly_app.name
128+
keys = redisacl_user.readonly_app.keys
129+
}
130+
write_app = {
131+
name = redisacl_user.write_app.name
132+
keys = redisacl_user.write_app.keys
133+
}
134+
admin = {
135+
name = redisacl_user.admin.name
136+
}
137+
monitoring = {
138+
name = redisacl_user.monitoring.name
139+
}
140+
}
141+
}
142+
```
143+
144+
<!-- schema generated by tfplugindocs -->
145+
## Schema
146+
147+
### Required
148+
149+
- `name` (String) The name of the user.
150+
151+
### Optional
152+
153+
- `allow_self_mutation` (Boolean) Whether to allow the user to modify itself.
154+
- `channels` (String) The channel patterns the user has access to (space-separated if multiple).
155+
- `commands` (String) The commands the user can execute (space-separated).
156+
- `enabled` (Boolean) Whether the user is enabled.
157+
- `keys` (String) The key patterns the user has access to (space-separated if multiple).
158+
- `passwords` (List of String, Sensitive) A list of passwords for the user.
159+
- `selectors` (List of String) A list of selectors for the user (each a string of space-separated rules).
160+
161+
### Read-Only
162+
163+
- `id` (String) The ID of the user (same as name).
164+
165+
## Import
166+
167+
Import is supported using the following syntax:
168+
169+
```shell
170+
# Redis ACL users can be imported using their username
171+
terraform import redisacl_user.example username
172+
```
173+
174+
**Note:** When importing a Redis ACL user, the `passwords` field will be empty in the Terraform state for security reasons. You'll need to set the passwords in your configuration after import.

examples/basic-usage/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ terraform {
1313
# Configure the provider for local Redis
1414
provider "redisacl" {
1515
address = "localhost:6379"
16-
username = "redis" # Change this to your Redis username
16+
username = "redis" # Change this to your Redis username
1717
password = "your-redis-password" # Change this to your Redis password
1818
}
1919

0 commit comments

Comments
 (0)