Skip to content

Commit cde2c4d

Browse files
milldrgoruha
andauthored
feat: transit_encryption_mode (#47)
* Add output for transit encryption mode in Redis cluster * Update auth_token generation logic and transit encryption mode output * Add support for transit encryption mode in Redis cluster * Update src/modules/redis_cluster/outputs.tf Co-authored-by: Igor Rodionov <goruha@gmail.com> --------- Co-authored-by: Igor Rodionov <goruha@gmail.com>
1 parent 4a65d3c commit cde2c4d

File tree

8 files changed

+23
-6
lines changed

8 files changed

+23
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@ github/
7676
*.ovpn
7777

7878
*.zip
79+
account-map/

src/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ locals {
4747
port = var.port
4848
at_rest_encryption_enabled = var.at_rest_encryption_enabled
4949
transit_encryption_enabled = var.transit_encryption_enabled
50+
transit_encryption_mode = var.transit_encryption_mode
5051
apply_immediately = var.apply_immediately
5152
automatic_failover_enabled = var.automatic_failover_enabled
5253
auto_minor_version_upgrade = var.auto_minor_version_upgrade

src/modules/redis_cluster/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ locals {
55

66
ssm_path_auth_token = local.auth_token_enabled ? format("/%s/%s/%s", "elasticache-redis", var.cluster_name, "auth_token") : null
77

8-
auth_token = local.auth_token_enabled ? join("", random_password.auth_token.*.result) : null
8+
auth_token = local.auth_token_enabled ? one(random_password.auth_token[*].result) : null
99
}
1010

1111
module "redis" {
1212
source = "cloudposse/elasticache-redis/aws"
13-
version = "1.9.2"
13+
version = "1.10.0"
1414

1515
name = var.cluster_name
1616

@@ -39,6 +39,7 @@ module "redis" {
3939
port = var.cluster_attributes.port
4040
subnets = var.cluster_attributes.subnets
4141
transit_encryption_enabled = var.cluster_attributes.transit_encryption_enabled
42+
transit_encryption_mode = var.cluster_attributes.transit_encryption_mode
4243
snapshot_retention_limit = var.cluster_attributes.snapshot_retention_limit
4344
vpc_id = var.cluster_attributes.vpc_id
4445
zone_id = var.cluster_attributes.zone_id

src/modules/redis_cluster/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ output "cluster_ssm_path_auth_token" {
2727
value = local.ssm_path_auth_token
2828
description = "SSM path of Redis auth_token"
2929
}
30+
31+
output "transit_encryption_mode" {
32+
value = module.redis.transit_encryption_mode
33+
description = "TLS in-transit encryption mode for Redis cluster"
34+
}

src/modules/redis_cluster/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ variable "cluster_attributes" {
6464
multi_az_enabled = bool
6565
at_rest_encryption_enabled = bool
6666
transit_encryption_enabled = bool
67+
transit_encryption_mode = string
6768
apply_immediately = bool
6869
automatic_failover_enabled = bool
6970
auto_minor_version_upgrade = bool
@@ -88,6 +89,7 @@ variable "parameter_group_name" {
8889
}
8990

9091
variable "kms_alias_name_ssm" {
92+
type = string
9193
default = "alias/aws/ssm"
9294
description = "KMS alias name for SSM"
9395
}

src/modules/redis_cluster/versions.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ terraform {
22
required_version = ">= 1.0.0"
33

44
required_providers {
5-
aws = {
6-
source = "hashicorp/aws"
7-
version = ">= 4.0, < 6.0.0"
8-
}
95
random = {
106
source = "hashicorp/random"
117
version = ">= 3.0"

src/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ output "security_group_id" {
77
description = "The security group ID of the ElastiCache Redis cluster"
88
value = local.enabled ? try(module.redis_clusters[keys(var.redis_clusters)[0]].security_group_id, null) : null
99
}
10+
11+
output "transit_encryption_mode" {
12+
description = "TLS in-transit encryption mode for Redis cluster"
13+
value = local.enabled ? try(module.redis_clusters[keys(var.redis_clusters)[0]].transit_encryption_mode, null) : null
14+
}

src/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ variable "transit_encryption_enabled" {
5050
description = "Enable TLS"
5151
}
5252

53+
variable "transit_encryption_mode" {
54+
type = string
55+
default = null
56+
description = "Transit encryption mode. Valid values are 'preferred' and 'required'"
57+
}
58+
5359
variable "auth_token_enabled" {
5460
type = bool
5561
description = "Enable auth token"

0 commit comments

Comments
 (0)