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

feat(infra): change ecs from ec2 to fargate #2267

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions apps/infra/production/codedang/codedang_service_client.tf
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module "client_api" {
ecs_service = {
name = "Codedang-Client-Api-Service"
cluster_arn = module.codedang_api.ecs_cluster.arn
desired_count = 2
desired_count = 1
load_balancer = {
container_name = "Codedang-Client-Api"
container_port = 4000
Expand All @@ -116,7 +116,7 @@ module "client_api" {
}

appautoscaling_target = {
min_capacity = 2
min_capacity = 1
max_capacity = 8
resource_id = {
cluster_name = module.codedang_api.ecs_cluster.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ resource "aws_ecs_cluster" "this" {
name = var.ecs_cluster_name
}

resource "aws_ecs_cluster_capacity_providers" "this" {
cluster_name = aws_ecs_cluster.this.name
capacity_providers = [aws_ecs_capacity_provider.this.name]
# resource "aws_ecs_cluster_capacity_providers" "this" {
# cluster_name = aws_ecs_cluster.this.name
# capacity_providers = [aws_ecs_capacity_provider.this.name]

default_capacity_provider_strategy {
capacity_provider = aws_ecs_capacity_provider.this.name
weight = 1
base = 1
}
}
# default_capacity_provider_strategy {
# capacity_provider = aws_ecs_capacity_provider.this.name
# weight = 1
# base = 1
# }
# }
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "aws_ecs_task_definition" "this" {
family = var.task_definition.family
requires_compatibilities = ["EC2"]
network_mode = "bridge"
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
cpu = var.task_definition.cpu
memory = var.task_definition.memory
container_definitions = var.task_definition.container_definitions
Expand All @@ -14,7 +14,7 @@ resource "aws_ecs_service" "this" {
cluster = var.ecs_service.cluster_arn
task_definition = aws_ecs_task_definition.this.family
desired_count = var.ecs_service.desired_count
launch_type = "EC2"
launch_type = "FARGATE"
force_new_deployment = true

dynamic "load_balancer" {
Expand Down
Loading