Skip to content

Commit 2cd463c

Browse files
authored
Adds dataset_size_in_gb attribute (#564)
* adds dataset_size_in_gb attribute * increment Go API version * addresses PR comments * adds dataset_size_in_gb attribute * addresses PR comments * fix issue with update * fix UT and add to docs
1 parent 0726603 commit 2cd463c

15 files changed

+237
-105
lines changed

docs/data-sources/rediscloud_active_active_subscription_database.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ data "rediscloud_active_active_subscription_database" "example" {
4343
`id` is set to the ID of the found subscription and database in the following format: `{subscription_id}/{db_id}`
4444

4545
* `memory_limit_in_gb` - The maximum memory usage for the database.
46+
* `dataset_size_in_gb` - Maximum amount of data in the dataset for this specific database in GB.
4647
* `support_oss_cluster_api` - Supports the Redis open-source (OSS) Cluster API.
4748
* `external_endpoint_for_oss_cluster_api` - Use the external endpoint for open-source (OSS) Cluster API.
4849
* `enable_tls` - Enable TLS for database.

docs/data-sources/rediscloud_database.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ data "rediscloud_database" "example" {
4343
* `name` - The name of the database
4444
* `protocol` - The protocol of the database.
4545
* `memory_limit_in_gb` - The maximum memory usage for the database.
46+
* `dataset_size_in_gb` - Maximum amount of data in the dataset for this specific database in GB.
4647
* `support_oss_cluster_api` - Supports the Redis open-source (OSS) Cluster API.
4748
* `resp_version` - Either `resp2` or `resp3`. Database's RESP version.
4849
* `replica_of` - The set of Redis database URIs, in the format `redis://user:password@host:port`, that this

docs/resources/rediscloud_active_active_subscription_database.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ output "us-east-2-private-endpoints" {
9090
The following arguments are supported:
9191
* `subscription_id`: (Required) The ID of the Active-Active subscription to create the database in. **Modifying this attribute will force creation of a new resource.**
9292
* `name` - (Required) A meaningful name to identify the database. **Modifying this attribute will force creation of a new resource.**
93-
* `memory_limit_in_gb` - (Required) Maximum memory usage for this specific database, including replication and other overhead
93+
* `memory_limit_in_gb` - (Optional - **Required if `dataset_size_in_gb` is unset**) Maximum memory usage for this specific database, including replication and other overhead **Deprecated in favor of `dataset_size_in_gb` - not possible to import databases with this attribute set**
94+
* `dataset_size_in_gb` - (Optional - **Required if `memory_limit_in_gb` is unset**) The maximum amount of data in the dataset for this specific database is in GB
9495
* `support_oss_cluster_api` - (Optional) Support Redis open-source (OSS) Cluster API. Default: ‘false’
9596
* `external_endpoint_for_oss_cluster_api` - (Optional) Should use the external endpoint for open-source (OSS) Cluster API.
9697
Can only be enabled if OSS Cluster API support is enabled. Default: 'false'
@@ -178,3 +179,5 @@ $ terraform import rediscloud_active_active_subscription_database.database-resou
178179

179180
Note: Due to constraints in the Redis Cloud API, the import process will not import global attributes or override region attributes. If you wish to use these attributes in your Terraform configuration, you will need to manually add them to your Terraform configuration and run `terraform apply` to update the database.
180181

182+
Additionally, the `memory_limit_in_gb` cannot be set during imports as it is deprecated. If you need to set the `memory_limit_in_gb` attribute, you will need to create a new database resource. It is recommended to use the `dataset_size_in_gb` attribute instead.
183+

docs/resources/rediscloud_subscription.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ resource "rediscloud_subscription" "subscription-resource" {
4848
// This block needs to be defined for provisioning a new subscription.
4949
// This allows creation of a well-optimized hardware specification for databases in the cluster
5050
creation_plan {
51-
memory_limit_in_gb = 15
51+
dataset_size_in_gb = 15
5252
quantity = 1
5353
replication = true
5454
throughput_measurement_by = "operations-per-second"
@@ -98,7 +98,8 @@ The `cloud_provider` block supports:
9898

9999
The `creation_plan` block supports:
100100

101-
* `memory_limit_in_gb` - (Required) Maximum memory usage that will be used for your largest planned database.
101+
* `memory_limit_in_gb` - (Required) Maximum memory usage that will be used for your largest planned database. You can not set both dataset_size_in_gb and memory_limit_in_gb. **Deprecated: Use `dataset_size_in_gb` instead**
102+
* `dataset_size_in_gb` - (Required) The maximum amount of data in the dataset for this specific database is in GB. You can not set both dataset_size_in_gb and memory_limit_in_gb.
102103
* `modules` - (Optional) a list of modules that will be used by the databases in this subscription. Not currently compatible with ‘ram-and-flash’ memory storage.
103104
Example: `modules = ["RedisJSON", "RediSearch", "RedisTimeSeries", "RedisBloom"]`
104105
* `support_oss_cluster_api` - (Optional) Support Redis open-source (OSS) Cluster API. Default: ‘false’

docs/resources/rediscloud_subscription_database.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ resource "rediscloud_subscription" "subscription-resource" {
3838
// This block needs to be defined for provisioning a new subscription.
3939
// This allows creation of a well-optimized hardware specification for databases in the cluster
4040
creation_plan {
41-
memory_limit_in_gb = 15
41+
dataset_size_in_gb = 15
4242
quantity = 1
4343
replication=true
4444
throughput_measurement_by = "operations-per-second"
@@ -51,7 +51,7 @@ resource "rediscloud_subscription" "subscription-resource" {
5151
resource "rediscloud_subscription_database" "database-resource" {
5252
subscription_id = rediscloud_subscription.subscription-resource.id
5353
name = "database-name"
54-
memory_limit_in_gb = 15
54+
dataset_size_in_gb = 15
5555
data_persistence = "aof-every-write"
5656
throughput_measurement_by = "operations-per-second"
5757
throughput_measurement_value = 20000
@@ -82,7 +82,8 @@ The following arguments are supported:
8282
* `name` - (Required) A meaningful name to identify the database
8383
* `throughput_measurement_by` - (Required) Throughput measurement method that will be used by your databases. Either `number-of-shards` or `operations-per-second`. **`number-of-shards` is deprecated and only supported for legacy deployments.**
8484
* `throughput_measurement_value` - (Required) Throughput value (as applies to selected measurement method)
85-
* `memory_limit_in_gb` - (Required) Maximum memory usage for this specific database
85+
* `memory_limit_in_gb` - (Optional - **Required if `dataset_size_in_gb` is unset**) Maximum memory usage for this specific database, including replication and other overhead **Deprecated in favor of `dataset_size_in_gb` - not possible to import databases with this attribute set**
86+
* `dataset_size_in_gb` - (Optional - **Required if `memory_limit_in_gb` is unset**) The maximum amount of data in the dataset for this specific database is in GB
8687
* `protocol` - (Optional) The protocol that will be used to access the database, (either ‘redis’ or ‘memcached’) Default: ‘redis’. **Modifying this attribute will force creation of a new resource.**
8788
* `support_oss_cluster_api` - (Optional) Support Redis open-source (OSS) Cluster API. Default: ‘false’
8889
* `resp_version` - (Optional) Either `resp2` or `resp3`. Database's RESP version. Must be compatible with the Redis version.
@@ -188,3 +189,4 @@ The `response` block `latest_import_status` contains:
188189
$ terraform import rediscloud_subscription_database.database-resource 123456/12345678
189190
```
190191

192+
Note: Due to constraints in the Redis Cloud API, the `memory_limit_in_gb` cannot be set during imports as it is deprecated. If you need to set the `memory_limit_in_gb` attribute, you will need to create a new database resource. It is recommended to use the `dataset_size_in_gb` attribute instead.

provider/datasource_rediscloud_active_active_database.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package provider
33
import (
44
"context"
55
"fmt"
6+
67
"github.com/RedisLabs/rediscloud-go-api/redis"
78
"github.com/RedisLabs/rediscloud-go-api/service/databases"
89
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -33,7 +34,12 @@ func dataSourceRedisCloudActiveActiveDatabase() *schema.Resource {
3334
Optional: true,
3435
},
3536
"memory_limit_in_gb": {
36-
Description: "Maximum memory usage for this specific database",
37+
Description: "(Deprecated) Maximum memory usage for this specific database",
38+
Type: schema.TypeFloat,
39+
Computed: true,
40+
},
41+
"dataset_size_in_gb": {
42+
Description: "Maximum amount of data in the dataset for this specific database in GB",
3743
Type: schema.TypeFloat,
3844
Computed: true,
3945
},
@@ -284,6 +290,9 @@ func dataSourceRedisCloudActiveActiveDatabaseRead(ctx context.Context, d *schema
284290
if err := d.Set("memory_limit_in_gb", redis.Float64(*db.CrdbDatabases[0].MemoryLimitInGB)); err != nil {
285291
return diag.FromErr(err)
286292
}
293+
if err := d.Set("dataset_size_in_gb", redis.Float64(*db.CrdbDatabases[0].DatasetSizeInGB)); err != nil {
294+
return diag.FromErr(err)
295+
}
287296
if err := d.Set("support_oss_cluster_api", redis.BoolValue(db.SupportOSSClusterAPI)); err != nil {
288297
return diag.FromErr(err)
289298
}

provider/datasource_rediscloud_pro_database.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package provider
33
import (
44
"context"
55
"fmt"
6+
"regexp"
7+
"strconv"
8+
69
"github.com/RedisLabs/rediscloud-go-api/redis"
710
"github.com/RedisLabs/rediscloud-go-api/service/databases"
811
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
912
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1013
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
11-
"regexp"
12-
"strconv"
1314
)
1415

1516
func dataSourceRedisCloudProDatabase() *schema.Resource {
@@ -53,6 +54,11 @@ func dataSourceRedisCloudProDatabase() *schema.Resource {
5354
Type: schema.TypeFloat,
5455
Computed: true,
5556
},
57+
"dataset_size_in_gb": {
58+
Description: "Maximum amount of data in the dataset for this specific database in GB",
59+
Type: schema.TypeFloat,
60+
Computed: true,
61+
},
5662
"support_oss_cluster_api": {
5763
Description: "Supports the Redis open-source (OSS) Cluster API",
5864
Type: schema.TypeBool,
@@ -374,6 +380,9 @@ func dataSourceRedisCloudProDatabaseRead(ctx context.Context, d *schema.Resource
374380
if err := d.Set("memory_limit_in_gb", redis.Float64Value(db.MemoryLimitInGB)); err != nil {
375381
return diag.FromErr(err)
376382
}
383+
if err := d.Set("dataset_size_in_gb", redis.Float64Value(db.DatasetSizeInGB)); err != nil {
384+
return diag.FromErr(err)
385+
}
377386
if err := d.Set("support_oss_cluster_api", redis.BoolValue(db.SupportOSSClusterAPI)); err != nil {
378387
return diag.FromErr(err)
379388
}

provider/rediscloud_active_active_database_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
3737
Check: resource.ComposeAggregateTestCheckFunc(
3838
// Test resource
3939
resource.TestCheckResourceAttr(resourceName, "name", name),
40-
resource.TestCheckResourceAttr(resourceName, "memory_limit_in_gb", "3"),
40+
resource.TestCheckResourceAttr(resourceName, "dataset_size_in_gb", "3"),
4141
resource.TestCheckResourceAttr(resourceName, "support_oss_cluster_api", "false"),
4242
resource.TestCheckResourceAttr(resourceName, "global_data_persistence", "none"),
4343
resource.TestCheckResourceAttr(resourceName, "external_endpoint_for_oss_cluster_api", "false"),
@@ -107,7 +107,7 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
107107
resource.TestCheckResourceAttrSet(datasourceName, "subscription_id"),
108108
resource.TestCheckResourceAttrSet(datasourceName, "db_id"),
109109
resource.TestCheckResourceAttr(datasourceName, "name", name),
110-
resource.TestCheckResourceAttr(datasourceName, "memory_limit_in_gb", "3"),
110+
resource.TestCheckResourceAttr(datasourceName, "dataset_size_in_gb", "3"),
111111
resource.TestCheckResourceAttr(datasourceName, "support_oss_cluster_api", "false"),
112112
resource.TestCheckResourceAttr(datasourceName, "external_endpoint_for_oss_cluster_api", "false"),
113113
resource.TestCheckResourceAttr(datasourceName, "enable_tls", "false"),
@@ -124,7 +124,7 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
124124
Config: fmt.Sprintf(testAccResourceRedisCloudActiveActiveDatabaseUpdate, subscriptionName, name),
125125
Check: resource.ComposeAggregateTestCheckFunc(
126126
// Test resource
127-
resource.TestCheckResourceAttr(resourceName, "memory_limit_in_gb", "1"),
127+
resource.TestCheckResourceAttr(resourceName, "dataset_size_in_gb", "1"),
128128
resource.TestCheckResourceAttr(resourceName, "support_oss_cluster_api", "true"),
129129
resource.TestCheckResourceAttr(resourceName, "external_endpoint_for_oss_cluster_api", "true"),
130130
resource.TestCheckResourceAttr(resourceName, "global_data_persistence", "aof-every-1-second"),
@@ -147,7 +147,7 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
147147
resource.TestCheckResourceAttr(resourceName, "override_region.0.override_global_source_ips.#", "0"),
148148

149149
// Test datasource
150-
resource.TestCheckResourceAttr(datasourceName, "memory_limit_in_gb", "1"),
150+
resource.TestCheckResourceAttr(datasourceName, "dataset_size_in_gb", "1"),
151151
resource.TestCheckResourceAttr(datasourceName, "support_oss_cluster_api", "true"),
152152
resource.TestCheckResourceAttr(datasourceName, "external_endpoint_for_oss_cluster_api", "true"),
153153
),
@@ -156,7 +156,7 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
156156
{
157157
Config: fmt.Sprintf(testAccResourceRedisCloudActiveActiveDatabaseUpdateNoAlerts, subscriptionName, name),
158158
Check: resource.ComposeAggregateTestCheckFunc(
159-
resource.TestCheckResourceAttr(resourceName, "memory_limit_in_gb", "1"),
159+
resource.TestCheckResourceAttr(resourceName, "dataset_size_in_gb", "1"),
160160
resource.TestCheckResourceAttr(resourceName, "support_oss_cluster_api", "true"),
161161
resource.TestCheckResourceAttr(resourceName, "external_endpoint_for_oss_cluster_api", "true"),
162162
resource.TestCheckResourceAttr(resourceName, "global_data_persistence", "aof-every-1-second"),
@@ -259,7 +259,7 @@ const activeActiveSubscriptionBoilerplate = `
259259
cloud_provider = "AWS"
260260
261261
creation_plan {
262-
memory_limit_in_gb = 1
262+
dataset_size_in_gb = 1
263263
quantity = 1
264264
region {
265265
region = "us-east-1"
@@ -283,7 +283,7 @@ const testAccResourceRedisCloudActiveActiveDatabase = activeActiveSubscriptionBo
283283
resource "rediscloud_active_active_subscription_database" "example" {
284284
subscription_id = rediscloud_active_active_subscription.example.id
285285
name = "%s"
286-
memory_limit_in_gb = 3
286+
dataset_size_in_gb = 3
287287
support_oss_cluster_api = false
288288
external_endpoint_for_oss_cluster_api = false
289289
enable_tls = false
@@ -328,7 +328,7 @@ const testAccResourceRedisCloudActiveActiveDatabaseUpdate = activeActiveSubscrip
328328
resource "rediscloud_active_active_subscription_database" "example" {
329329
subscription_id = rediscloud_active_active_subscription.example.id
330330
name = "%s"
331-
memory_limit_in_gb = 1
331+
dataset_size_in_gb = 1
332332
support_oss_cluster_api = true
333333
external_endpoint_for_oss_cluster_api = true
334334
@@ -362,7 +362,7 @@ const testAccResourceRedisCloudActiveActiveDatabaseUpdateNoAlerts = activeActive
362362
resource "rediscloud_active_active_subscription_database" "example" {
363363
subscription_id = rediscloud_active_active_subscription.example.id
364364
name = "%s"
365-
memory_limit_in_gb = 1
365+
dataset_size_in_gb = 1
366366
support_oss_cluster_api = true
367367
external_endpoint_for_oss_cluster_api = true
368368
@@ -385,7 +385,7 @@ const testAccResourceRedisCloudActiveActiveDatabaseImport = activeActiveSubscrip
385385
resource "rediscloud_active_active_subscription_database" "example" {
386386
subscription_id = rediscloud_active_active_subscription.example.id
387387
name = "%s"
388-
memory_limit_in_gb = 1
388+
dataset_size_in_gb = 1
389389
}
390390
`
391391

@@ -401,7 +401,7 @@ resource "rediscloud_active_active_subscription" "example" {
401401
redis_version = "latest"
402402
403403
creation_plan {
404-
memory_limit_in_gb = 1
404+
dataset_size_in_gb = 1
405405
quantity = 1
406406
region {
407407
region = "us-east-1"
@@ -421,7 +421,7 @@ resource "rediscloud_active_active_subscription" "example" {
421421
resource "rediscloud_active_active_subscription_database" "example" {
422422
subscription_id = rediscloud_active_active_subscription.example.id
423423
name = "%s"
424-
memory_limit_in_gb = 3
424+
dataset_size_in_gb = 3
425425
support_oss_cluster_api = false
426426
external_endpoint_for_oss_cluster_api = false
427427
enable_tls = false
@@ -455,7 +455,7 @@ const testAccResourceRedisCloudActiveActiveDatabaseInvalidTimeUtc = activeActive
455455
resource "rediscloud_active_active_subscription_database" "example" {
456456
subscription_id = rediscloud_active_active_subscription.example.id
457457
name = "%s"
458-
memory_limit_in_gb = 3
458+
dataset_size_in_gb = 3
459459
support_oss_cluster_api = false
460460
external_endpoint_for_oss_cluster_api = false
461461
enable_tls = false

0 commit comments

Comments
 (0)