Skip to content

Commit 801b721

Browse files
navfarmpaul-ylz
andauthored
Parameterizing the values of Encryption at rest and trasit (#6)
Co-authored-by: Navfarm <navfarm.sph.com.sg> Co-authored-by: Paul Yeoh <[email protected]>
1 parent ea1db15 commit 801b721

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ No modules.
4242
| <a name="input_alarm_ecpu_threshold_percent"></a> [alarm\_ecpu\_threshold\_percent](#input\_alarm\_ecpu\_threshold\_percent) | ECPU threshold alarm level for elasticache serverless | `number` | `75` | no |
4343
| <a name="input_alarm_memory_threshold_bytes"></a> [alarm\_memory\_threshold\_bytes](#input\_alarm\_memory\_threshold\_bytes) | Alarm memory threshold bytes | `number` | `10000000` | no |
4444
| <a name="input_apply_immediately"></a> [apply\_immediately](#input\_apply\_immediately) | Specifies whether any database modifications are applied immediately, or during the next maintenance window | `bool` | `true` | no |
45+
| <a name="input_at_rest_encryption_enabled"></a> [at\_rest\_encryption\_enabled](#input\_at\_rest\_encryption\_enabled) | Specifies whether the encryption at rest is enabled | `bool` | `true` | no |
4546
| <a name="input_auth_token"></a> [auth\_token](#input\_auth\_token) | Password used to access a password protected server. Can be specified only if `transit_encryption_enabled = true` | `string` | `null` | no |
4647
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | Cluster ID | `string` | `null` | no |
4748
| <a name="input_cluster_mode_enabled"></a> [cluster\_mode\_enabled](#input\_cluster\_mode\_enabled) | Set to false to diable cluster module | `bool` | `false` | no |
@@ -74,6 +75,7 @@ No modules.
7475
| <a name="input_subnet_group_name"></a> [subnet\_group\_name](#input\_subnet\_group\_name) | Subnet group name for the ElastiCache instance | `string` | `""` | no |
7576
| <a name="input_subnets"></a> [subnets](#input\_subnets) | AWS subnet ids | `list(string)` | `[]` | no |
7677
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (\_e.g.\_ map("BusinessUnit","ABC") | `map(string)` | `{}` | no |
78+
| <a name="input_transit_encryption_enabled"></a> [transit\_encryption\_enabled](#input\_transit\_encryption\_enabled) | Specifies whether the encryption at transit is enabled | `bool` | `true` | no |
7779
| <a name="input_use_serverless"></a> [use\_serverless](#input\_use\_serverless) | Use serverless ElastiCache service | `bool` | `false` | no |
7880

7981
## Outputs

main.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ resource "aws_elasticache_replication_group" "this" {
5757
security_group_ids = var.security_groups
5858

5959
multi_az_enabled = var.replication_enabled ? true : false
60-
at_rest_encryption_enabled = true
61-
transit_encryption_enabled = true
60+
at_rest_encryption_enabled = var.at_rest_encryption_enabled
61+
transit_encryption_enabled = var.transit_encryption_enabled
6262
automatic_failover_enabled = var.replication_enabled ? true : false
6363

6464
notification_topic_arn = var.notification_topic_arn
6565

6666
apply_immediately = var.apply_immediately
6767

68-
auth_token = var.auth_token
69-
kms_key_id = var.kms_key_id
68+
auth_token = var.transit_encryption_enabled ? var.auth_token : null
69+
kms_key_id = var.at_rest_encryption_enabled ? var.kms_key_id : null
7070

7171
num_node_groups = var.cluster_mode_enabled ? var.num_node_groups : null
7272
replicas_per_node_group = var.cluster_mode_enabled ? var.replicas_per_node_group : null

variables.tf

+12
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,24 @@ variable "snapshot_retention_limit" {
178178
default = 5
179179
}
180180

181+
variable "transit_encryption_enabled" {
182+
description = "Whether to enable encryption in transit"
183+
type = string
184+
default = true
185+
}
186+
181187
variable "auth_token" {
182188
description = "Password used to access a password protected server. Can be specified only if `transit_encryption_enabled = true`"
183189
type = string
184190
default = null
185191
}
186192

193+
variable "at_rest_encryption_enabled" {
194+
description = "Whether to enable encryption at rest"
195+
type = string
196+
default = true
197+
}
198+
187199
variable "kms_key_id" {
188200
description = "The ARN of the key that you wish to use if encrypting at rest. If not supplied, uses service managed encryption. Can be specified only if `at_rest_encryption_enabled = true`"
189201
type = string

0 commit comments

Comments
 (0)