Redis Cache module can deploy these resources:
- azurerm_redis_cache (required)
- azurerm_monitor_diagnostic_setting (optional)
- azurerm_private_endpoint (optional)
Example variables structure is located in variables.md.
Example use case is located in test-case/locals.tf.
You can also see changelog.
Terraform documentation:
https://registry.terraform.io/providers/hashicorp/azurerm/4.14.0/docs/resources/redis_cache
https://registry.terraform.io/providers/hashicorp/azurerm/4.14.0/docs/resources/private_endpoint
WARNING: AzureRM provider had been updated to a new major version. Many breaking changes were implemented. See the providers guide for more information.
There are a few things you need to do to import resources into .tfstate. In the example below there are resources which can be imported within the module. You may need to modify these commands to the OS on which they will be running (Refer to the documentation for additional details).
- terraform import '
<path-to-module>
.azurerm_redis_cache.redis_cache["<redis-cache-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Cache/redis/<redis-cache-name>
'
- terraform import '
<path-to-module>
.azurerm_monitor_diagnostic_setting.diagnostic_setting["<redis-cache-name>
_<diag-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Cache/redis/<redis-cache-name>
|<diag-name>
'
- terraform import '
<path-to-module>
.module.private_endpoint.azurerm_private_endpoint.private_endpoint["<private-endpoint-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/privateEndpoints/<private-endpoint-name>
'
NOTE:
<path-to-module>
is terraform logical path from root. e.g. module.redis_cache
Output Name | Value | Comment |
---|---|---|
outputs | name | |
id | ||
principal_id | principal_id (object_id) of system assigned identity | |
ssl_port | ||
port | ||
primary_access_key | ||
secondary_access_key | ||
primary_connection_string | ||
secondary_connection_string |
In the example below, outputted id of the deployed Redis Cache module is used as a value for the scope variable in Role Assignment resource.
module "rc" {
source = "[email protected]:seyfor-csc/mit.redis-cache.git?ref=v1.0.0"
config = [
{
name = "seyterraformnerc01"
location = "northeurope"
resource_group_name = "SEY-TERRAFORM-NE-RG01"
capacity = 2
family = C
sku_name = Basic
}
]
}
data "azurerm_client_config" "azurerm_client_config" {
}
resource "azurerm_role_assignment" "role_assignment" {
scope = module.rc.outputs.seyterraformnerc01.id # This is how to use output values
role_definition_name = "Contributor"
principal_id = data.azurerm_client_config.azurerm_client_config.object_id
}
No special features in module.
Because of this, terraform plan will generate changes to the rdb_storage_connection_string
variable every run. This is a known issue with the Azure API. See the following link for more details:
Azure/azure-rest-api-specs#3037
Terraform documentation for redis cache suggests to put the rdb_storage_connection_string
into an ignore_changes block. However, that also ends in an error. Because of this, no ignore_changes block is implemented. See the following link for more details:
Azure/azure-rest-api-specs#3037 (comment)