Skip to content
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
2 changes: 2 additions & 0 deletions terraform/environments/dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ module "ecs" {
user_data_path = "./ec2-user-data.ps1"
backend_ecr_url = module.my_ecr_repo.backend_ecr_repository_url
backend_ecr_arn = module.my_ecr_repo.backend_repository_arn
backend_repository_name = module.my_ecr_repo.backend_repository_name
frontend_ecr_url = module.my_ecr_repo.frontend_ecr_repository_url
frontend_ecr_arn = module.my_ecr_repo.frontend_repository_arn
frontend_repository_name = module.my_ecr_repo.frontend_repository_name
}
10 changes: 10 additions & 0 deletions terraform/modules/ecr/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,14 @@ output "frontend_ecr_repository_url" {
output "frontend_repository_arn" {
value = aws_ecr_repository.graphbuilder_frontend_docker_repo.arn
description = "The ARN of the frontend ECR repository"
}

output "backend_repository_name" {
value = aws_ecr_repository.graphbuilder_backend_docker_repo.name
description = "The name of the backend ECR repository"
}

output "frontend_repository_name" {
value = aws_ecr_repository.graphbuilder_frontend_docker_repo.name
description = "The name of the frontend ECR repository"
}
18 changes: 13 additions & 5 deletions terraform/modules/ecs/task-definition.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
locals {
backend_task_name = "${var.project_name}-${var.environment}-backend"
}

# 1. Look up the latest image tag in ECR (we’ll use "latest")
data "aws_ecr_image" "latest" {
repository_name = var.frontend_repository_name # your ECR repo name
image_tag = "latest"
}

resource "aws_ecs_task_definition" "graphbuilder_task" {
family = "${var.project_name}-${var.environment}"
network_mode = "bridge" # Use "awsvpc" if running in Fargate
Expand Down Expand Up @@ -34,8 +41,8 @@ resource "aws_ecs_task_definition" "graphbuilder_task" {
# inside the container
environment = [
{
name = "IAN_TEST_ENV_VAR"
value = "example-ian-test-value"
name = "TEST_ENV_VAR"
value = "example-ft-test-value"
}
]
logConfiguration = {
Expand All @@ -50,7 +57,8 @@ resource "aws_ecs_task_definition" "graphbuilder_task" {
},
{
name = "${var.project_name}-${var.environment}-frontend"
image = "${var.frontend_ecr_url}:latest"
# image = "${var.frontend_ecr_url}:latest"
image = "${var.frontend_ecr_url}@${data.aws_ecr_image.latest.image_digest}"
memory = 512 # Reduced from 4096MB
cpu = 512 # Reduced from 1024 CPU units
memoryReservation = 512 # Soft limit to prevent memory contention
Expand All @@ -71,8 +79,8 @@ resource "aws_ecs_task_definition" "graphbuilder_task" {
environment = [
{
name = "VITE_BACKEND_API_URL"
value = "http://${aws_instance.ecs_instance.public_ip}:8000"
# value = "http://localhost:8000"
# value = "http://${aws_instance.ecs_instance.public_ip}:8000"
value = "http://localhost:8000"
},
{
name = "VITE_ENV"
Expand Down
10 changes: 10 additions & 0 deletions terraform/modules/ecs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ variable "backend_ecr_arn" {
description = "the ecr arn of the backend service"
}

variable "backend_repository_name" {
type = string
description = "the name of the backend ecr repository"
}

variable "frontend_ecr_url" {
type = string
description = "the ecr url of the frontend service"
Expand All @@ -62,4 +67,9 @@ variable "frontend_ecr_url" {
variable "frontend_ecr_arn" {
type = string
description = "the ecr arn of the frontend service"
}

variable "frontend_repository_name" {
type = string
description = "the name of the frontend ecr repository"
}