This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
6-create-redis.tf
60 lines (50 loc) · 1.63 KB
/
6-create-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
variable "redisvmfamily" {
type = string
default = "C"
}
variable "redisvmcapacity" {
type = number
default = 1
}
variable "redissku" {
type = string
default = "Standard"
}
variable "redisshardstocreate" {
type = number
default = 0
}
variable "redissubnetaddressprefix" {
type = string
default = "10.0.1.0/24"
}
resource "azurerm_subnet" "redis" {
name = "${var.prefix}RedisSubnet"
resource_group_name = "${azurerm_resource_group.main.name}"
virtual_network_name = "${azurerm_virtual_network.main.name}"
address_prefix = var.redissubnetaddressprefix
}
resource "random_id" "redis" {
byte_length = 2
}
# NOTE: the Name used for Redis needs to be globally unique
resource "azurerm_redis_cache" "standard" {
count = "${var.redissku == "Standard" ? 1 : 0}"
name = "${var.prefix}Redis${random_id.redis.hex}"
location = "${azurerm_resource_group.main.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
capacity = var.redisvmcapacity
family = var.redisvmfamily
sku_name = var.redissku
}
resource "azurerm_redis_cache" "premium" {
count = "${var.redissku == "Premium" ? 1 : 0}"
name = "${var.prefix}Redis${random_id.redis.hex}"
location = "${azurerm_resource_group.main.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
capacity = var.redisvmcapacity
family = var.redisvmfamily
sku_name = var.redissku
shard_count = var.redisshardstocreate
subnet_id = "${azurerm_subnet.redis.id}"
}