Skip to content

Commit

Permalink
azurerm_redis_enterprise_database - support redisJson module for …
Browse files Browse the repository at this point in the history
…geo-replication (#22627)

* support redisJson module for geo-replication

* update code

---------

Co-authored-by: Elena Xin <[email protected]>
  • Loading branch information
sinbai and sinbai authored Jul 25, 2023
1 parent 5172da1 commit c8abd7d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ func expandArmDatabaseModuleArray(input []interface{}, isGeoEnabled bool) (*[]da
for _, item := range input {
v := item.(map[string]interface{})
moduleName := v["name"].(string)
if moduleName != "RediSearch" && isGeoEnabled {
return nil, fmt.Errorf("Only RediSearch module is allowed with geo-replication")
if moduleName != "RediSearch" && moduleName != "RedisJSON" && isGeoEnabled {
return nil, fmt.Errorf("Only RediSearch and RedisJSON modules are allowed with geo-replication")
}
results = append(results, databases.Module{
Name: moduleName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ func TestRedisEnterpriseDatabase_geoDatabaseModule(t *testing.T) {
})
}

func TestRedisEnterpriseDatabase_geoDatabaseWithRedisJsonModule(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_redis_enterprise_database", "test")
r := RedisenterpriseDatabaseResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.geoDatabasewithRedisJsonModuleEnabled(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestRedisEnterpriseDatabase_unlinkDatabase(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_redis_enterprise_database", "test")
r := RedisenterpriseDatabaseResource{}
Expand Down Expand Up @@ -331,3 +345,28 @@ resource "azurerm_redis_enterprise_database" "test" {
}
`, r.template(data))
}

func (r RedisenterpriseDatabaseResource) geoDatabasewithRedisJsonModuleEnabled(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
resource "azurerm_redis_enterprise_database" "test" {
cluster_id = azurerm_redis_enterprise_cluster.test.id
resource_group_name = azurerm_resource_group.test.name
client_protocol = "Encrypted"
clustering_policy = "EnterpriseCluster"
eviction_policy = "NoEviction"
module {
name = "RedisJSON"
args = ""
}
linked_database_id = [
"${azurerm_redis_enterprise_cluster.test.id}/databases/default",
"${azurerm_redis_enterprise_cluster.test1.id}/databases/default",
"${azurerm_redis_enterprise_cluster.test2.id}/databases/default"
]
linked_database_group_nickname = "tftestGeoGroup"
}
`, r.template(data))
}
2 changes: 1 addition & 1 deletion website/docs/r/redis_enterprise_database.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The following arguments are supported:

* `module` - (Optional) A `module` block as defined below. Changing this forces a new resource to be created.

-> **NOTE:** Only RediSearch module is allowed with geo-replication
-> **NOTE:** Only `RediSearch` and `RedisJSON` modules are allowed with geo-replication

* `linked_database_id` - (Optional) A list of database resources to link with this database with a maximum of 5.

Expand Down

0 comments on commit c8abd7d

Please sign in to comment.