Skip to content

Module that provision a redis paas inside a subnet

License

Notifications You must be signed in to change notification settings

hmcts/cnp-module-redis

Repository files navigation

cnp-module-redis

This repository contains the module that enables you to create a Redis PaaS instance.

Usage

Recommended example for cost optimisation

Premium redis PaaS instance are very expensive, care must be taken when using them and only used in required environments. This should only be production unless you really need it in a different environment.

variables.tf

variable "family" {
  default     = "C"
  description = "The SKU family/pricing group to use. Valid values are `C` (for Basic/Standard SKU family) and `P` (for Premium). Use P for higher availability, but beware it costs a lot more."
}

variable "sku_name" {
  default     = "Basic"
  description = "The SKU of Redis to use. Possible values are `Basic`, `Standard` and `Premium`."
}

variable "capacity" {
  default     = "1"
  description = "The size of the Redis cache to deploy. Valid values are 1, 2, 3, 4, 5"
}

The following values are recommended for use in the production environment:

prod.tfvars

sku_name = "Premium"
family   = "P"
capacity = "1"

redis.tf

module "redis" {
  source                   = "git@github.com:hmcts/cnp-module-redis?ref=master"
  product                  = var.product
  location                 = var.location
  env                      = var.env
  common_tags              = var.common_tags
  redis_version            = "6"
  business_area            = "cft" # cft or sds
  sku_name                 = var.sku_name
  family                   = var.family
  capacity                 = var.capacity

  private_endpoint_enabled      = true
  public_network_access_enabled = false
}

resource "azurerm_key_vault_secret" "redis_access_key" {
  name         = "redis-access-key"
  value        = module.redis-activity-service.access_key
  key_vault_id = data.azurerm_key_vault.vault.id
}

If you need to increase cache size take a look at the pricing page for available options and cost impact.

Configuration

Providers

Name Version
azurerm n/a

Resources

Name Type
azurerm_private_endpoint.this resource
azurerm_redis_cache.redis resource
azurerm_resource_group.cache-resourcegroup resource
azurerm_subnet.private_endpoint_subnet data source

Inputs

Name Description Type Default Required
availability_zones Specifies a list of Availability Zones in which this Redis Cache should be located. Changing this forces a new Redis Cache to be created. list(any) null no
business_area business_area name - sds or cft string "cft" no
capacity The size of the Redis cache to deploy. Valid values are 1, 2, 3, 4, 5 string "1" no
common_tags Map of tags to tag all resources with map(string) n/a yes
env Environment to deploy to string n/a yes
family The SKU family/pricing group to use. Valid values are C (for Basic/Standard SKU family) and P (for Premium). Use P for higher availability, but beware it costs a lot more. string "P" no
location Azure datacenter location string n/a yes
maxfragmentationmemory_reserved Value in megabytes reserved to accommodate for memory fragmentation string "642" no
maxmemory_delta The max-memory delta for this Redis instance. string "642" no
maxmemory_policy How Redis will select what to remove when maxmemory is reached string "volatile-lru" no
maxmemory_reserved Value in megabytes reserved for non-cache usage e.g. failover string "642" no
minimum_tls_version The minimum TLS version string "1.2" no
name Override the default name of $product-$env, useful when upgrading versions string null no
private_endpoint_enabled Deploy using a private endpoint rather than vnet integration (recommended) bool false no
private_endpoint_subnet Specify your own subnet for private link integration, if you don't specify one then it will be calculated for you. string "" no
product https://hmcts.github.io/glossary/#platform string n/a yes
public_network_access_enabled Whether or not public network access is allowed for this Redis Cache. true means this resource could be accessed by both public and private endpoint. false means only private endpoint access is allowed. Defaults to true. bool true no
redis_version Redis version to be deployed 4 or 6 (4 is deprecated) string "4" no
resource_group_name Name of existing resource group to deploy resources into string null no
sku_name The SKU of Redis to use. Possible values are Basic, Standard and Premium. string "Premium" no
subnetid Subnet to deploy the Redis instance to string "" no

Outputs

Name Description
access_key Primary access key to connect to redis with
host_name Host name of the Redis cache
redis_port SSL port to connect to redis with