Skip to content

Commit

Permalink
Add elasticache tf file
Browse files Browse the repository at this point in the history
  • Loading branch information
cduhn17 committed Jul 8, 2024
1 parent 373a49c commit 169f97d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions infrastructure/elasticache.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
resource "aws_security_group" "elasticache_security_group" {
name_prefix = "elasticache-"
description = "ElastiCache security group"

ingress {
from_port = 6379
to_port = 6379
protocol = "tcp"
cidr_blocks = ["10.0.2.0/24"] // Restrict to a specific CIDR block, ideally your VPC's CIDR
}
}

resource "aws_elasticache_subnet_group" "crossfeed_vpc" {
name = "aws_vpc.crossfeed_vpc"
subnet_ids = [aws_subnet.backend.id]

tags = {
Name = "crossfeed_vpc"
}
}

resource "aws_elasticache_cluster" "crossfeed_vpc_elasticache_cluster" {
count = var.create_elastcache_cluster ? 1 : 0
cluster_id = "crossfeed-vpc-cluster"
engine = "redis"
node_type = "cache.r7g.xlarge"
num_cache_nodes = 1
parameter_group_name = "default.redis7.1"
engine_version = "7.1.0"
port = 6379
subnet_group_name = aws_elasticache_subnet_group.crossfeed_vpc.name
security_group_ids = [aws_security_group.elasticache_security_group.id]

tags = {
Name = "crossfeed_vpc_elasticache-cluster"
Project = var.project
Stage = var.stage
}
}

0 comments on commit 169f97d

Please sign in to comment.