azurermRedisCache
Manages a Redis Cache.
Example Usage
This example provisions a Standard Redis Cache. Other examples of the azurermRedisCache
resource can be found in the /examples/redisCache
directory within the GitHub Repository
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
this,
"example",
{
location: "West Europe",
name: "example-resources",
}
);
const azurermRedisCacheExample = new azurerm.redisCache.RedisCache(
this,
"example_1",
{
capacity: 2,
enable_non_ssl_port: false,
family: "C",
location: azurermResourceGroupExample.location,
minimum_tls_version: "1.2",
name: "example-cache",
redis_configuration: [{}],
resource_group_name: azurermResourceGroupExample.name,
sku_name: "Standard",
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermRedisCacheExample.overrideLogicalId("example");
Argument Reference
The following arguments are supported:
-
name
- (Required) The name of the Redis instance. Changing this forces a new resource to be created. -
location
- (Required) The location of the resource group. Changing this forces a new resource to be created. -
resourceGroupName
- (Required) The name of the resource group in which to create the Redis instance. Changing this forces a new resource to be created. -
capacity
- (Required) The size of the Redis cache to deploy. Valid values for a SKUfamily
of C (Basic/Standard) are0,1,2,3,4,5,6
, and for P (Premium)family
are1,2,3,4,5
. -
family
- (Required) The SKU family/pricing group to use. Valid values arec
(for Basic/Standard SKU family) andp
(forpremium
) -
skuName
- (Required) The SKU of Redis to use. Possible values arebasic
,standard
andpremium
.
\~> Note Downgrading the SKU will force a new resource to be created.
-
enableNonSslPort
- (Optional) Enable the non-SSL port (6379) - disabled by default. -
identity
- (Optional) Anidentity
block as defined below. -
minimumTlsVersion
- (Optional) The minimum TLS version. Possible values are10
,11
and12
. Defaults to10
. -
patchSchedule
- (Optional) A list ofpatchSchedule
blocks as defined below. -
privateStaticIpAddress
- (Optional) The Static IP Address to assign to the Redis Cache when hosted inside the Virtual Network. This argument implies the use ofsubnetId
. Changing this forces a new resource to be created. -
publicNetworkAccessEnabled
- (Optional) 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 totrue
. -
redisConfiguration
- (Optional) AredisConfiguration
as defined below - with some limitations by SKU - defaults/details are shown below. -
replicasPerMaster
- (Optional) Amount of replicas to create per master for this Redis Cache.
\~> Note: Configuring the number of replicas per master is only available when using the Premium SKU and cannot be used in conjunction with shards.
-
replicasPerPrimary
- (Optional) Amount of replicas to create per primary for this Redis Cache. If bothreplicasPerPrimary
andreplicasPerMaster
are set, they need to be equal. -
redisVersion
- (Optional) Redis version. Only major version needed. Valid values:4
,6
. -
tenantSettings
- (Optional) A mapping of tenant settings to assign to the resource. -
shardCount
- (Optional) Only available when using the Premium SKU The number of Shards to create on the Redis Cluster. -
subnetId
- (Optional) Only available when using the Premium SKU The ID of the Subnet within which the Redis Cache should be deployed. This Subnet must only contain Azure Cache for Redis instances without any other type of resources. Changing this forces a new resource to be created. -
tags
- (Optional) A mapping of tags to assign to the resource. -
zones
- (Optional) Specifies a list of Availability Zones in which this Redis Cache should be located. Changing this forces a new Redis Cache to be created.
-> Please Note: Availability Zones are in Preview and only supported in several regions at this time - as such you must be opted into the Preview to use this functionality. You can opt into the Availability Zones Preview in the Azure Portal.
An identity
block supports the following:
-
type
- (Required) Specifies the type of Managed Service Identity that should be configured on this Redis Cluster. Possible values aresystemAssigned
,userAssigned
,systemAssigned,UserAssigned
(to enable both). -
identityIds
- (Optional) A list of User Assigned Managed Identity IDs to be assigned to this Redis Cluster.
\~> NOTE: This is required when type
is set to userAssigned
or systemAssigned,UserAssigned
.
A redisConfiguration
block supports the following:
aofBackupEnabled
- (Optional) Enable or disable AOF persistence for this Redis Cache.aofStorageConnectionString0
- (Optional) First Storage Account connection string for AOF persistence.aofStorageConnectionString1
- (Optional) Second Storage Account connection string for AOF persistence.
Example usage:
redis_configuration {
aof_backup_enabled = true
aof_storage_connection_string_0 = "DefaultEndpointsProtocol=https;BlobEndpoint=${azurerm_storage_account.nc-cruks-storage-account.primary_blob_endpoint};AccountName=${azurerm_storage_account.mystorageaccount.name};AccountKey=${azurerm_storage_account.mystorageaccount.primary_access_key}"
aof_storage_connection_string_1 = "DefaultEndpointsProtocol=https;BlobEndpoint=${azurerm_storage_account.mystorageaccount.primary_blob_endpoint};AccountName=${azurerm_storage_account.mystorageaccount.name};AccountKey=${azurerm_storage_account.mystorageaccount.secondary_access_key}"
}
enableAuthentication
- (Optional) If set tofalse
, the Redis instance will be accessible without authentication. Defaults totrue
.
-> NOTE: enableAuthentication
can only be set to false
if a subnetId
is specified; and only works if there aren't existing instances within the subnet with enableAuthentication
set to true
.
-
maxmemoryReserved
- (Optional) Value in megabytes reserved for non-cache usage e.g. failover. Defaults are shown below. -
maxmemoryDelta
- (Optional) The max-memory delta for this Redis instance. Defaults are shown below. -
maxmemoryPolicy
- (Optional) How Redis will select what to remove whenmaxmemory
is reached. Defaults are shown below. Defaults tovolatileLru
. -
maxfragmentationmemoryReserved
- (Optional) Value in megabytes reserved to accommodate for memory fragmentation. Defaults are shown below. -
rdbBackupEnabled
- (Optional) Is Backup Enabled? Only supported on Premium SKUs.
-> NOTE: If rdbBackupEnabled
set to true
, rdbStorageConnectionString
must also be set.
rdbBackupFrequency
- (Optional) The Backup Frequency in Minutes. Only supported on Premium SKUs. Possible values are:15
,30
,60
,360
,720
and1440
.rdbBackupMaxSnapshotCount
- (Optional) The maximum number of snapshots to create as a backup. Only supported for Premium SKUs.rdbStorageConnectionString
- (Optional) The Connection String to the Storage Account. Only supported for Premium SKUs. In the format:defaultEndpointsProtocol=https;blobEndpoint=${azurermStorageAccountExamplePrimaryBlobEndpoint};accountName=${azurermStorageAccountExampleName};accountKey=${azurermStorageAccountExamplePrimaryAccessKey}
.
\~> NOTE: There's a bug in the Redis API where the original storage connection string isn't being returned, which is being tracked in this issue. In the interim you can use the ignoreChanges
attribute to ignore changes to this field e.g.:
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
new azurerm.redisCache.RedisCache(this, "example", {
ignore_changes: ["${redis_configuration.0.rdb_storage_connection_string}"],
});
notifyKeyspaceEvents
- (Optional) Keyspace notifications allows clients to subscribe to Pub/Sub channels in order to receive events affecting the Redis data set in some way. Reference
redis_configuration {
maxmemory_reserved = 10
maxmemory_delta = 2
maxmemory_policy = "allkeys-lru"
}
Default Redis Configuration Values
Redis Value | Basic | Standard | Premium |
---|---|---|---|
enable_authentication | true | true | true |
maxmemory_reserved | 2 | 50 | 200 |
maxfragmentationmemory_reserved | 2 | 50 | 200 |
maxmemory_delta | 2 | 50 | 200 |
maxmemory_policy | volatile-lru | volatile-lru | volatile-lru |
\~> NOTE: The maxmemoryReserved
, maxmemoryDelta
and maxfragmentationmemoryReserved
settings are only available for Standard and Premium caches. More details are available in the Relevant Links section below.
A patchSchedule
block supports the following:
-
dayOfWeek
- (Required) the Weekday name - possible values includemonday
,tuesday
,wednesday
etc. -
startHourUtc
- (Optional) the Start Hour for maintenance in UTC - possible values range from023
.
\~> Note: The Patch Window lasts for 5
hours from the startHourUtc
.
maintenanceWindow
- (Optional) The ISO 8601 timespan which specifies the amount of time the Redis Cache can be updated. Defaults topt5H
.
Attributes Reference
The following attributes are exported:
-
id
- The Route ID. -
hostname
- The Hostname of the Redis Instance -
sslPort
- The SSL Port of the Redis Instance -
port
- The non-SSL Port of the Redis Instance -
primaryAccessKey
- The Primary Access Key for the Redis Instance -
secondaryAccessKey
- The Secondary Access Key for the Redis Instance -
primaryConnectionString
- The primary connection string of the Redis Instance. -
secondaryConnectionString
- The secondary connection string of the Redis Instance. -
redisConfiguration
- AredisConfiguration
block as defined below:
A redisConfiguration
block exports the following:
maxclients
- Returns the max number of connected clients at the same time.
Relevant Links
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 90 minutes) Used when creating the Redis Cache.update
- (Defaults to 90 minutes) Used when updating the Redis Cache.read
- (Defaults to 5 minutes) Used when retrieving the Redis Cache.delete
- (Defaults to 90 minutes) Used when deleting the Redis Cache.
Import
Redis Cache's can be imported using the resourceId
, e.g.