hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

Support for active geo-replication in `azurerm_redis_enterprise_database` #16448

Open MrDrMcCoy opened 2 years ago

MrDrMcCoy commented 2 years ago

Is there an existing issue for this?

Community Note

Description

Please add support for active geo-replication in the Enterprise Azure Cache for Redis. The only other way to automate this is via Bicep, which we do not wish to introduce into our Terraform environment.

New or Affected Resource(s)/Data Source(s)

azurerm_redis_enterprise_database

Potential Terraform Configuration

resource "azurerm_redis_enterprise_database" "example" {
  name                = "default"
  resource_group_name = azurerm_resource_group.example.name
  cluster_id = azurerm_redis_enterprise_cluster.example.id
  geo_replication {
    name = "groupNickname"
    linked_databases = ["id", ...]
  }
}

References

Docs:

xiaxyi commented 2 years ago

The feature is merged:https://github.com/hashicorp/terraform-provider-azurerm/pull/16045

MrDrMcCoy commented 2 years ago

@xiaxyi This is very exciting, but I am not able to get it to work. When attempting to create the following resources:

resource "azurerm_redis_enterprise_cluster" "geo" {
  for_each = var.config.aks_regions
  location = each.key
  minimum_tls_version = "1.2"
  name = "anark${var.resource_group.name}${each.key}geo"
  resource_group_name = var.resource_group.name
  sku_name = var.config.redis_geo.sku_name
}

resource "azurerm_redis_enterprise_database" "geo" {
  name = "default"
  client_protocol = "Encrypted"
  cluster_id = azurerm_redis_enterprise_cluster.geo[keys(var.config.aks_regions)[0]].id
  clustering_policy = "EnterpriseCluster"
  linked_database_id = [
    for _, value in azurerm_redis_enterprise_cluster.geo :
      "${value.id}/databases/default"
  ]
}

It results in the following error:

│ Error: evictionPolicy must be set to NoEviction when using RediSearch module
│ 
│   with module.az_resource_group["dev2"].azurerm_redis_enterprise_database.geo,
│   on az_resource_group/redis.tf line 37, in resource "azurerm_redis_enterprise_database" "geo":
│   37: resource "azurerm_redis_enterprise_database" "geo" {

We are not interested in the RediSearch module, nor are we interested in disabling eviction. From the available documentation that I have seen, there is no way to exclude these add-on modules. Should I open a new issue for this?

xiaxyi commented 2 years ago

@MrDrMcCoy Let me check the code, besides, can you be more specific about the there is no way to exclude these add-on modules?

no need to open another issue, we can do the follow-up in the thread.

MrDrMcCoy commented 2 years ago

can you be more specific about the there is no way to exclude these add-on modules?

Sure. The module {} block only allows you to specify name and args, but not enabled. The fact that I am getting the error above despite not requesting any modules to be installed suggests that these modules are getting enabled by default when creating a geo-replicated database. Short of a mechanism to exclude these modules, the default behavior of this resource creation would need to be changed to not include them.

xiaxyi commented 2 years ago

@MrDrMcCoy May I know if any of the databases which are involved in the active-geo linking process are created before?

MrDrMcCoy commented 2 years ago

@xiaxyi it is my understanding that, given the example I posted earlier, these databases are not created until the clusters they reference are available. Neither the databases nor the clusters existed previously, as they are created from nothing by Terraform. Is that what you were looking for?

xiaxyi commented 2 years ago

@MrDrMcCoy yes, Thanks for the clarification. I will perform more tests to have the issue reproduced from my side

MrDrMcCoy commented 2 years ago

@xiaxyi any news on this issue? The ability to create and manage Azure Redis Enterprise with geo-replication via Terraform is very important for my company and we are blocked by this.

xiaxyi commented 2 years ago

https://github.com/hashicorp/terraform-provider-azurerm/pull/16700