Skip to content

Commit

Permalink
- changed app name to jasper
Browse files Browse the repository at this point in the history
- changed task def to use web
- added variables for web and api images
  • Loading branch information
Ronaldo Macapobre committed Jul 26, 2024
1 parent d73d82a commit 3b75e39
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion infrastructure/cloud/environments/sandbox/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ variable "kms_key_name" {
variable "app_name" {
description = "The name of the application"
type = string
default = "jasper-aws"
default = "jasper"
}

variable "environment" {
Expand Down
10 changes: 5 additions & 5 deletions infrastructure/cloud/modules/container/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ resource "aws_ecs_cluster" "ecs_cluster" {
}
}

resource "aws_ecs_task_definition" "ecs_task_definition" {
family = "${var.app_name}-task-${var.environment}"
resource "aws_ecs_task_definition" "ecs_web_task_definition" {
family = "${var.app_name}-web-task-${var.environment}"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = 256
memory = 512

container_definitions = jsonencode([
{
name = "${var.app_name}-container-${var.environment}"
image = "${aws_ecr_repository.ecr_repository.repository_url}:latest"
name = "${var.app_name}-web-container-${var.environment}"
image = "${aws_ecr_repository.ecr_repository.repository_url}:${var.web_image_name}"
essential = true
portMappings = [
{
Expand All @@ -34,7 +34,7 @@ resource "aws_ecs_task_definition" "ecs_task_definition" {
resource "aws_ecs_service" "ecs_service" {
name = "${var.app_name}-service-${var.environment}"
cluster = aws_ecs_cluster.ecs_cluster.id
task_definition = aws_ecs_task_definition.ecs_task_definition.arn
task_definition = aws_ecs_task_definition.ecs_web_task_definition.arn
launch_type = "FARGATE"
desired_count = 1

Expand Down
11 changes: 11 additions & 0 deletions infrastructure/cloud/modules/container/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ variable "lb_tg_arn" {
variable "lb_listener" {
description = "Load Balancer Listener"
}

variable "web_image_name" {
description = "Image Name of the frontend app"
default = "jasper-web"
}

variable "api_image_name" {
description = "Image Name of the backend app"
default = "jasper-api"
}

4 changes: 4 additions & 0 deletions infrastructure/cloud/modules/networking/elb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ resource "aws_lb_target_group" "lb_target_group" {
protocol = "HTTP"
vpc_id = aws_vpc.vpc.id
target_type = "ip"

lifecycle {
create_before_destroy = true
}
}

resource "aws_lb_listener" "lb_listener" {
Expand Down

0 comments on commit 3b75e39

Please sign in to comment.