diff --git a/.gitignore b/.gitignore index 7868d16..c84de37 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ # Compiled files *.tfstate *.tfstate.backup +.terraform diff --git a/main.tf b/main.tf index d2d459a..0192f51 100644 --- a/main.tf +++ b/main.tf @@ -15,6 +15,7 @@ resource "aws_elasticache_replication_group" "redis" { number_cache_clusters = var.redis_clusters node_type = var.redis_node_type automatic_failover_enabled = var.redis_failover + multi_az_enabled = var.multi_az_enabled engine_version = var.redis_version port = var.redis_port parameter_group_name = aws_elasticache_parameter_group.redis_parameter_group.id diff --git a/security_groups.tf b/security_groups.tf index 6a941f7..8fe8b9e 100644 --- a/security_groups.tf +++ b/security_groups.tf @@ -26,3 +26,13 @@ resource "aws_security_group_rule" "redis_networks_ingress" { cidr_blocks = var.allowed_cidr security_group_id = aws_security_group.redis_security_group.id } + +resource "aws_security_group_rule" "redis_replication_egress" { + count = var.is_migration_cluster ? 1 : 0 + type = "egress" + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + security_group_id = aws_security_group.redis_security_group.id +} diff --git a/variables.tf b/variables.tf index 98633d4..31b254c 100644 --- a/variables.tf +++ b/variables.tf @@ -47,11 +47,24 @@ variable "redis_clusters" { type = string } +variable "multi_az_enabled" { + description = "Specifies whether to enable Multi-AZ Support for the replication group" + type = bool + default = false +} + variable "redis_failover" { + description = "Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails" type = bool default = false } +variable "is_migration_cluster" { + description = "Specifies whether this is a cluster for replicating other EC2 redis. Useful for migrations." + type = bool + default = false +} + variable "redis_node_type" { description = "Instance type to use for creating the Redis cache clusters" type = string diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..41b0022 --- /dev/null +++ b/versions.tf @@ -0,0 +1,11 @@ +terraform { + required_version = ">= 0.12" +} + +provider "aws" { + version = "~> 3.31" +} + +provider "random" { + version = "~> 3.1" +}