Skip to content

claranet/terraform-azurerm-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure Redis Cache

Changelog Notice Apache V2 License OpenTofu Registry

This Terraform module creates a Redis Cache instance along with firewall rules. No logging is available from this resource.

The default configuration is an highly available cluster of 3 shards and data persistence enabled on the Premium tier.

Global versioning rule for Claranet Azure modules

Module version Terraform version OpenTofu version AzureRM version
>= 8.x.x Unverified 1.8.x >= 4.0
>= 7.x.x 1.3.x >= 3.0
>= 6.x.x 1.x >= 3.0
>= 5.x.x 0.15.x >= 2.0
>= 4.x.x 0.13.x / 0.14.x >= 2.0
>= 3.x.x 0.12.x >= 2.0
>= 2.x.x 0.12.x < 2.0
< 2.x.x 0.11.x < 2.0

Contributing

If you want to contribute to this repository, feel free to use our pre-commit git hook configuration which will help you automatically update and format some files for you by enforcing our Terraform code module best-practices.

More details are available in the CONTRIBUTING.md file.

Usage

This module is optimized to work with the Claranet terraform-wrapper tool which set some terraform variables in the environment needed by this module. More details about variables set by the terraform-wrapper available in the documentation.

⚠️ Since modules version v8.0.0, we do not maintain/check anymore the compatibility with Hashicorp Terraform. Instead, we recommend to use OpenTofu.

module "redis" {
  source  = "claranet/redis/azurerm"
  version = "x.x.x"

  client_name    = var.client_name
  environment    = var.environment
  location       = module.azure_region.location
  location_short = module.azure_region.location_short
  stack          = var.stack

  resource_group_name = module.rg.name

  allowed_cidrs = ["1.2.3.4/32", "5.6.7.8/16"]

  logs_destinations_ids = [
    module.logs.storage_account_id,
    module.logs.id
  ]

  extra_tags = {
    foo = "bar"
  }
}

Providers

Name Version
azurecaf ~> 1.2.28
azurerm ~> 4.0

Modules

Name Source Version
diagnostics claranet/diagnostic-settings/azurerm ~> 8.0.0

Resources

Name Type
azurerm_redis_cache.main resource
azurerm_redis_firewall_rule.main resource
azurerm_storage_account.main resource
azurecaf_name.data_storage data source
azurecaf_name.redis data source
azurecaf_name.redis_fw_rule data source

Inputs

Name Description Type Default Required
allowed_cidrs List of allowed CIDR ranges to access the Azure Redis Cache resource. any [] no
capacity Redis size: (Basic/Standard: 1,2,3,4,5,6) (Premium: 1,2,3,4) documentation. number 2 no
client_name Client name/account used in naming. string n/a yes
cluster_shard_count Number of cluster shards desired. number 3 no
custom_name Custom name of Redis Server string "" no
data_persistence_enabled "true" to enable data persistence. bool true no
data_persistence_frequency_in_minutes Data persistence snapshot frequency in minutes. number 60 no
data_persistence_max_snapshot_count Max number of data persistence snapshots. number null no
data_persistence_storage_account_replication Replication type for the Storage Account used for data persistence. string "LRS" no
data_persistence_storage_account_tier Replication type for the Storage Account used for data persistence. string "Premium" no
data_persistence_storage_custom_name Custom name for the Storage Account used for Redis data persistence. string "" no
default_tags_enabled Option to enable or disable default tags. bool true no
diagnostic_settings_custom_name Custom name of the diagnostics settings, name will be default if not set. string "default" no
environment Project environment. string n/a yes
extra_tags Additional tags to associate. map(string) {} no
location Azure location. string n/a yes
location_short Short string for Azure location. string n/a yes
logs_categories Log categories to send to destinations. list(string) null no
logs_destinations_ids List of destination resources IDs for logs diagnostic destination.
Can be Storage Account, Log Analytics Workspace and Event Hub. No more than one of each can be set.
If you want to use Azure EventHub as a destination, you must provide a formatted string containing both the EventHub Namespace authorization send ID and the EventHub name (name of the queue to use in the Namespace) separated by the | character.
list(string) n/a yes
logs_metrics_categories Metrics categories to send to destinations. list(string) null no
minimum_tls_version The minimum TLS version. string "1.2" no
name_prefix Optional prefix for the generated name string "" no
name_suffix Optional suffix for the generated name string "" no
non_ssl_port_enabled Activate non SSL port (6779) for Redis connection. bool false no
patch_schedules A list of Patch Schedule, Azure Cache for Redis patch schedule is used to install important software updates in specified time window.
list(object({
day_of_week = string
start_hour_utc = optional(string)
maintenance_window = optional(string)
}))
[] no
private_static_ip_address The Static IP Address to assign to the Redis Cache when hosted inside the Virtual Network. Changing this forces a new resource to be created. string null no
public_network_access_enabled Whether the Azure Redis Cache is available from public network. bool false no
redis_additional_configuration Additional configuration for the Redis instance. Some of the keys are set automatically. See documentation for full reference.
object({
aof_backup_enabled = optional(bool)
aof_storage_connection_string_0 = optional(string)
aof_storage_connection_string_1 = optional(string)
authentication_enabled = optional(bool)
active_directory_authentication_enabled = optional(bool)
maxmemory_reserved = optional(number)
maxmemory_delta = optional(number)
maxmemory_policy = optional(string)
maxfragmentationmemory_reserved = optional(number)
rdb_backup_enabled = optional(bool)
rdb_backup_frequency = optional(number)
rdb_backup_max_snapshot_count = optional(number)
rdb_storage_connection_string = optional(string)
notify_keyspace_events = optional(string)
})
{} no
redis_version Redis version to deploy. Allowed value is only 6 for new instances since v4 deprecation. number 6 no
resource_group_name Resource group name. string n/a yes
sku_name Redis Cache Sku name. Can be Basic, Standard or Premium. string "Premium" no
stack Project stack name. string n/a yes
subnet_id The ID of the Subnet within which the Redis Cache should be deployed. Changing this forces a new resource to be created. string null no
zones A list of a one or more Availability Zones, where the Redis Cache should be allocated. list(number) null no

Outputs

Name Description
capacity Redis instance capacity.
configuration Redis instance configuration.
family Redis instance family.
hostname Redis instance hostname.
id Redis instance id.
module_diagnostics Diagnostics settings module outputs.
name Redis instance name.
port Redis instance port.
primary_access_key Redis instance primary access key.
primary_connection_string The primary connection string of the Redis instance.
private_static_ip_address Redis instance private static IP address.
resource Redis instance object.
resource_storage Redis storage account outputs.
secondary_access_key Redis instance secondary access key.
secondary_connection_string The secondary connection string of the Redis instance.
sku_name Redis instance SKU name.
ssl_port Redis instance SSL port.
terraform_module Information about this Terraform module.

Related documentation

Microsoft Azure service documentation: docs.microsoft.com/en-us/azure/azure-cache-for-redis/