Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Add elasticache in subnet group instead of creating a new
Browse files Browse the repository at this point in the history
  • Loading branch information
pjuniorlima committed Jan 21, 2022
1 parent 32a0759 commit 3cd7bbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
resource "aws_elasticache_replication_group" "default" {
engine = "redis"
parameter_group_name = aws_elasticache_parameter_group.default.name
subnet_group_name = aws_elasticache_subnet_group.default.name
subnet_group_name = var.subnet_group_name == null ? aws_elasticache_subnet_group.default[0].name : var.subnet_group_name
security_group_ids = [aws_security_group.default.id]

# The replication group identifier. This parameter is stored as a lowercase string.
Expand Down Expand Up @@ -104,6 +104,7 @@ resource "aws_elasticache_parameter_group" "default" {

# https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html
resource "aws_elasticache_subnet_group" "default" {
count = var.subnet_group_name == null ? 1 : 0
name = var.name
subnet_ids = var.subnet_ids
description = var.description
Expand Down
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ variable "node_type" {
variable "subnet_ids" {
type = list(string)
description = "List of VPC Subnet IDs for the cache subnet group."
default = []
}

variable "vpc_id" {
type = string
description = "VPC Id to associate with Redis ElastiCache."
default = ""
}

variable "subnet_group_name" {
type = string
description = "VPC Id to associate with Redis ElastiCache."
}

variable "source_cidr_blocks" {
Expand Down

0 comments on commit 3cd7bbf

Please sign in to comment.