Terraform module for Azure Managed Redis (Microsoft.Cache/redisEnterprise). Mirrors the input/output surface of the upstream AVM module Azure/avm-res-cache-redisenterprise/azurerm as closely as possible, but with two deliberate differences:
- Uses the
azurermprovider (notazapi) — keeps state addresses stable when migrating from the olderazurerm_managed_redis-based modules. - Exposes a few features the AVM module does not yet support:
access_keys_authentication_enabledpersistence_append_only_file_backup_frequencypersistence_redis_database_backup_frequencygeo_replication_group_name- cluster-level
diagnostic_settings(built-in, not a sidecar extension)
The module does not create the parent resource group — pass an existing one via parent_id.
module "redis" {
source = "git::https://github.com/emberstack/terraform.git//src/modules/azure-res-cache-redis?ref=vX.Y.Z"
name = "my-redis-cluster"
location = "westeurope"
parent_id = azurerm_resource_group.example.id
sku_name = "Balanced_B0"
}The customer_managed_key block in the AzureRM provider requires a user-assigned identity. Pass the same UAI in both managed_identities.user_assigned_resource_ids (so the cluster identity references it) and customer_managed_key_encryption.user_assigned_identity_resource_id (so the CMK block uses it).
module "redis" {
source = "..."
name = "my-redis-cluster"
location = "westeurope"
parent_id = azurerm_resource_group.example.id
sku_name = "Balanced_B0"
managed_identities = {
user_assigned_resource_ids = [azurerm_user_assigned_identity.cmk.id]
}
customer_managed_key_encryption = {
key_encryption_key_url = "https://my-vault.vault.azure.net/keys/redis-cmk/abc123"
identity_type = "UserAssignedIdentity"
user_assigned_identity_resource_id = azurerm_user_assigned_identity.cmk.id
}
}Two features the upstream AVM module does not expose — set them when migrating workloads that depend on durable persistence and legacy auth.
module "redis" {
source = "..."
# ...
clustering_policy = "NoCluster"
access_keys_authentication_enabled = true
persistence_append_only_file_backup_frequency = "1s"
}module "redis" {
source = "..."
# ...
private_endpoints = {
default = {
subnet_resource_id = azurerm_subnet.private_endpoints.id
private_dns_zone_resource_ids = [azurerm_private_dns_zone.redis.id]
}
}
}module "redis" {
source = "..."
# ...
role_assignments = {
operators = {
role_definition_id_or_name = "Redis Cache Contributor"
principal_id = azuread_group.operators.object_id
principal_type = "Group"
}
}
}See variables.tf and outputs.tf. Every variable and output
carries a description, and CI enforces that.
- Provider. This module uses
azurerm, the AVM usesazapi. Practical implication: state addresses (azurerm_managed_redis.this,azurerm_private_endpoint.this[<key>]) are stable across migrations from olderazurerm-based modules. - CMK identity. Both modules require a user-assigned identity for CMK (the resource provider only supports
userAssignedIdentitytoday). Theidentity_typefield is kept for AVM compatibility but is validated toUserAssignedIdentity. zones. The AVM input is omitted because theazurerm_managed_redisresource does not expose zones directly — zone redundancy is implicit whenhigh_availability = "Enabled"in regions with availability zones.access_policy_assignments. Not implemented — theazurerm_managed_redisresource doesn't model database-level access policies. If you need Entra-ID-only auth, useaccess_keys_authentication_enabled = falseand manage policies via a sibling resource.clustering_policy = "NoCluster". Allowed (the underlying provider accepts it). The AVM module restricts toEnterpriseCluster | OSSCluster | NoEviction— different semantics.