-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
97 lines (74 loc) · 2.15 KB
/
main.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
provider "aws" {
region = "us-east-1"
}
###################################################
# ElastiCache Redis Cluster
###################################################
module "cluster" {
source = "../../modules/elasticache-redis-cluster"
# source = "tedilabs/db/aws//modules/elasticache-redis-cluster"
# version = "~> 0.2.0"
name = "example-redis-single"
description = "Managed by Terraform."
redis_version = "6.2"
node_instance_type = "cache.t4g.micro"
node_size = 1
user_groups = [module.user_group.id]
encryption_in_transit = {
enabled = true
}
tags = {
"project" = "terraform-aws-db-examples"
}
}
###################################################
# Redis User Groups on ElastiCache
###################################################
module "user_group" {
source = "../../modules/elasticache-redis-user-group"
# source = "tedilabs/db/aws//modules/elasticache-redis-user-group"
# version = "~> 0.2.0"
name = "example"
default_user = module.user["example-default"].id
users = [module.user["example-admin"].id]
tags = {
"project" = "terraform-aws-db-examples"
}
}
###################################################
# Redis Users on ElastiCache
###################################################
locals {
users = [
{
id = "example-default"
name = "default"
access_string = "on ~* -@all +@read"
password_required = false
},
{
id = "example-admin"
name = "admin"
access_string = "on ~* +@all"
password_required = true
passwords = ["MyPassWord!Q@W#E", "MyPassW0rd!@QW#$ER"]
},
]
}
module "user" {
source = "../../modules/elasticache-redis-user"
# source = "tedilabs/db/aws//modules/elasticache-redis-user"
# version = "~> 0.2.0"
for_each = {
for user in try(local.users, []) :
user.id => user
}
id = each.key
name = each.value.name
access_string = try(each.value.access_string, null)
password_required = try(each.value.password_required, true)
passwords = try(each.value.passwords, [])
tags = {
"project" = "terraform-aws-db-examples"
}
}