Skip to content

Commit 55dba58

Browse files
committed
feat: adding global default user field to active active databases
1 parent df11e8e commit 55dba58

8 files changed

+49
-37
lines changed

.claude/settings.local.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ website/node_modules
3030
website/vendor
3131
vendor
3232
.vscode/
33+
.claude/
34+
CLAUDE.md
3335

3436
# Test exclusions
3537
!command/test-fixtures/**/*.tfstate

docs/resources/rediscloud_active_active_subscription_database.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ The following arguments are supported:
103103
* `global_alert` - (Optional) A block defining Redis database alert of regions that don't override global settings, documented below, can be specified multiple times. (either: 'dataset-size', 'datasets-size', 'throughput-higher-than', 'throughput-lower-than', 'latency', 'syncsource-error', 'syncsource-lag' or 'connections-limit')
104104
* `global_modules` - (Optional) A list of modules to be enabled on all deployments of this database. Supported modules: `RedisJSON`, `RediSearch`. Ignored after database creation.
105105
* `global_source_ips` - (Optional) List of source IP addresses or subnet masks of regions that don't override global settings. If specified, Redis clients will be able to connect to this database only from within the specified source IP addresses ranges (example: ['192.168.10.0/32', '192.168.12.0/24'])
106+
* `global_enable_default_user` - (Optional) When 'true', enables connecting to the database with the 'default' user across all regions. Default: 'true'
106107
* `global_resp_version` - (Optional) Either 'resp2' or 'resp3'. Resp version for Crdb databases within the AA database. Must be compatible with Redis version.
107108
* `port` - (Optional) TCP port on which the database is available - must be between 10000 and 19999. **Modifying this attribute will force creation of a new resource.**
108109
* `override_region` - (Optional) Override region specific configuration, documented below

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.24.0
55
toolchain go1.24.1
66

77
require (
8-
github.com/RedisLabs/rediscloud-go-api v0.36.5
8+
github.com/RedisLabs/rediscloud-go-api v0.37.0
99
github.com/bflad/tfproviderlint v0.31.0
1010
github.com/hashicorp/go-cty v1.5.0
1111
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0
@@ -71,4 +71,4 @@ require (
7171
)
7272

7373
// for local development, uncomment this
74-
//replace github.com/RedisLabs/rediscloud-go-api => ../rediscloud-go-api
74+
replace github.com/RedisLabs/rediscloud-go-api => ../rediscloud-go-api

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
44
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
55
github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw=
66
github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
7-
github.com/RedisLabs/rediscloud-go-api v0.36.5 h1:zZ5C2+QHdfdlGqZDw3o2GMM7Wz5BhLUUW8U3yGFl1ck=
8-
github.com/RedisLabs/rediscloud-go-api v0.36.5/go.mod h1:Hkh3i/EsHnyfgV0ijednbofz/EmZC3sFnSNNruF3G6I=
97
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
108
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
119
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=

provider/rediscloud_active_active_database_test.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package provider
33
import (
44
"context"
55
"fmt"
6-
client2 "github.com/RedisLabs/terraform-provider-rediscloud/provider/client"
76
"os"
87
"regexp"
98
"strconv"
109
"testing"
1110

1211
"github.com/RedisLabs/rediscloud-go-api/redis"
12+
"github.com/RedisLabs/terraform-provider-rediscloud/provider/client"
1313
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
1414
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1515
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
@@ -39,7 +39,7 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
3939
Check: resource.ComposeAggregateTestCheckFunc(
4040
// Test resource
4141
resource.TestCheckResourceAttr(databaseResourceName, "name", databaseName),
42-
resource.TestCheckResourceAttr(databaseResourceName, "dataset_size_in_gb", "3"),
42+
resource.TestCheckResourceAttr(databaseResourceName, "dataset_size_in_gb", "1"),
4343
resource.TestCheckResourceAttr(databaseResourceName, "support_oss_cluster_api", "false"),
4444
resource.TestCheckResourceAttr(databaseResourceName, "global_data_persistence", "none"),
4545
resource.TestCheckResourceAttr(databaseResourceName, "external_endpoint_for_oss_cluster_api", "false"),
@@ -52,6 +52,7 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
5252
resource.TestCheckResourceAttr(databaseResourceName, "global_modules.#", "1"),
5353
resource.TestCheckResourceAttr(databaseResourceName, "global_modules.0", "RedisJSON"),
5454
resource.TestCheckResourceAttr(databaseResourceName, "global_source_ips.#", "2"),
55+
resource.TestCheckResourceAttr(databaseResourceName, "global_enable_default_user", "true"),
5556

5657
resource.TestCheckResourceAttr(databaseResourceName, "override_region.#", "2"),
5758
resource.TestCheckResourceAttr(databaseResourceName, "override_region.0.name", "us-east-1"),
@@ -84,8 +85,8 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
8485
return fmt.Errorf("couldn't parse the subscription ID: %s", redis.StringValue(&r.Primary.ID))
8586
}
8687

87-
client := testProvider.Meta().(*client2.ApiClient)
88-
sub, err := client.Client.Subscription.Get(context.TODO(), subId)
88+
apiClient := testProvider.Meta().(*client.ApiClient)
89+
sub, err := apiClient.Client.Subscription.Get(context.TODO(), subId)
8990
if err != nil {
9091
return err
9192
}
@@ -94,7 +95,7 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
9495
return fmt.Errorf("unexpected name value: %s", redis.StringValue(sub.Name))
9596
}
9697

97-
listDb := client.Client.Database.List(context.TODO(), subId)
98+
listDb := apiClient.Client.Database.List(context.TODO(), subId)
9899
if listDb.Next() != true {
99100
return fmt.Errorf("no database found: %s", listDb.Err())
100101
}
@@ -109,7 +110,7 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
109110
resource.TestCheckResourceAttrSet(datasourceName, "subscription_id"),
110111
resource.TestCheckResourceAttrSet(datasourceName, "db_id"),
111112
resource.TestCheckResourceAttr(datasourceName, "name", databaseName),
112-
resource.TestCheckResourceAttr(datasourceName, "dataset_size_in_gb", "3"),
113+
resource.TestCheckResourceAttr(datasourceName, "dataset_size_in_gb", "1"),
113114
resource.TestCheckResourceAttr(datasourceName, "support_oss_cluster_api", "false"),
114115
resource.TestCheckResourceAttr(datasourceName, "external_endpoint_for_oss_cluster_api", "false"),
115116
resource.TestCheckResourceAttr(datasourceName, "enable_tls", "false"),
@@ -118,6 +119,7 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
118119
resource.TestCheckResourceAttr(datasourceName, "data_eviction", "volatile-lru"),
119120
resource.TestCheckResourceAttr(datasourceName, "global_modules.#", "1"),
120121
resource.TestCheckResourceAttr(datasourceName, "global_modules.0", "RedisJSON"),
122+
resource.TestCheckResourceAttr(datasourceName, "global_enable_default_user", "true"),
121123

122124
resource.TestCheckResourceAttr(datasourceName, "tags.deployment_family", "blue"),
123125
resource.TestCheckResourceAttr(datasourceName, "tags.priority", "code-2"),
@@ -145,6 +147,7 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
145147
resource.TestCheckResourceAttr(databaseResourceName, "global_alert.#", "1"),
146148
resource.TestCheckResourceAttr(databaseResourceName, "global_alert.0.name", "dataset-size"),
147149
resource.TestCheckResourceAttr(databaseResourceName, "global_alert.0.value", "60"),
150+
resource.TestCheckResourceAttr(databaseResourceName, "global_enable_default_user", "false"),
148151
resource.TestCheckResourceAttr(databaseResourceName, "redis_version", "7.2"),
149152

150153
// Changes are ignored after creation
@@ -299,7 +302,7 @@ const testAccResourceRedisCloudActiveActiveDatabase = activeActiveSubscriptionBo
299302
resource "rediscloud_active_active_subscription_database" "example" {
300303
subscription_id = rediscloud_active_active_subscription.example.id
301304
name = "%s"
302-
dataset_size_in_gb = 3
305+
dataset_size_in_gb = 1
303306
support_oss_cluster_api = false
304307
external_endpoint_for_oss_cluster_api = false
305308
enable_tls = false
@@ -312,6 +315,7 @@ resource "rediscloud_active_active_subscription_database" "example" {
312315
name = "dataset-size"
313316
value = 1
314317
}
318+
global_enable_default_user = true
315319
global_modules = ["RedisJSON"]
316320
override_region {
317321
name = "us-east-1"
@@ -360,6 +364,7 @@ resource "rediscloud_active_active_subscription_database" "example" {
360364
name = "dataset-size"
361365
value = 60
362366
}
367+
global_enable_default_user = false
363368
global_modules = []
364369
365370
override_region {
@@ -442,7 +447,7 @@ resource "rediscloud_active_active_subscription" "example" {
442447
resource "rediscloud_active_active_subscription_database" "example" {
443448
subscription_id = rediscloud_active_active_subscription.example.id
444449
name = "%s"
445-
dataset_size_in_gb = 3
450+
dataset_size_in_gb = 1
446451
support_oss_cluster_api = false
447452
external_endpoint_for_oss_cluster_api = false
448453
enable_tls = false
@@ -476,7 +481,7 @@ const testAccResourceRedisCloudActiveActiveDatabaseInvalidTimeUtc = activeActive
476481
resource "rediscloud_active_active_subscription_database" "example" {
477482
subscription_id = rediscloud_active_active_subscription.example.id
478483
name = "%s"
479-
dataset_size_in_gb = 3
484+
dataset_size_in_gb = 1
480485
support_oss_cluster_api = false
481486
external_endpoint_for_oss_cluster_api = false
482487
enable_tls = false

provider/resource_rediscloud_active_active_database.go

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ package provider
22

33
import (
44
"context"
5-
"github.com/RedisLabs/terraform-provider-rediscloud/provider/client"
6-
"github.com/RedisLabs/terraform-provider-rediscloud/provider/utils"
75
"log"
86
"regexp"
97
"strings"
108
"time"
119

1210
"github.com/RedisLabs/rediscloud-go-api/redis"
1311
"github.com/RedisLabs/rediscloud-go-api/service/databases"
12+
"github.com/RedisLabs/terraform-provider-rediscloud/provider/client"
13+
"github.com/RedisLabs/terraform-provider-rediscloud/provider/utils"
1414
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1515
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
1616
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -200,6 +200,12 @@ func resourceRedisCloudActiveActiveDatabase() *schema.Resource {
200200
ValidateDiagFunc: validation.ToDiagFunc(validation.IsCIDR),
201201
},
202202
},
203+
"global_enable_default_user": {
204+
Description: "When 'true', enables connecting to the database with the 'default' user across all regions. Default: 'true'",
205+
Type: schema.TypeBool,
206+
Optional: true,
207+
Default: true,
208+
},
203209
"override_region": {
204210
Description: "Region-specific configuration parameters to override the global configuration",
205211
Type: schema.TypeSet,
@@ -733,12 +739,9 @@ func resourceRedisCloudActiveActiveDatabaseUpdate(ctx context.Context, d *schema
733739

734740
// Populate the database update request with the required fields
735741
update := databases.UpdateActiveActiveDatabase{
736-
SupportOSSClusterAPI: redis.Bool(d.Get("support_oss_cluster_api").(bool)),
737-
UseExternalEndpointForOSSClusterAPI: redis.Bool(d.Get("external_endpoint_for_oss_cluster_api").(bool)),
738-
DataEvictionPolicy: redis.String(d.Get("data_eviction").(string)),
739-
GlobalAlerts: &updateAlerts,
740-
GlobalSourceIP: globalSourceIps,
741-
Regions: regions,
742+
GlobalAlerts: &updateAlerts,
743+
GlobalSourceIP: globalSourceIps,
744+
Regions: regions,
742745
}
743746

744747
// One of the following fields must be set in the request, validation is handled in the schema (ExactlyOneOf)
@@ -763,6 +766,22 @@ func resourceRedisCloudActiveActiveDatabaseUpdate(ctx context.Context, d *schema
763766
update.GlobalDataPersistence = redis.String(d.Get("global_data_persistence").(string))
764767
}
765768

769+
if v, ok := d.GetOk("global_enable_default_user"); ok {
770+
update.GlobalEnableDefaultUser = redis.Bool(v.(bool))
771+
}
772+
773+
if v, ok := d.GetOk("support_oss_cluster_api"); ok {
774+
update.SupportOSSClusterAPI = redis.Bool(v.(bool))
775+
}
776+
777+
if v, ok := d.GetOk("external_endpoint_for_oss_cluster_api"); ok {
778+
update.UseExternalEndpointForOSSClusterAPI = redis.Bool(v.(bool))
779+
}
780+
781+
if v, ok := d.GetOk("data_eviction"); ok {
782+
update.DataEvictionPolicy = redis.String(v.(string))
783+
}
784+
766785
//The cert validation is done by the API (HTTP 400 is returned if it's invalid).
767786
clientSSLCertificate := d.Get("client_ssl_certificate").(string)
768787
clientTLSCertificates := interfaceToStringSlice(d.Get("client_tls_certificates").([]interface{}))
@@ -788,8 +807,6 @@ func resourceRedisCloudActiveActiveDatabaseUpdate(ctx context.Context, d *schema
788807
}
789808
}
790809

791-
update.UseExternalEndpointForOSSClusterAPI = redis.Bool(d.Get("external_endpoint_for_oss_cluster_api").(bool))
792-
793810
err = api.Client.Database.ActiveActiveUpdate(ctx, subId, dbId, update)
794811
if err != nil {
795812
return diag.FromErr(err)

provider/resource_rediscloud_active_active_subscription_regions_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package provider
33
import (
44
"context"
55
"fmt"
6-
client2 "github.com/RedisLabs/terraform-provider-rediscloud/provider/client"
76
"strconv"
87
"testing"
98

109
"github.com/RedisLabs/rediscloud-go-api/redis"
10+
"github.com/RedisLabs/terraform-provider-rediscloud/provider/client"
1111
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
1212
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1313
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
@@ -60,8 +60,8 @@ func TestAccResourceRedisCloudActiveActiveSubscriptionRegions_CRUDI(t *testing.T
6060
return err
6161
}
6262

63-
client := testProvider.Meta().(*client2.ApiClient)
64-
sub, err := client.Client.Subscription.Get(context.TODO(), subId)
63+
apiClient := testProvider.Meta().(*client.ApiClient)
64+
sub, err := apiClient.Client.Subscription.Get(context.TODO(), subId)
6565
if err != nil {
6666
return err
6767
}

0 commit comments

Comments
 (0)