Skip to content

Commit 2b69eac

Browse files
ghaddowmarcincuber
authored andcommitted
improve typing (#1)
automatic failover cannot be enabled if nodes < 2 to safeguard against misconfiguration
1 parent 2104ff4 commit 2b69eac

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ Module managed by [Marcin Cuber](https://github.com/marcincuber) [linkedin](http
4242
|------|-------------|:----:|:-----:|:-----:|
4343
| name\_prefix | The replication group identifier. This parameter is stored as a lowercase string. | string | n/a | yes |
4444
| node\_type | The compute and memory capacity of the nodes in the node group. | string | n/a | yes |
45-
| number\_cache\_clusters | The number of cache clusters (primary and replicas) this replication group will have. | string | n/a | yes |
45+
| number\_cache\_clusters | The number of cache clusters (primary and replicas) this replication group will have. | number | n/a | yes |
4646
| subnet\_ids | List of VPC Subnet IDs for the cache subnet group. | list(string) | n/a | yes |
4747
| vpc\_id | VPC Id to associate with Redis ElastiCache. | string | n/a | yes |
48-
| apply\_immediately | Specifies whether any modifications are applied immediately, or during the next maintenance window. | string | `"false"` | no |
49-
| at\_rest\_encryption\_enabled | Whether to enable encryption at rest. | string | `"true"` | no |
48+
| apply\_immediately | Specifies whether any modifications are applied immediately, or during the next maintenance window. | bool | `false` | no |
49+
| at\_rest\_encryption\_enabled | Whether to enable encryption at rest. | bool | `true` | no |
5050
| auth\_token | The password used to access a password protected server. Can be specified only if `transit_encryption_enabled = true`. | string | `""` | no |
5151
| auto\_minor\_version\_upgrade | | string | `"true"` | no |
52-
| automatic\_failover\_enabled | Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails. | string | `"true"` | no |
52+
| automatic\_failover\_enabled | Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails. | bool | `true` | no |
5353
| description | The description of the all resources. | string | `"Managed by Terraform"` | no |
5454
| engine\_version | The version number of the cache engine to be used for the cache clusters in this replication group. | string | `"5.0.6"` | no |
5555
| family | The family of the ElastiCache parameter group. | string | `"redis5.0"` | no |
@@ -58,12 +58,12 @@ Module managed by [Marcin Cuber](https://github.com/marcincuber) [linkedin](http
5858
| maintenance\_window | Specifies the weekly time range for when maintenance on the cache cluster is performed. | string | `""` | no |
5959
| notification\_topic\_arn | An Amazon Resource Name (ARN) of an SNS topic to send ElastiCache notifications to. Example: `arn:aws:sns:us-east-1:012345678999:my_sns_topic` | string | `""` | no |
6060
| parameter | A list of Redis parameters to apply. Note that parameters may differ from one Redis family to another | object | `[]` | no |
61-
| port | The port number on which each of the cache nodes will accept connections. | string | `"6379"` | no |
61+
| port | The port number on which each of the cache nodes will accept connections. | number | `6379` | no |
6262
| security\_group\_ids | List of Security Groups. | list(string) | `[]` | no |
63-
| snapshot\_retention\_limit | The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them. | string | `"30"` | no |
63+
| snapshot\_retention\_limit | The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them. | number | `30` | no |
6464
| snapshot\_window | The daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your cache cluster. | string | `""` | no |
6565
| tags | A mapping of tags to assign to all resources. | map(string) | `{}` | no |
66-
| transit\_encryption\_enabled | Whether to enable encryption in transit. | string | `"true"` | no |
66+
| transit\_encryption\_enabled | Whether to enable encryption in transit. | bool | `true` | no |
6767

6868
## Outputs
6969

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ resource "aws_elasticache_replication_group" "redis" {
1515
maintenance_window = var.maintenance_window
1616
snapshot_window = var.snapshot_window
1717
snapshot_retention_limit = var.snapshot_retention_limit
18-
automatic_failover_enabled = var.automatic_failover_enabled
18+
automatic_failover_enabled = var.automatic_failover_enabled && var.number_cache_clusters > 1 ? true : false
1919
auto_minor_version_upgrade = var.auto_minor_version_upgrade
2020

2121
at_rest_encryption_enabled = var.at_rest_encryption_enabled

outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@ output "security_group_egress" {
5858
description = "The egress rules of the Redis ElastiCache security group."
5959
}
6060

61+
output "elasticache_auth_token" {
62+
description = "The Redis Auth Token"
63+
value = aws_elasticache_replication_group.redis.auth_token
64+
}

variables.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ variable "name_prefix" {
44
}
55

66
variable "number_cache_clusters" {
7-
type = string
7+
type = number
88
description = "The number of cache clusters (primary and replicas) this replication group will have."
99
}
1010

@@ -43,7 +43,7 @@ variable "engine_version" {
4343

4444
variable "port" {
4545
default = 6379
46-
type = string
46+
type = number
4747
description = "The port number on which each of the cache nodes will accept connections."
4848
}
4949

@@ -60,8 +60,8 @@ variable "snapshot_window" {
6060
}
6161

6262
variable "snapshot_retention_limit" {
63-
default = "30"
64-
type = string
63+
default = 30
64+
type = number
6565
description = "The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them."
6666
}
6767

@@ -72,25 +72,25 @@ variable "auto_minor_version_upgrade" {
7272

7373
variable "automatic_failover_enabled" {
7474
default = true
75-
type = string
75+
type = bool
7676
description = "Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails."
7777
}
7878

7979
variable "at_rest_encryption_enabled" {
8080
default = true
81-
type = string
81+
type = bool
8282
description = "Whether to enable encryption at rest."
8383
}
8484

8585
variable "transit_encryption_enabled" {
8686
default = true
87-
type = string
87+
type = bool
8888
description = "Whether to enable encryption in transit."
8989
}
9090

9191
variable "apply_immediately" {
9292
default = false
93-
type = string
93+
type = bool
9494
description = "Specifies whether any modifications are applied immediately, or during the next maintenance window."
9595
}
9696

0 commit comments

Comments
 (0)