-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathredis-cache.tf
74 lines (62 loc) · 2.78 KB
/
redis-cache.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
resource "azurerm_redis_cache" "default" {
count = local.enable_redis_cache ? 1 : 0
name = "${local.resource_prefix}default"
location = local.resource_group.location
resource_group_name = local.resource_group.name
capacity = local.redis_cache_capacity
family = local.redis_cache_family
sku_name = local.redis_cache_sku
redis_version = local.redis_cache_version
non_ssl_port_enabled = false
minimum_tls_version = "1.2"
public_network_access_enabled = local.launch_in_vnet ? (
local.redis_cache_sku == "Premium" ? false : true
) : true
subnet_id = local.launch_in_vnet ? (
local.redis_cache_sku == "Premium" ? azurerm_subnet.redis_cache_subnet[0].id : null
) : null
redis_configuration {
maxmemory_reserved = local.redis_config.maxmemory_reserved
maxmemory_delta = local.redis_config.maxmemory_delta
maxmemory_policy = local.redis_config.maxfragmentationmemory_reserved
maxfragmentationmemory_reserved = local.redis_config.maxmemory_policy
}
patch_schedule {
day_of_week = local.redis_cache_patch_schedule_day
start_hour_utc = local.redis_cache_patch_schedule_hour
}
tags = local.tags
}
resource "azurerm_redis_firewall_rule" "container_app_default_static_ip" {
for_each = local.enable_redis_cache ? azurerm_container_app.container_apps : {}
name = "${replace(local.resource_prefix, "-", "")}fw${each.key}"
redis_cache_name = azurerm_redis_cache.default[0].name
resource_group_name = local.resource_group.name
start_ip = each.value.outbound_ip_addresses[0]
end_ip = each.value.outbound_ip_addresses[0]
}
resource "azurerm_redis_firewall_rule" "default" {
for_each = local.enable_redis_cache ? toset(local.redis_cache_firewall_ipv4_allow_list) : []
name = "${replace(local.resource_prefix, "-", "")}fw${each.key}"
redis_cache_name = azurerm_redis_cache.default[0].name
resource_group_name = local.resource_group.name
start_ip = each.value
end_ip = each.value
}
resource "azurerm_monitor_diagnostic_setting" "default_redis_cache" {
count = local.enable_monitoring ? (
local.enable_redis_cache ? 1 : 0
) : 0
name = "${local.resource_prefix}-default-redis-diag"
target_resource_id = azurerm_redis_cache.default[0].id
log_analytics_workspace_id = azurerm_log_analytics_workspace.container_app.id
eventhub_name = local.enable_event_hub ? azurerm_eventhub.container_app[0].name : null
enabled_log {
category = "ConnectedClientList"
}
# The below metrics are kept in to avoid a diff in the Terraform Plan output
metric {
category = "AllMetrics"
enabled = false
}
}