Skip to content

Commit f931b94

Browse files
committed
expose vars from comet_elasticache into root
1 parent 355229e commit f931b94

File tree

4 files changed

+81
-56
lines changed

4 files changed

+81
-56
lines changed

comet-infrastructure/main.tf

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,40 +106,38 @@ module "comet_eks" {
106106
}
107107

108108
module "comet_elasticache" {
109-
source = "./modules/comet_elasticache"
110-
count = var.enable_elasticache ? 1 : 0
111-
109+
source = "./modules/comet_elasticache"
110+
count = var.enable_elasticache ? 1 : 0
112111
environment = var.environment
113112

114113
ec2_enabled = var.enable_ec2
115114
eks_enabled = var.enable_eks
116115

117-
vpc_id = module.vpc.vpc_id
118-
vpc_private_subnets = module.vpc.private_subnets
119-
120-
# index is used on the module refs becuase of the count usage in the toggle: "After the count apply the resource becomes a group, so later in the reference use 0-index of the group"
121-
elasticache_allow_ec2_sg = var.enable_ec2 ? module.comet_ec2[0].comet_ec2_sg_id : null
122-
elasticache_allow_eks_sg = var.enable_eks ? module.comet_eks[0].nodegroup_sg_id : null
116+
vpc_id = module.vpc.vpc_id
117+
elasticache_private_subnets = module.vpc.private_subnets
118+
elasticache_allow_ec2_sg = var.enable_ec2 ? module.comet_ec2[0].comet_ec2_sg_id : null
119+
elasticache_allow_eks_sg = var.enable_eks ? module.comet_eks[0].nodegroup_sg_id : null
120+
elasticache_engine = var.elasticache_engine
121+
elasticache_engine_version = var.elasticache_engine_version
122+
elasticache_instance_type = var.elasticache_instance_type
123+
elasticache_param_group_name = var.elasticache_param_group_name
124+
elasticache_num_cache_nodes = var.elasticache_num_cache_nodes
123125
}
124126

125127
module "comet_rds" {
126-
source = "./modules/comet_rds"
127-
count = var.enable_rds ? 1 : 0
128-
128+
source = "./modules/comet_rds"
129+
count = var.enable_rds ? 1 : 0
129130
environment = var.environment
130131

131132
ec2_enabled = var.enable_ec2
132133
eks_enabled = var.enable_eks
133134

134-
availability_zones = local.azs
135+
availability_zones = local.azs
135136
vpc_id = module.vpc.vpc_id
136137
vpc_private_subnets = module.vpc.private_subnets
137-
138-
# index is used on the module refs becuase of the count usage in the toggle: "After the count apply the resource becomes a group, so later in the reference use 0-index of the group"
139-
rds_allow_ec2_sg = var.enable_ec2 ? module.comet_ec2[0].comet_ec2_sg_id : null
140-
rds_allow_eks_sg = var.enable_eks ? module.comet_eks[0].nodegroup_sg_id : null
141-
142-
rds_root_password = var.rds_root_password
138+
rds_allow_ec2_sg = var.enable_ec2 ? module.comet_ec2[0].comet_ec2_sg_id : null
139+
rds_allow_eks_sg = var.enable_eks ? module.comet_eks[0].nodegroup_sg_id : null
140+
rds_root_password = var.rds_root_password
143141
}
144142

145143
module "comet_s3" {

comet-infrastructure/modules/comet_elasticache/main.tf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,26 @@ locals {
22
redis_port = 6379
33

44
tags = {
5-
Terraform = "true"
6-
Environment = var.environment
5+
Terraform = "true"
6+
Environment = var.environment
77
}
88
}
99

1010
resource "aws_elasticache_cluster" "comet-ml-ec-redis" {
1111
cluster_id = "cometml-ec-redis-${var.environment}"
1212
engine = var.elasticache_engine
13-
node_type = var.elasticache_redis_instance_type
13+
node_type = var.elasticache_instance_type
1414
num_cache_nodes = var.elasticache_num_cache_nodes
1515
parameter_group_name = var.elasticache_param_group_name
1616
engine_version = var.elasticache_engine_version
1717
port = local.redis_port
1818
subnet_group_name = aws_elasticache_subnet_group.comet-ml-ec-subnet-group.name
19-
# SG resource ref
2019
security_group_ids = [aws_security_group.redis_inbound_sg.id]
2120
}
2221

2322
resource "aws_elasticache_subnet_group" "comet-ml-ec-subnet-group" {
2423
name = "cometml-ec-sng-${var.environment}"
25-
subnet_ids = var.vpc_private_subnets
24+
subnet_ids = var.elasticache_private_subnets
2625
}
2726

2827
resource "aws_security_group" "redis_inbound_sg" {

comet-infrastructure/modules/comet_elasticache/variables.tf

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,49 @@ variable "environment" {
44
default = "dev"
55
}
66

7-
variable "elasticache_redis_instance_type" {
8-
description = "Elasticache Redis instance type"
7+
variable "vpc_id" {
8+
description = "ID of the VPC that will contain the provisioned resources"
99
type = string
10-
default = "cache.r4.xlarge"
1110
}
1211

13-
variable "elasticache_engine" {
14-
description = "Engine type for Elasticache cluster"
15-
type = string
16-
default = "redis"
12+
variable "elasticache_private_subnets" {
13+
description = "IDs of private subnets within the VPC"
14+
type = list(string)
1715
}
1816

19-
variable "elasticache_engine_version" {
20-
description = "Version number for Elasticache engine"
17+
variable "elasticache_allow_ec2_sg" {
18+
description = "Security group associated with EC2 compute, if provisioned"
2119
type = string
22-
default = "5.0.6"
2320
}
2421

25-
variable "elasticache_param_group_name" {
26-
description = "Name for the Elasticache cluster parameter group"
22+
variable "elasticache_allow_eks_sg" {
23+
description = "Security group associated with EKS compute, if provisioned"
2724
type = string
28-
default = "default.redis5.0"
2925
}
3026

31-
variable "elasticache_num_cache_nodes" {
32-
description = "Number of nodes in the Elasticache cluster"
33-
type = number
34-
default = 1
27+
variable "elasticache_engine" {
28+
description = "Engine type for Elasticache cluster"
29+
type = string
3530
}
3631

37-
variable "vpc_id" {
38-
description = "ID of the VPC that will contain the provisioned resources"
32+
variable "elasticache_engine_version" {
33+
description = "Version number for Elasticache engine"
3934
type = string
40-
default = ""
4135
}
4236

43-
variable "vpc_private_subnets" {
44-
description = "IDs of private subnets within the VPC"
45-
type = list(string)
46-
default = []
37+
variable "elasticache_instance_type" {
38+
description = "Elasticache instance type"
39+
type = string
4740
}
4841

49-
variable "elasticache_allow_ec2_sg" {
50-
description = "Security group associated with EC2 compute, if provisioned"
42+
variable "elasticache_param_group_name" {
43+
description = "Name for the Elasticache cluster parameter group"
5144
type = string
52-
default = ""
5345
}
5446

55-
variable "elasticache_allow_eks_sg" {
56-
description = "Security group associated with EKS compute, if provisioned"
57-
type = string
58-
default = ""
47+
variable "elasticache_num_cache_nodes" {
48+
description = "Number of nodes in the Elasticache cluster"
49+
type = number
5950
}
6051

6152
variable "ec2_enabled" {

comet-infrastructure/variables.tf

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ variable "enable_eks" {
2727
}
2828

2929
variable "enable_elasticache" {
30-
description = "Toggles the ElastiCache module for provisioning Comet Redis on ElastiCache"
30+
description = "Toggles the elasticache module for provisioning Comet Redis on elasticache"
3131
type = bool
3232
}
3333

@@ -164,6 +164,43 @@ variable "eks_external_dns" {
164164
default = true
165165
}
166166

167+
#comet_elasticache
168+
variable "elasticache_private_subnets" {
169+
description = "IDs of private subnets within the VPC"
170+
type = list(string)
171+
default = null
172+
}
173+
174+
variable "elasticache_engine" {
175+
description = "Engine type for ElastiCache cluster"
176+
type = string
177+
default = "redis"
178+
}
179+
180+
variable "elasticache_engine_version" {
181+
description = "Version number for ElastiCache engine"
182+
type = string
183+
default = "5.0.6"
184+
}
185+
186+
variable "elasticache_instance_type" {
187+
description = "ElastiCache instance type"
188+
type = string
189+
default = "cache.r4.xlarge"
190+
}
191+
192+
variable "elasticache_param_group_name" {
193+
description = "Name for the ElastiCache cluster parameter group"
194+
type = string
195+
default = "default.redis5.0"
196+
}
197+
198+
variable "elasticache_num_cache_nodes" {
199+
description = "Number of nodes in the ElastiCache cluster"
200+
type = number
201+
default = 1
202+
}
203+
167204
#comet_rds
168205
variable "rds_root_password" {
169206
description = "Root password for RDS database"

0 commit comments

Comments
 (0)