Skip to content

Commit 427fca0

Browse files
committed
chore: extracting out terraforms to config files. Updating ACL tests as they cross-referenced the same HCL
1 parent b65f145 commit 427fca0

13 files changed

+643
-339
lines changed

provider/pro/resource_rediscloud_pro_database.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -958,9 +958,6 @@ func skipDiffIfIntervalIs12And12HourTimeDiff(k, oldValue, newValue string, d *sc
958958

959959
func customizeDiff() schema.CustomizeDiffFunc {
960960
return func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error {
961-
if err := validateQueryPerformanceFactor()(ctx, diff, meta); err != nil {
962-
return err
963-
}
964961
if err := validateModulesForRedis8()(ctx, diff, meta); err != nil {
965962
return err
966963
}
@@ -971,46 +968,6 @@ func customizeDiff() schema.CustomizeDiffFunc {
971968
}
972969
}
973970

974-
func validateQueryPerformanceFactor() schema.CustomizeDiffFunc {
975-
return func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error {
976-
// Check if "query_performance_factor" is set
977-
qpf, qpfExists := diff.GetOk("query_performance_factor")
978-
979-
if qpfExists && qpf.(string) != "" {
980-
// Check if Redis version is 8.0 or later
981-
redisVersion, _ := diff.GetOk("redis_version")
982-
if redisVersion != nil && redisVersion.(string) >= "8.0" {
983-
// Redis 8.0+ has RediSearch bundled by default, no need to check modules
984-
return nil
985-
}
986-
987-
// Ensure "modules" is explicitly defined in the HCL for Redis < 8.0
988-
_, modulesExists := diff.GetOkExists("modules")
989-
990-
if !modulesExists {
991-
return fmt.Errorf(`"query_performance_factor" requires the "modules" key to be explicitly defined in HCL`)
992-
}
993-
994-
// Retrieve modules as a slice of interfaces
995-
rawModules := diff.Get("modules").(*schema.Set).List()
996-
997-
// Convert modules to []map[string]interface{}
998-
var modules []map[string]interface{}
999-
for _, rawModule := range rawModules {
1000-
if moduleMap, ok := rawModule.(map[string]interface{}); ok {
1001-
modules = append(modules, moduleMap)
1002-
}
1003-
}
1004-
1005-
// Check if "RediSearch" exists
1006-
if !containsDBModule(modules, "RediSearch") {
1007-
return fmt.Errorf(`"query_performance_factor" requires the "modules" list to contain "RediSearch"`)
1008-
}
1009-
}
1010-
return nil
1011-
}
1012-
}
1013-
1014971
// Helper function to check if a module exists
1015972
func containsDBModule(modules []map[string]interface{}, moduleName string) bool {
1016973
for _, module := range modules {
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
locals {
2+
rediscloud_cloud_account = "%s"
3+
rediscloud_subscription_name = "%s"
4+
rediscloud_database_password = "%s"
5+
}
6+
7+
data "rediscloud_payment_method" "card" {
8+
card_type = "Visa"
9+
last_four_numbers = "5556"
10+
}
11+
12+
data "rediscloud_cloud_account" "account" {
13+
exclude_internal_account = true
14+
provider_type = "AWS"
15+
name = local.rediscloud_cloud_account
16+
}
17+
18+
resource "rediscloud_subscription" "example" {
19+
name = local.rediscloud_subscription_name
20+
payment_method_id = data.rediscloud_payment_method.card.id
21+
cloud_provider {
22+
provider = data.rediscloud_cloud_account.account.provider_type
23+
cloud_account_id = data.rediscloud_cloud_account.account.id
24+
region {
25+
region = "eu-west-1"
26+
networking_deployment_cidr = "10.0.0.0/24"
27+
preferred_availability_zones = ["eu-west-1a"]
28+
}
29+
}
30+
31+
creation_plan {
32+
dataset_size_in_gb = 1
33+
quantity = 1
34+
replication = false
35+
throughput_measurement_by = "operations-per-second"
36+
throughput_measurement_value = 1000
37+
}
38+
}
39+
40+
resource "rediscloud_subscription_database" "example" {
41+
subscription_id = rediscloud_subscription.example.id
42+
name = "example"
43+
protocol = "redis"
44+
dataset_size_in_gb = 3
45+
data_persistence = "none"
46+
data_eviction = "allkeys-random"
47+
throughput_measurement_by = "operations-per-second"
48+
throughput_measurement_value = 1000
49+
password = local.rediscloud_database_password
50+
support_oss_cluster_api = false
51+
external_endpoint_for_oss_cluster_api = false
52+
replication = false
53+
average_item_size_in_bytes = 0
54+
client_ssl_certificate = ""
55+
periodic_backup_path = ""
56+
enable_default_user = true
57+
redis_version = "7.2"
58+
59+
alert {
60+
name = "dataset-size"
61+
value = 1
62+
}
63+
64+
modules = [
65+
{
66+
name = "RedisBloom"
67+
}
68+
]
69+
70+
tags = {
71+
"market" = "emea"
72+
"material" = "cardboard"
73+
}
74+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
locals {
2+
rediscloud_cloud_account = "%s"
3+
rediscloud_subscription_name = "%s"
4+
}
5+
6+
data "rediscloud_payment_method" "card" {
7+
card_type = "Visa"
8+
last_four_numbers = "5556"
9+
}
10+
11+
data "rediscloud_cloud_account" "account" {
12+
exclude_internal_account = true
13+
provider_type = "AWS"
14+
name = local.rediscloud_cloud_account
15+
}
16+
17+
resource "rediscloud_subscription" "example" {
18+
name = local.rediscloud_subscription_name
19+
payment_method_id = data.rediscloud_payment_method.card.id
20+
cloud_provider {
21+
provider = data.rediscloud_cloud_account.account.provider_type
22+
cloud_account_id = data.rediscloud_cloud_account.account.id
23+
region {
24+
region = "eu-west-1"
25+
networking_deployment_cidr = "10.0.0.0/24"
26+
preferred_availability_zones = ["eu-west-1a"]
27+
}
28+
}
29+
30+
creation_plan {
31+
dataset_size_in_gb = 1
32+
quantity = 1
33+
replication = false
34+
throughput_measurement_by = "operations-per-second"
35+
throughput_measurement_value = 1000
36+
}
37+
}
38+
39+
resource "rediscloud_subscription_database" "example" {
40+
subscription_id = rediscloud_subscription.example.id
41+
name = "example-no-protocol"
42+
dataset_size_in_gb = 1
43+
data_persistence = "none"
44+
throughput_measurement_by = "operations-per-second"
45+
throughput_measurement_value = 1000
46+
remote_backup {
47+
interval = "every-6-hours"
48+
time_utc = "16:00"
49+
storage_type = "aws-s3"
50+
storage_path = "uri://interval.not.12.or.24.hours.test"
51+
}
52+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
locals {
2+
rediscloud_cloud_account = "%s"
3+
rediscloud_subscription_name = "%s"
4+
database_name = "%s"
5+
}
6+
7+
data "rediscloud_payment_method" "card" {
8+
card_type = "Visa"
9+
last_four_numbers = "5556"
10+
}
11+
12+
data "rediscloud_cloud_account" "account" {
13+
exclude_internal_account = true
14+
provider_type = "AWS"
15+
name = local.rediscloud_cloud_account
16+
}
17+
18+
resource "rediscloud_subscription" "example" {
19+
name = local.rediscloud_subscription_name
20+
payment_method_id = data.rediscloud_payment_method.card.id
21+
memory_storage = "ram"
22+
allowlist {
23+
cidrs = ["192.168.0.0/16"]
24+
security_group_ids = []
25+
}
26+
cloud_provider {
27+
provider = data.rediscloud_cloud_account.account.provider_type
28+
cloud_account_id = data.rediscloud_cloud_account.account.id
29+
region {
30+
region = "eu-west-1"
31+
networking_deployment_cidr = "10.0.0.0/24"
32+
preferred_availability_zones = ["eu-west-1a"]
33+
}
34+
}
35+
creation_plan {
36+
dataset_size_in_gb = 1
37+
quantity = 1
38+
replication = false
39+
support_oss_cluster_api = false
40+
throughput_measurement_by = "operations-per-second"
41+
throughput_measurement_value = 1000
42+
modules = ["RedisJSON", "RedisBloom"]
43+
}
44+
}
45+
46+
resource "rediscloud_subscription_database" "example" {
47+
subscription_id = rediscloud_subscription.example.id
48+
name = local.database_name
49+
protocol = "redis"
50+
dataset_size_in_gb = 1
51+
data_persistence = "none"
52+
throughput_measurement_by = "operations-per-second"
53+
throughput_measurement_value = 1000
54+
modules = [
55+
{
56+
name = "RedisJSON"
57+
},
58+
{
59+
name = "RedisBloom"
60+
}
61+
]
62+
alert {
63+
name = "latency"
64+
value = 11
65+
}
66+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
locals {
2+
rediscloud_cloud_account = "%s"
3+
rediscloud_subscription_name = "%s"
4+
}
5+
6+
data "rediscloud_payment_method" "card" {
7+
card_type = "Visa"
8+
last_four_numbers = "5556"
9+
}
10+
11+
data "rediscloud_cloud_account" "account" {
12+
exclude_internal_account = true
13+
provider_type = "AWS"
14+
name = local.rediscloud_cloud_account
15+
}
16+
17+
resource "rediscloud_subscription" "example" {
18+
name = local.rediscloud_subscription_name
19+
payment_method_id = data.rediscloud_payment_method.card.id
20+
cloud_provider {
21+
provider = data.rediscloud_cloud_account.account.provider_type
22+
cloud_account_id = data.rediscloud_cloud_account.account.id
23+
region {
24+
region = "eu-west-1"
25+
networking_deployment_cidr = "10.0.0.0/24"
26+
preferred_availability_zones = ["eu-west-1a"]
27+
}
28+
}
29+
30+
creation_plan {
31+
dataset_size_in_gb = 1
32+
quantity = 1
33+
replication = false
34+
throughput_measurement_by = "operations-per-second"
35+
throughput_measurement_value = 1000
36+
}
37+
}
38+
39+
resource "rediscloud_subscription_database" "no_password_database" {
40+
subscription_id = rediscloud_subscription.example.id
41+
name = "example-no-password"
42+
protocol = "redis"
43+
dataset_size_in_gb = 1
44+
data_persistence = "none"
45+
throughput_measurement_by = "operations-per-second"
46+
throughput_measurement_value = 1000
47+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
locals {
2+
rediscloud_cloud_account = "%s"
3+
rediscloud_subscription_name = "%s"
4+
port_number = %d
5+
}
6+
7+
data "rediscloud_payment_method" "card" {
8+
card_type = "Visa"
9+
last_four_numbers = "5556"
10+
}
11+
12+
data "rediscloud_cloud_account" "account" {
13+
exclude_internal_account = true
14+
provider_type = "AWS"
15+
name = local.rediscloud_cloud_account
16+
}
17+
18+
resource "rediscloud_subscription" "example" {
19+
name = local.rediscloud_subscription_name
20+
payment_method_id = data.rediscloud_payment_method.card.id
21+
cloud_provider {
22+
provider = data.rediscloud_cloud_account.account.provider_type
23+
cloud_account_id = data.rediscloud_cloud_account.account.id
24+
region {
25+
region = "eu-west-1"
26+
networking_deployment_cidr = "10.0.0.0/24"
27+
preferred_availability_zones = ["eu-west-1a"]
28+
}
29+
}
30+
31+
creation_plan {
32+
dataset_size_in_gb = 1
33+
quantity = 1
34+
replication = false
35+
throughput_measurement_by = "operations-per-second"
36+
throughput_measurement_value = 1000
37+
}
38+
}
39+
40+
resource "rediscloud_subscription_database" "example" {
41+
subscription_id = rediscloud_subscription.example.id
42+
name = "example-no-protocol"
43+
dataset_size_in_gb = 1
44+
data_persistence = "none"
45+
throughput_measurement_by = "operations-per-second"
46+
throughput_measurement_value = 1000
47+
port = local.port_number
48+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
locals {
2+
rediscloud_cloud_account = "%s"
3+
rediscloud_subscription_name = "%s"
4+
port_number = %d
5+
resp_version = "%s"
6+
}
7+
8+
data "rediscloud_payment_method" "card" {
9+
card_type = "Visa"
10+
last_four_numbers = "5556"
11+
}
12+
13+
data "rediscloud_cloud_account" "account" {
14+
exclude_internal_account = true
15+
provider_type = "AWS"
16+
name = local.rediscloud_cloud_account
17+
}
18+
19+
resource "rediscloud_subscription" "example" {
20+
name = local.rediscloud_subscription_name
21+
payment_method_id = data.rediscloud_payment_method.card.id
22+
cloud_provider {
23+
provider = data.rediscloud_cloud_account.account.provider_type
24+
cloud_account_id = data.rediscloud_cloud_account.account.id
25+
region {
26+
region = "eu-west-1"
27+
networking_deployment_cidr = "10.0.0.0/24"
28+
preferred_availability_zones = ["eu-west-1a"]
29+
}
30+
}
31+
32+
creation_plan {
33+
dataset_size_in_gb = 1
34+
quantity = 1
35+
replication = false
36+
throughput_measurement_by = "operations-per-second"
37+
throughput_measurement_value = 1000
38+
}
39+
}
40+
41+
resource "rediscloud_subscription_database" "example" {
42+
subscription_id = rediscloud_subscription.example.id
43+
name = "example"
44+
dataset_size_in_gb = 1
45+
data_persistence = "none"
46+
throughput_measurement_by = "operations-per-second"
47+
throughput_measurement_value = 1000
48+
port = local.port_number
49+
resp_version = local.resp_version
50+
}

0 commit comments

Comments
 (0)