Skip to content

Commit

Permalink
docs: improve valkey docs (#1914)
Browse files Browse the repository at this point in the history
  • Loading branch information
staceysalamon-aiven authored Nov 21, 2024
1 parent 66e1874 commit dee70ec
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 27 deletions.
14 changes: 7 additions & 7 deletions docs/data-sources/valkey_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ The Valkey User data source provides information about the existing Aiven for Va

- `project` (String) The name of the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
- `service_name` (String) The name of the service that this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
- `username` (String) The actual name of the Valkey User. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
- `username` (String) Name of the Valkey service user. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.

### Read-Only

- `id` (String) The ID of this resource.
- `password` (String, Sensitive) The password of the Valkey User.
- `type` (String) Type of the user account. Tells whether the user is the primary account or a regular account.
- `valkey_acl_categories` (List of String) Defines command category rules. The field is required with`valkey_acl_commands` and `valkey_acl_keys`. Changing this property forces recreation of the resource.
- `valkey_acl_channels` (List of String) Defines the permitted pub/sub channel patterns. Changing this property forces recreation of the resource.
- `valkey_acl_commands` (List of String) Defines rules for individual commands. The field is required with`valkey_acl_categories` and `valkey_acl_keys`. Changing this property forces recreation of the resource.
- `valkey_acl_keys` (List of String) Defines key access rules. The field is required with`valkey_acl_categories` and `valkey_acl_keys`. Changing this property forces recreation of the resource.
- `password` (String, Sensitive) The Valkey service user's password.
- `type` (String) User account type, such as primary or regular account.
- `valkey_acl_categories` (List of String) Allow or disallow command categories. To allow a category use the prefix `+@` and to disallow use `-@`. See the [Valkey documentation](https://valkey.io/topics/acl/) for details on the ACL feature. The field is required with`valkey_acl_commands` and `valkey_acl_keys`. Changing this property forces recreation of the resource.
- `valkey_acl_channels` (List of String) Allows and disallows access to pub/sub channels. Entries are defined as standard glob patterns. Changing this property forces recreation of the resource.
- `valkey_acl_commands` (List of String) Defines rules for individual commands. To allow a command use the prefix `+` and to disallow use `-`. The field is required with`valkey_acl_categories` and `valkey_acl_keys`. Changing this property forces recreation of the resource.
- `valkey_acl_keys` (List of String) Key access rules. Entries are defined as standard glob patterns. The field is required with`valkey_acl_categories` and `valkey_acl_keys`. Changing this property forces recreation of the resource.
4 changes: 2 additions & 2 deletions docs/resources/valkey.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "aiven_valkey Resource - terraform-provider-aiven"
subcategory: ""
description: |-
Creates and manages an Aiven for Valkey https://aiven.io/docs/products/valkey service.
Creates and manages an Aiven for Valkey https://aiven.io/docs/products/valkey service.
---

# aiven_valkey (Resource)

Creates and manages an [Aiven for Valkey](https://aiven.io/docs/products/valkey) service.
Creates and manages an [Aiven for Valkey](https://aiven.io/docs/products/valkey) service.

## Example Usage

Expand Down
71 changes: 62 additions & 9 deletions docs/resources/valkey_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,59 @@
page_title: "aiven_valkey_user Resource - terraform-provider-aiven"
subcategory: ""
description: |-
Creates and manages an Aiven for Valkey https://aiven.io/docs/products/valkey user.
Creates and manages an Aiven for Valkey https://aiven.io/docs/products/valkey service user.
---

# aiven_valkey_user (Resource)

Creates and manages an [Aiven for Valkey](https://aiven.io/docs/products/valkey) user.
Creates and manages an [Aiven for Valkey](https://aiven.io/docs/products/valkey) service user.

## Example Usage

```terraform
# Example user with read-only access for analytics
resource "aiven_valkey_user" "read_analytics" {
project = data.aiven_project.example_project.project
service_name = aiven_valkey.example_valkey.service_name
username = "example-analytics-reader"
password = var.valkey_user_pw
valkey_acl_categories = [
"+@read"
]
valkey_acl_commands = [
"+get",
"+set",
"+mget",
"+hget",
"+zrange"
]
valkey_acl_keys = [
"analytics:*"
]
}
# Example user with restricted write access for session management
resource "aiven_valkey_user" "manage_sessions" {
project = data.aiven_project.example_project.project
service_name = aiven_valkey.example_valkey.service_name
username = "example-session-manager"
password = var.valkey_user_pw
valkey_acl_categories = [
"+@write",
"+@keyspace",
]
valkey_acl_commands = [
"+set",
"+del",
"+expire",
"-flushall",
"-flushdb"
]
valkey_acl_keys = [
"session:*"
]
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand All @@ -19,21 +64,21 @@ Creates and manages an [Aiven for Valkey](https://aiven.io/docs/products/valkey)

- `project` (String) The name of the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
- `service_name` (String) The name of the service that this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
- `username` (String) The actual name of the Valkey User. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
- `username` (String) Name of the Valkey service user. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.

### Optional

- `password` (String, Sensitive) The password of the Valkey User.
- `password` (String, Sensitive) The Valkey service user's password.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `valkey_acl_categories` (List of String) Defines command category rules. The field is required with`valkey_acl_commands` and `valkey_acl_keys`. Changing this property forces recreation of the resource.
- `valkey_acl_channels` (List of String) Defines the permitted pub/sub channel patterns. Changing this property forces recreation of the resource.
- `valkey_acl_commands` (List of String) Defines rules for individual commands. The field is required with`valkey_acl_categories` and `valkey_acl_keys`. Changing this property forces recreation of the resource.
- `valkey_acl_keys` (List of String) Defines key access rules. The field is required with`valkey_acl_categories` and `valkey_acl_keys`. Changing this property forces recreation of the resource.
- `valkey_acl_categories` (List of String) Allow or disallow command categories. To allow a category use the prefix `+@` and to disallow use `-@`. See the [Valkey documentation](https://valkey.io/topics/acl/) for details on the ACL feature. The field is required with`valkey_acl_commands` and `valkey_acl_keys`. Changing this property forces recreation of the resource.
- `valkey_acl_channels` (List of String) Allows and disallows access to pub/sub channels. Entries are defined as standard glob patterns. Changing this property forces recreation of the resource.
- `valkey_acl_commands` (List of String) Defines rules for individual commands. To allow a command use the prefix `+` and to disallow use `-`. The field is required with`valkey_acl_categories` and `valkey_acl_keys`. Changing this property forces recreation of the resource.
- `valkey_acl_keys` (List of String) Key access rules. Entries are defined as standard glob patterns. The field is required with`valkey_acl_categories` and `valkey_acl_keys`. Changing this property forces recreation of the resource.

### Read-Only

- `id` (String) The ID of this resource.
- `type` (String) Type of the user account. Tells whether the user is the primary account or a regular account.
- `type` (String) User account type, such as primary or regular account.

<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`
Expand All @@ -45,3 +90,11 @@ Optional:
- `delete` (String)
- `read` (String)
- `update` (String)

## Import

Import is supported using the following syntax:

```shell
terraform import aiven_valkey.example_valkey PROJECT/SERVICE_NAME/USERNAME
```
1 change: 1 addition & 0 deletions examples/resources/aiven_valkey_user/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import aiven_valkey.example_valkey PROJECT/SERVICE_NAME/USERNAME
42 changes: 42 additions & 0 deletions examples/resources/aiven_valkey_user/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Example user with read-only access for analytics
resource "aiven_valkey_user" "read_analytics" {
project = data.aiven_project.example_project.project
service_name = aiven_valkey.example_valkey.service_name
username = "example-analytics-reader"
password = var.valkey_user_pw
valkey_acl_categories = [
"+@read"
]
valkey_acl_commands = [
"+get",
"+set",
"+mget",
"+hget",
"+zrange"
]
valkey_acl_keys = [
"analytics:*"
]
}

# Example user with restricted write access for session management
resource "aiven_valkey_user" "manage_sessions" {
project = data.aiven_project.example_project.project
service_name = aiven_valkey.example_valkey.service_name
username = "example-session-manager"
password = var.valkey_user_pw
valkey_acl_categories = [
"+@write",
"+@keyspace",
]
valkey_acl_commands = [
"+set",
"+del",
"+expire",
"-flushall",
"-flushdb"
]
valkey_acl_keys = [
"session:*"
]
}
2 changes: 1 addition & 1 deletion internal/sdkprovider/service/valkey/valkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func valkeySchema() map[string]*schema.Schema {

func ResourceValkey() *schema.Resource {
return &schema.Resource{
Description: "Creates and manages an [Aiven for Valkey](https://aiven.io/docs/products/valkey) service.",
Description: "Creates and manages an [Aiven for Valkey](https://aiven.io/docs/products/valkey) service.",
CreateContext: schemautil.ResourceServiceCreateWrapper(schemautil.ServiceTypeValkey),
ReadContext: schemautil.ResourceServiceRead,
UpdateContext: schemautil.ResourceServiceUpdate,
Expand Down
16 changes: 8 additions & 8 deletions internal/sdkprovider/service/valkey/valkey_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ var aivenValkeyUserSchema = map[string]*schema.Schema{
Required: true,
ForceNew: true,
ValidateFunc: schemautil.GetServiceUserValidateFunc(),
Description: userconfig.Desc("The actual name of the Valkey User.").ForceNew().Referenced().Build(),
Description: userconfig.Desc("Name of the Valkey service user.").ForceNew().Referenced().Build(),
},
"password": {
Type: schema.TypeString,
Optional: true,
Sensitive: true,
Computed: true,
DiffSuppressFunc: schemautil.EmptyObjectDiffSuppressFunc,
Description: "The password of the Valkey User.",
Description: "The Valkey service user's password.",
},
"valkey_acl_categories": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
RequiredWith: []string{"valkey_acl_commands", "valkey_acl_keys"},
Description: userconfig.Desc("Defines command category rules.").RequiredWith("valkey_acl_commands", "valkey_acl_keys").ForceNew().Build(),
Description: userconfig.Desc("Allow or disallow command categories. To allow a category use the prefix `+@` and to disallow use `-@`. See the [Valkey documentation](https://valkey.io/topics/acl/) for details on the ACL feature.").RequiredWith("valkey_acl_commands", "valkey_acl_keys").ForceNew().Build(),
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand All @@ -46,7 +46,7 @@ var aivenValkeyUserSchema = map[string]*schema.Schema{
Optional: true,
ForceNew: true,
RequiredWith: []string{"valkey_acl_categories", "valkey_acl_keys"},
Description: userconfig.Desc("Defines rules for individual commands.").RequiredWith("valkey_acl_categories", "valkey_acl_keys").ForceNew().Build(),
Description: userconfig.Desc("Defines rules for individual commands. To allow a command use the prefix `+` and to disallow use `-`.").RequiredWith("valkey_acl_categories", "valkey_acl_keys").ForceNew().Build(),
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand All @@ -56,7 +56,7 @@ var aivenValkeyUserSchema = map[string]*schema.Schema{
Optional: true,
ForceNew: true,
RequiredWith: []string{"valkey_acl_categories", "valkey_acl_commands"},
Description: userconfig.Desc("Defines key access rules.").RequiredWith("valkey_acl_categories", "valkey_acl_keys").ForceNew().Build(),
Description: userconfig.Desc("Key access rules. Entries are defined as standard glob patterns.").RequiredWith("valkey_acl_categories", "valkey_acl_keys").ForceNew().Build(),
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand All @@ -65,7 +65,7 @@ var aivenValkeyUserSchema = map[string]*schema.Schema{
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Description: userconfig.Desc("Defines the permitted pub/sub channel patterns.").ForceNew().Build(),
Description: userconfig.Desc("Allows and disallows access to pub/sub channels. Entries are defined as standard glob patterns.").ForceNew().Build(),
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand All @@ -75,13 +75,13 @@ var aivenValkeyUserSchema = map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Computed: true,
Description: "Type of the user account. Tells whether the user is the primary account or a regular account.",
Description: "User account type, such as primary or regular account.",
},
}

func ResourceValkeyUser() *schema.Resource {
return &schema.Resource{
Description: "Creates and manages an [Aiven for Valkey](https://aiven.io/docs/products/valkey) user.",
Description: "Creates and manages an [Aiven for Valkey](https://aiven.io/docs/products/valkey) service user.",
CreateContext: common.WithGenClient(resourceValkeyUserCreate),
UpdateContext: common.WithGenClient(resourceValkeyUserUpdate),
ReadContext: common.WithGenClient(resourceValkeyUserRead),
Expand Down

0 comments on commit dee70ec

Please sign in to comment.