Skip to content

Commit 1dd6890

Browse files
committed
adding examples and documentation
1 parent d9b3e24 commit 1dd6890

File tree

26 files changed

+1263
-93
lines changed

26 files changed

+1263
-93
lines changed

README.md

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,95 @@
1-
# terraform-azurerm-redis
2-
Terraform module for Azure Cache for Redis
1+
# Azure Cache for Redis Terraform module
32

3+
Azure Cache for Redis provides an in-memory data store based on the Redis software. This terraform module helps to quickly create the open-source (OSS Redis) Azure Cache for Redis.
4+
5+
## Resources supported
6+
7+
* [Redis Cache Server](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/redis_cache)
8+
* [Redis Cache Configuration](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/redis_cache#redis_configuration)
9+
* [Redis Cache Firewall Rules](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/redis_firewall_rule)
10+
* [Redis Cache Cluser](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/redis_cache#shard_count)
11+
* [Redis Cache Virtual Network Support](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/redis_cache#subnet_id)
12+
* [Redis Cache Data Persistence](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/redis_cache#rdb_backup_enabled)
13+
* [Redis Diagnostics](https://docs.microsoft.com/en-us/azure/azure-sql/database/metrics-diagnostic-telemetry-logging-streaming-export-configure?tabs=azure-portal)
14+
* [Private Endpoints](https://www.terraform.io/docs/providers/azurerm/r/private_endpoint.html)
15+
* [Private DNS zone for `privatelink` A records](https://www.terraform.io/docs/providers/azurerm/r/private_dns_zone.html)
16+
17+
## Module Usage
18+
19+
```terraform
20+
module "redis" {
21+
source = "kumarvna/redis/azurerm"
22+
version = "1.0.0"
23+
24+
# By default, this module will create a resource group
25+
# proivde a name to use an existing resource group and set the argument
26+
# to `create_resource_group = false` if you want to existing resoruce group.
27+
# If you use existing resrouce group location will be the same as existing RG.
28+
create_resource_group = false
29+
resource_group_name = "rg-shared-westeurope-01"
30+
location = "westeurope"
31+
32+
# Configuration to provision a Standard Redis Cache
33+
# Specify `shard_count` to create on the Redis Cluster
34+
# Add patch_schedle to this object to enable redis patching schedule
35+
redis_server_settings = {
36+
demoredischache-shared = {
37+
sku_name = "Premium"
38+
capacity = 2
39+
shard_count = 3
40+
zones = ["1", "2", "3"]
41+
enable_non_ssl_port = true
42+
patch_schedule = {
43+
days_of_week = "Monday"
44+
start_hour_utc = 21
45+
}
46+
}
47+
}
48+
49+
# MEMORY MANAGEMENT
50+
# Azure Cache for Redis instances are configured with the following default Redis configuration values:
51+
redis_configuration = {
52+
maxmemory_reserved = 2
53+
maxmemory_delta = 2
54+
maxmemory_policy = "allkeys-lru"
55+
}
56+
57+
#Azure Cache for Redis firewall filter rules are used to provide specific source IP access.
58+
# Azure Redis Cache access is determined based on start and end IP address range specified.
59+
# As a rule, only specific IP addresses should be granted access, and all others denied.
60+
# "name" (ex. azure_to_azure or desktop_ip) may only contain alphanumeric characters and underscores
61+
firewall_rules = {
62+
access_to_azure = {
63+
start_ip = "1.2.3.4"
64+
end_ip = "1.2.3.4"
65+
},
66+
desktop_ip = {
67+
start_ip = "49.204.228.223"
68+
end_ip = "49.204.228.223"
69+
}
70+
}
71+
72+
# Creating Private Endpoint requires, VNet name and address prefix to create a subnet
73+
# By default this will create a `privatelink.mysql.database.azure.com` DNS zone.
74+
# To use existing private DNS zone specify `existing_private_dns_zone` with valid zone name
75+
# Private endpoints doesn't work If using `subnet_id` to create redis cache inside a specified virtual network
76+
enable_private_endpoint = true
77+
virtual_network_name = "vnet-shared-hub-westeurope-001"
78+
private_subnet_address_prefix = ["10.1.5.0/29"]
79+
# existing_private_dns_zone = "demo.example.com"
80+
81+
# (Optional) To enable Azure Monitoring for Azure Cache for Redis
82+
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
83+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
84+
85+
# Tags for Azure Resources
86+
tags = {
87+
Terraform = "true"
88+
Environment = "dev"
89+
Owner = "test-user"
90+
}
91+
}
92+
```
493

594
Schedule maintenance for Redis. The default maintenance window is 5 hours
695
This does not cover any maintenance done by Azure for updating the underlying platform.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Azure Cache for Redis Terraform module
2+
3+
Azure Cache for Redis provides an in-memory data store based on the Redis software. This terraform module helps to quickly create the open-source (OSS Redis) Azure Cache for Redis.
4+
5+
## Module Usage
6+
7+
### Azure Cache for Redis with Cluster
8+
9+
```hcl
10+
module "redis" {
11+
source = "kumarvna/redis/azurerm"
12+
version = "1.0.0"
13+
14+
# By default, this module will create a resource group
15+
# proivde a name to use an existing resource group and set the argument
16+
# to `create_resource_group = false` if you want to existing resoruce group.
17+
# If you use existing resrouce group location will be the same as existing RG.
18+
create_resource_group = false
19+
resource_group_name = "rg-shared-westeurope-01"
20+
location = "westeurope"
21+
22+
# Configuration to provision a Standard Redis Cache
23+
# Specify `shard_count` to create on the Redis Cluster
24+
# Add patch_schedle to this object to enable redis patching schedule
25+
redis_server_settings = {
26+
demoredischache-shared = {
27+
sku_name = "Premium"
28+
capacity = 2
29+
shard_count = 3
30+
}
31+
}
32+
33+
# MEMORY MANAGEMENT
34+
# Azure Cache for Redis instances are configured with the following default Redis configuration values:
35+
redis_configuration = {
36+
maxmemory_reserved = 2
37+
maxmemory_delta = 2
38+
maxmemory_policy = "allkeys-lru"
39+
}
40+
41+
#Azure Cache for Redis firewall filter rules are used to provide specific source IP access.
42+
# Azure Redis Cache access is determined based on start and end IP address range specified.
43+
# As a rule, only specific IP addresses should be granted access, and all others denied.
44+
# "name" (ex. azure_to_azure or desktop_ip) may only contain alphanumeric characters and underscores
45+
firewall_rules = {
46+
access_to_azure = {
47+
start_ip = "1.2.3.4"
48+
end_ip = "1.2.3.4"
49+
},
50+
desktop_ip = {
51+
start_ip = "49.204.228.223"
52+
end_ip = "49.204.228.223"
53+
}
54+
}
55+
56+
# (Optional) To enable Azure Monitoring for Azure Cache for Redis
57+
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
58+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
59+
60+
# Tags for Azure Resources
61+
tags = {
62+
Terraform = "true"
63+
Environment = "dev"
64+
Owner = "test-user"
65+
}
66+
}
67+
```
68+
69+
## Terraform Usage
70+
71+
To run this example you need to execute following Terraform commands
72+
73+
```hcl
74+
terraform init
75+
terraform plan
76+
terraform apply
77+
78+
```
79+
80+
Run `terraform destroy` when you don't need these resources.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
module "redis" {
2+
source = "kumarvna/redis/azurerm"
3+
version = "1.0.0"
4+
5+
# By default, this module will create a resource group
6+
# proivde a name to use an existing resource group and set the argument
7+
# to `create_resource_group = false` if you want to existing resoruce group.
8+
# If you use existing resrouce group location will be the same as existing RG.
9+
create_resource_group = false
10+
resource_group_name = "rg-shared-westeurope-01"
11+
location = "westeurope"
12+
13+
# Configuration to provision a Standard Redis Cache
14+
# Specify `shard_count` to create on the Redis Cluster
15+
# Add patch_schedle to this object to enable redis patching schedule
16+
redis_server_settings = {
17+
demoredischache-shared = {
18+
sku_name = "Premium"
19+
capacity = 2
20+
shard_count = 3
21+
}
22+
}
23+
24+
# MEMORY MANAGEMENT
25+
# Azure Cache for Redis instances are configured with the following default Redis configuration values:
26+
redis_configuration = {
27+
maxmemory_reserved = 2
28+
maxmemory_delta = 2
29+
maxmemory_policy = "allkeys-lru"
30+
}
31+
32+
#Azure Cache for Redis firewall filter rules are used to provide specific source IP access.
33+
# Azure Redis Cache access is determined based on start and end IP address range specified.
34+
# As a rule, only specific IP addresses should be granted access, and all others denied.
35+
# "name" (ex. azure_to_azure or desktop_ip) may only contain alphanumeric characters and underscores
36+
firewall_rules = {
37+
access_to_azure = {
38+
start_ip = "1.2.3.4"
39+
end_ip = "1.2.3.4"
40+
},
41+
desktop_ip = {
42+
start_ip = "49.204.228.223"
43+
end_ip = "49.204.228.223"
44+
}
45+
}
46+
47+
# (Optional) To enable Azure Monitoring for Azure Cache for Redis
48+
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
49+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
50+
51+
# Tags for Azure Resources
52+
tags = {
53+
Terraform = "true"
54+
Environment = "dev"
55+
Owner = "test-user"
56+
}
57+
}

examples/Azure_Cache_for_Redis_with_Data_Persistence_Enabled/.terraform.lock.hcl

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Azure Cache for Redis Terraform module
2+
3+
Azure Cache for Redis provides an in-memory data store based on the Redis software. This terraform module helps to quickly create the open-source (OSS Redis) Azure Cache for Redis.
4+
5+
## Module Usage
6+
7+
### Azure Cache for Redis with data persistence enabled
8+
9+
```hcl
10+
module "redis" {
11+
source = "kumarvna/redis/azurerm"
12+
version = "1.0.0"
13+
14+
# By default, this module will create a resource group
15+
# proivde a name to use an existing resource group and set the argument
16+
# to `create_resource_group = false` if you want to existing resoruce group.
17+
# If you use existing resrouce group location will be the same as existing RG.
18+
create_resource_group = false
19+
resource_group_name = "rg-shared-westeurope-01"
20+
location = "westeurope"
21+
22+
# Configuration to provision a Standard Redis Cache
23+
# Specify `shard_count` to create on the Redis Cluster
24+
# Add patch_schedle to this object to enable redis patching schedule
25+
redis_server_settings = {
26+
demoredischache-shared = {
27+
sku_name = "Premium"
28+
capacity = 2
29+
}
30+
}
31+
32+
# MEMORY MANAGEMENT
33+
# Azure Cache for Redis instances are configured with the following default Redis configuration values:
34+
redis_configuration = {
35+
maxmemory_reserved = 2
36+
maxmemory_delta = 2
37+
maxmemory_policy = "allkeys-lru"
38+
}
39+
40+
# SNAPSHOTTING - Redis data backup
41+
# Data persistence doesn't work if `shard_count` is specified. i.e. Cluster enabled.
42+
enable_data_persistence = true
43+
data_persistence_backup_frequency = 60
44+
data_persistence_backup_max_snapshot_count = 1
45+
46+
#Azure Cache for Redis firewall filter rules are used to provide specific source IP access.
47+
# Azure Redis Cache access is determined based on start and end IP address range specified.
48+
# As a rule, only specific IP addresses should be granted access, and all others denied.
49+
# "name" (ex. azure_to_azure or desktop_ip) may only contain alphanumeric characters and underscores
50+
firewall_rules = {
51+
access_to_azure = {
52+
start_ip = "1.2.3.4"
53+
end_ip = "1.2.3.4"
54+
},
55+
desktop_ip = {
56+
start_ip = "49.204.228.223"
57+
end_ip = "49.204.228.223"
58+
}
59+
}
60+
61+
# (Optional) To enable Azure Monitoring for Azure Cache for Redis
62+
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
63+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
64+
65+
# Tags for Azure Resources
66+
tags = {
67+
Terraform = "true"
68+
Environment = "dev"
69+
Owner = "test-user"
70+
}
71+
}
72+
```
73+
74+
## Terraform Usage
75+
76+
To run this example you need to execute following Terraform commands
77+
78+
```hcl
79+
terraform init
80+
terraform plan
81+
terraform apply
82+
83+
```
84+
85+
Run `terraform destroy` when you don't need these resources.

0 commit comments

Comments
 (0)