Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AWS Elasticache #414

Merged
merged 10 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_elasticache_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"
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
}
}
1 change: 1 addition & 0 deletions infrastructure/prod.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,4 @@ ssm_redshift_host = "/crossfeed/prod/REDSHIFT_HOST"
ssm_redshift_database = "/crossfeed/prod/REDSHIFT_DATABASE"
ssm_redshift_user = "/crossfeed/prod/REDSHIFT_USER"
ssm_redshift_password = "/crossfeed/prod/REDSHIFT_PASSWORD"
create_elasticache_cluster = false
2 changes: 1 addition & 1 deletion infrastructure/stage.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ pe_worker_ecs_cluster_name = "pe-staging-worker"
pe_worker_ecs_task_definition_family = "pe-staging-worker"
pe_worker_ecs_log_group_name = "pe-staging-worker"
pe_worker_ecs_role_name = "pe-staging-worker"
pe_cybersixgill_ecs_service_name = "pe-staging-cybersixgill"
logging_bucket_name = "cisa-crossfeed-staging-logging"
cloudtrail_name = "crossfeed-staging-all-events"
cloudtrail_bucket_name = "cisa-crossfeed-staging-cloudtrail"
Expand Down Expand Up @@ -105,3 +104,4 @@ ssm_redshift_host = "/crossfeed/staging/REDSHIFT_HOST"
ssm_redshift_database = "/crossfeed/staging/REDSHIFT_DATABASE"
ssm_redshift_user = "/crossfeed/staging/REDSHIFT_USER"
ssm_redshift_password = "/crossfeed/staging/REDSHIFT_PASSWORD"
create_elasticache_cluster = true
6 changes: 6 additions & 0 deletions infrastructure/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -656,3 +656,9 @@ variable "ssm_redshift_password" {
type = string
default = "/crossfeed/staging/REDSHIFT_PASSWORD"
}

variable "create_elasticache_cluster" {
description = "Whether to create a elasticache cluster."
type = bool
default = false
}
Loading