Skip to content

Commit d1a32e4

Browse files
authored
Merge pull request #18 from DNXLabs/feature/valkey
Add valkey support
2 parents f5795e2 + bcc8344 commit d1a32e4

22 files changed

+308
-167
lines changed

.github/workflows/docs.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ jobs:
55
docs:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v2
9-
with:
10-
ref: ${{ github.head_ref }}
8+
- uses: actions/checkout@v4
9+
with:
10+
ref: ${{ github.head_ref }}
1111

12-
- name: Render terraform docs inside the README.md and push changes back to pushed branch
13-
uses: DNXLabs/[email protected]
14-
with:
15-
tf_docs_working_dir: .
16-
tf_docs_output_file: README.md
17-
tf_docs_output_method: inject
18-
tf_docs_git_push: 'true'
19-
tf_docs_git_commit_message: 'terraform-docs: automated update action'
12+
- name: Render terraform docs inside the README.md and push changes back to pushed branch
13+
uses: DNXLabs/[email protected]
14+
with:
15+
tf_docs_working_dir: .
16+
tf_docs_output_file: README.md
17+
tf_docs_output_method: inject
18+
tf_docs_git_push: "true"
19+
tf_docs_git_commit_message: "terraform-docs: automated update action"

.github/workflows/documentation.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ jobs:
99
docs:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
13-
with:
14-
ref: master
12+
- uses: actions/checkout@v4
13+
with:
14+
ref: master
1515

16-
- name: Render terraform docs inside the README.md and push changes back to pushed branch
17-
uses: DNXLabs/[email protected]
18-
with:
19-
tf_docs_working_dir: .
20-
tf_docs_output_file: README.md
21-
tf_docs_output_method: inject
22-
tf_docs_git_push: 'true'
23-
tf_docs_git_commit_message: 'terraform-docs: automated update action'
16+
- name: Render terraform docs inside the README.md and push changes back to pushed branch
17+
uses: DNXLabs/[email protected]
18+
with:
19+
tf_docs_working_dir: .
20+
tf_docs_output_file: README.md
21+
tf_docs_output_method: inject
22+
tf_docs_git_push: "true"
23+
tf_docs_git_commit_message: "terraform-docs: automated update action"

.github/workflows/lint.yml

+13-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
name: Lint
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@master
10+
- uses: actions/checkout@v4
1111
- name: TFLint
1212
uses: docker://wata727/tflint
1313

@@ -17,7 +17,7 @@ jobs:
1717
container:
1818
image: hashicorp/terraform:latest
1919
steps:
20-
- uses: actions/checkout@master
20+
- uses: actions/checkout@v4
2121
- run: terraform fmt --recursive -check=true
2222

2323
validate:
@@ -26,15 +26,15 @@ jobs:
2626
container:
2727
image: hashicorp/terraform:latest
2828
steps:
29-
- uses: actions/checkout@master
29+
- uses: actions/checkout@v4
3030
- name: Validate Code
3131
env:
32-
AWS_REGION: 'us-east-1'
32+
AWS_REGION: "us-east-1"
3333
TF_WARN_OUTPUT_ERRORS: 1
34-
TF_VAR_vpc_id: 'vpc-123456'
34+
TF_VAR_vpc_id: "vpc-123456"
3535
TF_VAR_subnets: '["subnet-12345a"]'
36-
TF_VAR_workers_ami_id: 'ami-123456'
37-
TF_VAR_cluster_name: 'test_cluster'
36+
TF_VAR_workers_ami_id: "ami-123456"
37+
TF_VAR_cluster_name: "test_cluster"
3838
run: |
3939
terraform init
4040
terraform validate
@@ -46,18 +46,19 @@ jobs:
4646
terraform validate
4747
cd -
4848
done
49+
4950
minimum:
5051
name: Minimum version check
5152
runs-on: ubuntu-latest
5253
container:
53-
image: hashicorp/terraform:0.13.0
54+
image: hashicorp/terraform:1.10.0
5455
steps:
55-
- uses: actions/checkout@master
56+
- uses: actions/checkout@v4
5657
- name: Validate Code
5758
env:
58-
AWS_REGION: 'us-east-1'
59+
AWS_REGION: "us-east-1"
5960
TF_WARN_OUTPUT_ERRORS: 1
6061
run: |
61-
sed -i -e 's/>=/=/' -e 's/ \(\d\+\.\d\+\)"/ \1.0"/' versions.tf
62+
sed -i -e 's/>=/=/' -e 's/ \(\d\+\.\d\+\)"/ \1.0"/' _versions.tf
6263
terraform init
63-
terraform validate -var "region=${AWS_REGION}" -var "vpc_id=vpc-123456" -var "subnets=[\"subnet-12345a\"]" -var "workers_ami_id=ami-123456" -var "cluster_ingress_cidrs=[]" -var "cluster_name=test_cluster"
64+
terraform validate -var "region=${AWS_REGION}" -var "vpc_id=vpc-123456" -var "subnets=[\"subnet-12345a\"]" -var "workers_ami_id=ami-123456" -var "cluster_ingress_cidrs=[]" -var "cluster_name=test_cluster"

.github/workflows/scan.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# name: Scan
2+
3+
# on: [push]
4+
5+
# permissions: read-all
6+
7+
# jobs:
8+
# scan:
9+
# runs-on: ubuntu-latest
10+
# steps:
11+
# - name: Checkout repo
12+
# uses: actions/checkout@v4
13+
# - name: Run Checkov action
14+
# id: checkov
15+
# uses: bridgecrewio/checkov-action@v12
16+
# with:
17+
# directory: .
18+
# framework: terraform

.github/workflows/test.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# name: Lint
2+
3+
# on: [push]
4+
5+
# jobs:
6+
# test:
7+
# name: Run Tests
8+
# runs-on: ubuntu-latest
9+
# container:
10+
# image: hashicorp/terraform:latest
11+
# steps:
12+
# - uses: actions/checkout@v4
13+
# - run: terraform test

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module
2+
.terraform

.terraform.lock.hcl

+44
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module "redis" {
3535
redis_port = try(each.value.redis_port, 6379)
3636
redis_snapshot_retention_limit = try(each.value.redis_snapshot_retention_limit, 0)
3737
redis_snapshot_window = try(each.value.redis_snapshot_window, "06:30-07:30") # "The daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your cache cluster."
38-
redis_version = try(each.value.redis_version, "3.2.10") # "Whether to enable encryption in transit. Requires 3.2.6 or >=4.0 redis_version"
38+
engine_version = try(each.value.engine_version, "3.2.10") # "Whether to enable encryption in transit. Requires 3.2.6 or >=4.0 engine_version"
3939
snapshot_arns = try(each.value.snapshot_arns, []) # "A single-element string list containing an Amazon Resource Name (ARN) of a Redis RDB snapshot file stored in Amazon S3. Example: arn:aws:s3:::my_bucket/snapshot1.rdb"
4040
snapshot_name = try(each.value.snapshot_name, "") # " The name of a snapshot from which to restore data into the new node group. Changing the snapshot_name forces a new resource"
4141
tags = try(each.value.tags, {})

_locals.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
locals {
2-
major_version = tonumber(replace(var.redis_version, "/\\.[\\d][\\.\\d]*/", ""))
2+
major_version = tonumber(replace(var.engine_version, "/\\.[\\d][\\.\\d]*/", ""))
33
}

variables.tf _variables.tf

+39-29
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ variable "subnet_tags_filter" {
2222
}
2323
}
2424

25-
2625
variable "apply_immediately" {
2726
description = "Specifies whether any modifications are applied immediately, or during the next maintenance window. Default is false."
2827
type = bool
@@ -59,84 +58,93 @@ variable "name" {
5958
type = string
6059
}
6160

62-
variable "redis_clusters" {
61+
variable "number_clusters" {
6362
description = "Number of Redis cache clusters (nodes) to create"
6463
type = string
64+
default = 0
6565
}
6666

67-
variable "redis_cluster_enable" {
67+
variable "cluster_enabled" {
6868
description = "Enable or disable cluster mode"
6969
type = bool
7070
default = false
7171
}
7272

73-
variable "redis_cluster_num_node_groups" {
73+
variable "cluster_num_node_groups" {
7474
description = "Number of node groups"
7575
type = number
7676
default = 2
7777
}
7878

79-
variable "redis_cluster_replicas_per_node_group" {
79+
variable "cluster_replicas_per_node_group" {
8080
description = "Replicas per node group"
8181
type = number
8282
default = 1
8383
}
8484

85-
86-
87-
variable "redis_failover" {
88-
type = bool
89-
default = false
85+
variable "failover_enabled" {
86+
type = bool
87+
default = false
88+
description = "If the cache cluster should have failover enabled"
9089
}
9190

9291
variable "multi_az_enabled" {
93-
type = bool
94-
default = false
92+
type = bool
93+
default = false
94+
description = "If the cache cluster should be multi-az"
9595
}
9696

97-
variable "redis_node_type" {
97+
variable "node_type" {
9898
description = "Instance type to use for creating the Redis cache clusters"
9999
type = string
100-
default = "cache.m3.medium"
100+
default = "cache.t4g.micro"
101101
}
102102

103-
variable "redis_port" {
104-
type = number
105-
default = 6379
103+
variable "port" {
104+
type = number
105+
description = "Port to use on cache. 6379 for Redis, 11211 for memcached."
106+
default = 6379
106107
}
107108

108109
variable "vpc_id" {
109110
type = string
110111
description = "Vpc Id"
111112
}
112113

113-
# might want a map
114-
variable "redis_version" {
114+
variable "engine" {
115+
type = string
116+
default = "redis"
117+
validation {
118+
condition = contains(["redis", "valkey"], var.engine)
119+
error_message = "Only 'redis' or 'valkey' is supported."
120+
}
121+
}
122+
123+
variable "engine_version" {
115124
description = "Redis version to use, defaults to 3.2.10"
116125
type = string
117126
default = "6.2"
118127
}
119128

120-
121129
variable "redis_parameters" {
122130
description = "additional parameters modifyed in parameter group"
123131
type = list(map(any))
124132
default = []
125133
}
126134

127-
variable "redis_maintenance_window" {
135+
variable "maintenance_window" {
128136
description = "Specifies the weekly time range for when maintenance on the cache cluster is performed. The format is ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC). The minimum maintenance window is a 60 minute period"
129137
type = string
130138
default = "fri:08:00-fri:09:00"
131139
}
132140

133-
variable "redis_snapshot_window" {
141+
variable "snapshot_window" {
134142
description = "The daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your cache cluster. The minimum snapshot window is a 60 minute period"
135143
type = string
136144
default = "06:30-07:30"
137145
}
138146

139-
variable "redis_snapshot_retention_limit" {
147+
variable "snapshot_retention_limit" {
140148
description = "The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them. For example, if you set SnapshotRetentionLimit to 5, then a snapshot that was taken today will be retained for 5 days before being deleted. If the value of SnapshotRetentionLimit is set to zero (0), backups are turned off. Please note that setting a snapshot_retention_limit is not supported on cache.t1.micro or cache.t2.* cache nodes"
141149
type = number
142150
default = 0
@@ -163,7 +171,7 @@ variable "availability_zones" {
163171
variable "at_rest_encryption_enabled" {
164172
description = "Whether to enable encryption at rest"
165173
type = bool
166-
default = false
174+
default = true
167175
}
168176

169177
variable "kms_key_id" {
@@ -173,7 +181,7 @@ variable "kms_key_id" {
173181
}
174182

175183
variable "transit_encryption_enabled" {
176-
description = "Whether to enable encryption in transit. Requires 3.2.6 or >=4.0 redis_version"
184+
description = "Whether to enable encryption in transit. Requires 3.2.6 or >=4.0 engine_version"
177185
type = bool
178186
default = false
179187
}
@@ -220,12 +228,14 @@ variable "user_group_ids" {
220228
default = null
221229
}
222230

223-
variable "create_redis_subnet_group" {
224-
description = "Create a Subnet group?"
231+
variable "create_subnet_group" {
232+
description = "If the module should create a Subnet group"
233+
type = bool
225234
default = true
226235
}
227236

228-
variable "redis_subnet_group_id" {
229-
description = "Redis subnet group id"
237+
variable "subnet_group_id" {
238+
description = "Subnet group ID to use for the replication group"
230239
type = string
240+
default = null
231241
}

_versions.tf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_version = "> 1.3.0"
3+
required_providers {
4+
aws = {
5+
source = "hashicorp/aws"
6+
version = "> 5.0.0"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)