-
Notifications
You must be signed in to change notification settings - Fork 28
/
public-redis.tf
70 lines (56 loc) · 2.66 KB
/
public-redis.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
# Public Redis Instance
resource "azurerm_resource_group" "public_redis" {
name = "public-redis"
provider = azurerm.jenkins-sponsorship
location = var.location
tags = local.default_tags
}
# Redis database
resource "azurerm_redis_cache" "public_redis" {
name = "public-redis"
provider = azurerm.jenkins-sponsorship
location = azurerm_resource_group.public_redis.location
resource_group_name = azurerm_resource_group.public_redis.name
capacity = 2
family = "P" # Basic/Standard SKU family
sku_name = "Premium" # A replicated cache in a two node Primary/Secondary configuration managed by Microsoft, with a high availability SLA.
non_ssl_port_enabled = true
minimum_tls_version = "1.2"
public_network_access_enabled = false
tags = local.default_tags
}
resource "azurerm_private_dns_zone" "public_redis" {
# Conventional and static name required by Azure (otherwise automatic record creation does not work)
# https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-dns
name = "privatelink.redis.cache.windows.net"
# Private DNS zone name is static: we can only have one per RG
resource_group_name = data.azurerm_subnet.publick8s_tier.resource_group_name
tags = local.default_tags
}
resource "azurerm_private_endpoint" "public_redis" {
name = "redis-private-endpoint"
# provider must be the same as the using subnet
location = azurerm_resource_group.public_redis.location
resource_group_name = data.azurerm_subnet.publick8s_tier.resource_group_name
subnet_id = data.azurerm_subnet.publick8s_tier.id
custom_network_interface_name = "redis-nic"
private_service_connection {
name = "public-redis"
private_connection_resource_id = azurerm_redis_cache.public_redis.id
is_manual_connection = false
subresource_names = ["redisCache"]
}
private_dns_zone_group {
name = azurerm_private_dns_zone.public_redis.name
private_dns_zone_ids = [azurerm_private_dns_zone.public_redis.id]
}
}
resource "azurerm_private_dns_zone_virtual_network_link" "public_redis" {
name = azurerm_private_dns_zone.public_redis.name
# Private DNS zone name is static: we can only have one per RG
resource_group_name = data.azurerm_subnet.publick8s_tier.resource_group_name
private_dns_zone_name = azurerm_private_dns_zone.public_redis.name
virtual_network_id = data.azurerm_virtual_network.public.id
registration_enabled = true
tags = local.default_tags
}