Skip to content

Commit 5fff3c0

Browse files
authored
Merge pull request #12 from comet-ml/redis-auth
Enable the use of elasticache/redis auth token
2 parents 961edc5 + 3077275 commit 5fff3c0

File tree

7 files changed

+52
-16
lines changed

7 files changed

+52
-16
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,13 @@ terraform {
8989
| <a name="input_eks_mng_name"></a> [eks\_mng\_name](#input\_eks\_mng\_name) | Name for the EKS managed nodegroup | `string` | `"mng"` | no |
9090
| <a name="input_eks_node_types"></a> [eks\_node\_types](#input\_eks\_node\_types) | Node instance types for EKS managed node group | `list(string)` | <pre>[<br> "m5.4xlarge"<br>]</pre> | no |
9191
| <a name="input_elasticache_allow_from_sg"></a> [elasticache\_allow\_from\_sg](#input\_elasticache\_allow\_from\_sg) | Security group from which to allow connections to ElastiCache, to use when provisioning with existing compute | `string` | `null` | no |
92+
| <a name="input_elasticache_auth_token"></a> [elasticache\_auth\_token](#input\_elasticache\_auth\_token) | Auth token for ElastiCache | `string` | `null` | no |
9293
| <a name="input_elasticache_engine"></a> [elasticache\_engine](#input\_elasticache\_engine) | Engine type for ElastiCache cluster | `string` | `"redis"` | no |
9394
| <a name="input_elasticache_engine_version"></a> [elasticache\_engine\_version](#input\_elasticache\_engine\_version) | Version number for ElastiCache engine | `string` | `"5.0.6"` | no |
9495
| <a name="input_elasticache_instance_type"></a> [elasticache\_instance\_type](#input\_elasticache\_instance\_type) | ElastiCache instance type | `string` | `"cache.r4.xlarge"` | no |
9596
| <a name="input_elasticache_num_cache_nodes"></a> [elasticache\_num\_cache\_nodes](#input\_elasticache\_num\_cache\_nodes) | Number of nodes in the ElastiCache cluster | `number` | `1` | no |
9697
| <a name="input_elasticache_param_group_name"></a> [elasticache\_param\_group\_name](#input\_elasticache\_param\_group\_name) | Name for the ElastiCache cluster parameter group | `string` | `"default.redis5.0"` | no |
98+
| <a name="input_elasticache_transit_encryption"></a> [elasticache\_transit\_encryption](#input\_elasticache\_transit\_encryption) | Enable transit encryption for ElastiCache | `bool` | `false` | no |
9799
| <a name="input_enable_ec2"></a> [enable\_ec2](#input\_enable\_ec2) | Toggles the comet\_ec2 module, to provision EC2 resources for running Comet | `bool` | n/a | yes |
98100
| <a name="input_enable_ec2_alb"></a> [enable\_ec2\_alb](#input\_enable\_ec2\_alb) | Toggles the comet\_ec2\_alb module, to provision an ALB in front of the EC2 instance | `bool` | n/a | yes |
99101
| <a name="input_enable_eks"></a> [enable\_eks](#input\_enable\_eks) | Toggles the comet\_eks module, to provision EKS resources for running Comet | `bool` | n/a | yes |

main.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ module "comet_elasticache" {
8585
elasticache_allow_from_sg = var.enable_ec2 ? module.comet_ec2[0].comet_ec2_sg_id : (
8686
var.enable_eks ? module.comet_eks[0].nodegroup_sg_id : (
8787
var.elasticache_allow_from_sg))
88-
elasticache_engine = var.elasticache_engine
89-
elasticache_engine_version = var.elasticache_engine_version
90-
elasticache_instance_type = var.elasticache_instance_type
91-
elasticache_param_group_name = var.elasticache_param_group_name
92-
elasticache_num_cache_nodes = var.elasticache_num_cache_nodes
88+
elasticache_engine = var.elasticache_engine
89+
elasticache_engine_version = var.elasticache_engine_version
90+
elasticache_instance_type = var.elasticache_instance_type
91+
elasticache_param_group_name = var.elasticache_param_group_name
92+
elasticache_num_cache_nodes = var.elasticache_num_cache_nodes
93+
elasticache_transit_encryption = var.elasticache_transit_encryption
94+
elasticache_auth_token = var.elasticache_auth_token
9395
}
9496

9597
module "comet_rds" {

modules/comet_elasticache/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ No modules.
1616

1717
| Name | Type |
1818
|------|------|
19-
| [aws_elasticache_cluster.comet-ml-ec-redis](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource |
19+
| [aws_elasticache_replication_group.comet-ml-ec-redis](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_replication_group) | resource |
2020
| [aws_elasticache_subnet_group.comet-ml-ec-subnet-group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_subnet_group) | resource |
2121
| [aws_security_group.redis_inbound_sg](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
2222
| [aws_vpc_security_group_ingress_rule.redis_port_inbound_rule](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_security_group_ingress_rule) | resource |
@@ -26,12 +26,14 @@ No modules.
2626
| Name | Description | Type | Default | Required |
2727
|------|-------------|------|---------|:--------:|
2828
| <a name="input_elasticache_allow_from_sg"></a> [elasticache\_allow\_from\_sg](#input\_elasticache\_allow\_from\_sg) | Security group from which connections to ElastiCache will be allowed | `string` | n/a | yes |
29+
| <a name="input_elasticache_auth_token"></a> [elasticache\_auth\_token](#input\_elasticache\_auth\_token) | Auth token for ElastiCache | `string` | `null` | no |
2930
| <a name="input_elasticache_engine"></a> [elasticache\_engine](#input\_elasticache\_engine) | Engine type for Elasticache cluster | `string` | n/a | yes |
3031
| <a name="input_elasticache_engine_version"></a> [elasticache\_engine\_version](#input\_elasticache\_engine\_version) | Version number for Elasticache engine | `string` | n/a | yes |
3132
| <a name="input_elasticache_instance_type"></a> [elasticache\_instance\_type](#input\_elasticache\_instance\_type) | Elasticache instance type | `string` | n/a | yes |
3233
| <a name="input_elasticache_num_cache_nodes"></a> [elasticache\_num\_cache\_nodes](#input\_elasticache\_num\_cache\_nodes) | Number of nodes in the Elasticache cluster | `number` | n/a | yes |
3334
| <a name="input_elasticache_param_group_name"></a> [elasticache\_param\_group\_name](#input\_elasticache\_param\_group\_name) | Name for the Elasticache cluster parameter group | `string` | n/a | yes |
3435
| <a name="input_elasticache_private_subnets"></a> [elasticache\_private\_subnets](#input\_elasticache\_private\_subnets) | IDs of private subnets within the VPC | `list(string)` | n/a | yes |
36+
| <a name="input_elasticache_transit_encryption"></a> [elasticache\_transit\_encryption](#input\_elasticache\_transit\_encryption) | Enable transit encryption for ElastiCache | `bool` | n/a | yes |
3537
| <a name="input_environment"></a> [environment](#input\_environment) | Deployment environment, i.e. dev/stage/prod, etc | `string` | n/a | yes |
3638
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | ID of the VPC that will contain the provisioned resources | `string` | n/a | yes |
3739

modules/comet_elasticache/main.tf

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ locals {
77
}
88
}
99

10-
resource "aws_elasticache_cluster" "comet-ml-ec-redis" {
11-
cluster_id = "cometml-ec-redis-${var.environment}"
12-
engine = var.elasticache_engine
13-
node_type = var.elasticache_instance_type
14-
num_cache_nodes = var.elasticache_num_cache_nodes
15-
parameter_group_name = var.elasticache_param_group_name
16-
engine_version = var.elasticache_engine_version
17-
port = local.redis_port
18-
subnet_group_name = aws_elasticache_subnet_group.comet-ml-ec-subnet-group.name
19-
security_group_ids = [aws_security_group.redis_inbound_sg.id]
10+
resource "aws_elasticache_replication_group" "comet-ml-ec-redis" {
11+
engine = var.elasticache_engine
12+
engine_version = var.elasticache_engine_version
13+
transit_encryption_enabled = var.elasticache_transit_encryption
14+
auth_token = var.elasticache_auth_token
15+
automatic_failover_enabled = false
16+
replication_group_id = "cometml-ec-redis-${var.environment}"
17+
node_type = var.elasticache_instance_type
18+
num_cache_clusters = var.elasticache_num_cache_nodes
19+
parameter_group_name = var.elasticache_param_group_name
20+
port = local.redis_port
21+
subnet_group_name = aws_elasticache_subnet_group.comet-ml-ec-subnet-group.name
22+
security_group_ids = [aws_security_group.redis_inbound_sg.id]
23+
description = "Redis for CometML"
2024
}
2125

2226
resource "aws_elasticache_subnet_group" "comet-ml-ec-subnet-group" {

modules/comet_elasticache/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,15 @@ variable "elasticache_param_group_name" {
4141
variable "elasticache_num_cache_nodes" {
4242
description = "Number of nodes in the Elasticache cluster"
4343
type = number
44+
}
45+
46+
variable "elasticache_transit_encryption" {
47+
description = "Enable transit encryption for ElastiCache"
48+
type = bool
49+
}
50+
51+
variable "elasticache_auth_token" {
52+
description = "Auth token for ElastiCache"
53+
type = string
54+
default = null
4455
}

terraform.tfvars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ ssl_certificate_arn = null
5555
#### comet_elasticache ####
5656
# If setting enable_elasticache with existing compute, set the variable below to specify an SG that connections will be allowed from
5757
elasticache_allow_from_sg = "sg-012345abcdefghijkl"
58+
## Set the following to enable the auth token for Redis
59+
#elasticache_transit_encryption = true
60+
#elasticache_auth_token = "your-cometml-redis-token"
5861

5962
#### comet_rds ####
6063
# If setting enable_rds, specify the root password for RDS below, or leave null and enter at the prompt during apply

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,18 @@ variable "elasticache_num_cache_nodes" {
238238
default = 1
239239
}
240240

241+
variable "elasticache_transit_encryption" {
242+
description = "Enable transit encryption for ElastiCache"
243+
type = bool
244+
default = false
245+
}
246+
247+
variable "elasticache_auth_token" {
248+
description = "Auth token for ElastiCache"
249+
type = string
250+
default = null
251+
}
252+
241253
#### comet_rds ####
242254
variable "rds_allow_from_sg" {
243255
description = "Security group from which to allow connections to RDS, to use when provisioning with existing compute"

0 commit comments

Comments
 (0)