Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_redis_enterprise_database - support redisJson module for geo-replication #22627

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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