diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f8079ce..1497f3f 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -60,6 +60,9 @@ jobs: TF_VAR_hcaptcha_secret: ${{ secrets.HCAPTCHA_SECRET }} TF_VAR_direct_url: ${{ secrets.DIRECT_URL }} TF_VAR_database_url: ${{ secrets.DATABASE_URL }} + TF_VAR_redis_host: ${{ secrets.REDIS_HOST }} + TF_VAR_redis_port: ${{ secrets.REDIS_PORT }} + TF_VAR_redis_password: ${{ secrets.REDIS_PASSWORD }} with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/terraform/ecs/variables.tf b/terraform/ecs/variables.tf index 6ff08ab..5722c3a 100644 --- a/terraform/ecs/variables.tf +++ b/terraform/ecs/variables.tf @@ -98,3 +98,18 @@ variable "supabase_jwt_secret" { type = string sensitive = true } + +variable "redis_host" { + type = string + sensitive = true +} + +variable "redis_port" { + type = string + sensitive = true +} + +variable "redis_password" { + type = string + sensitive = true +} diff --git a/terraform/main.tf b/terraform/main.tf index 23f6202..8a493c0 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -104,15 +104,8 @@ module "redis_global" { redis_name = "cloud-auth-redis" app_name = "${terraform.workspace}_redis_${local.app_name}" - vpc_id = module.eu-central-1.vpc_id - node_type = var.redis_node_type - global = true - - private_subnet_ids = module.eu-central-1.private_subnets - - allowed_ingress_cidr_blocks = tolist(toset([ - module.us-east-1.cidr_block, - module.eu-central-1.cidr_block, - module.ap-southeast-1.cidr_block - ])) -} \ No newline at end of file + vpc_id = module.vpc.vpc_id + node_type = "cache.t2.micro" + + allowed_ingress_cidr_blocks = module.vpc.private_subnets +} diff --git a/terraform/redis/main.tf b/terraform/redis/main.tf index 17a395d..94b063e 100644 --- a/terraform/redis/main.tf +++ b/terraform/redis/main.tf @@ -1,17 +1,3 @@ -resource "aws_elasticache_cluster" "cache" { - cluster_id = replace("${var.app_name}-${var.redis_name}", "_", "-") - engine = "redis" - node_type = var.node_type - num_cache_nodes = 1 - parameter_group_name = "default.redis6.x" - engine_version = "6.x" - port = 6379 - subnet_group_name = aws_elasticache_subnet_group.private_subnets.name - security_group_ids = [ - aws_security_group.service_security_group.id - ] -} - resource "aws_elasticache_subnet_group" "private_subnets" { name = replace("${var.app_name}-${var.redis_name}-private-subnet-group", "_", "-") subnet_ids = data.aws_subnets.private_subnets.ids @@ -36,3 +22,19 @@ resource "aws_security_group" "service_security_group" { cidr_blocks = ["0.0.0.0/0"] # Allowing traffic out to all IP addresses } } + +resource "aws_elasticache_cluster" "cache" { + cluster_id = replace("${var.app_name}-${var.redis_name}", "_", "-") + engine = "redis" + node_type = var.node_type + num_cache_nodes = 1 + parameter_group_name = "default.redis6.x" + engine_version = "6.x" + port = 6379 + subnet_group_name = aws_elasticache_subnet_group.private_subnets.name + security_group_ids = [ + aws_security_group.service_security_group.id + ] +} + + diff --git a/terraform/variables.tf b/terraform/variables.tf index 827ecfa..053c4be 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -55,10 +55,12 @@ variable "redis_host" { type = string sensitive = true } + variable "redis_port" { type = string sensitive = true } + variable "redis_password" { type = string sensitive = true