From 56dc54a8d54b57e5a9db46132c4edbcfb3ee3fe5 Mon Sep 17 00:00:00 2001 From: OMPRAKASH MISHRA Date: Sun, 15 Dec 2024 20:38:20 -0800 Subject: [PATCH 1/4] try with max capacity 5 --- infrastructure/api/vars.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/api/vars.tf b/infrastructure/api/vars.tf index 02db5a8e..82fc87ee 100644 --- a/infrastructure/api/vars.tf +++ b/infrastructure/api/vars.tf @@ -103,5 +103,5 @@ variable "min_capacity" { } variable "max_capacity" { type = number - default = 3 + default = 5 } \ No newline at end of file From 6aecc1f27c65a010db21815fc0df8255054415be Mon Sep 17 00:00:00 2001 From: OMPRAKASH MISHRA Date: Sun, 15 Dec 2024 22:14:17 -0800 Subject: [PATCH 2/4] fix: pause/resume resources command and max tasks for API to 3, use non alpine image for flyway --- .github/workflows/pause-resources.yml | 2 +- .github/workflows/resume-resources.yml | 2 +- infrastructure/api/vars.tf | 2 +- migrations/Dockerfile | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pause-resources.yml b/.github/workflows/pause-resources.yml index 4d50508f..d6edd82f 100644 --- a/.github/workflows/pause-resources.yml +++ b/.github/workflows/pause-resources.yml @@ -22,7 +22,7 @@ jobs: - name: Pause AWS Resources shell: bash run: | - aws application-autoscaling register-scalable-target --service-namespace ecs --resource-id service/ecs-cluster-node-api-dev/node-api-dev-service --scalable-dimension ecs:service:DesiredCount --suspended-state DynamicScalingInSuspended=true,DynamicScalingOutSuspended=true --no-cli-pager --output json + aws application-autoscaling register-scalable-target --service-namespace ecs --resource-id service/ecs-cluster-node-api-dev/node-api-dev-service --scalable-dimension ecs:service:DesiredCount --min-capacity 0 --max-capacity 0 --no-cli-pager --output json aws ecs update-service --cluster ecs-cluster-node-api-dev --service node-api-dev-service --desired-count 0 --no-cli-pager --output json DB_CLUSTER_STATUS=$(aws rds describe-db-clusters --db-cluster-identifier qsawsc-aurora-cluster-dev --query 'DBClusters[0].Status' --output text) if [ "$DB_CLUSTER_STATUS" = "available" ]; then diff --git a/.github/workflows/resume-resources.yml b/.github/workflows/resume-resources.yml index 325b1195..c2cd3d97 100644 --- a/.github/workflows/resume-resources.yml +++ b/.github/workflows/resume-resources.yml @@ -29,4 +29,4 @@ jobs: echo "DB cluster is not in an stopped state. Current state: $DB_CLUSTER_STATUS" fi aws ecs update-service --cluster ecs-cluster-node-api-dev --service node-api-dev-service --desired-count 1 --no-cli-pager --output json - aws application-autoscaling register-scalable-target --service-namespace ecs --resource-id service/ecs-cluster-node-api-dev/node-api-dev-service --scalable-dimension ecs:service:DesiredCount --suspended-state DynamicScalingInSuspended=false,DynamicScalingOutSuspended=false --no-cli-pager --output json + aws application-autoscaling register-scalable-target --service-namespace ecs --resource-id service/ecs-cluster-node-api-dev/node-api-dev-service --scalable-dimension ecs:service:DesiredCount --min-capacity 1 --max-capacity 3 --no-cli-pager --output json diff --git a/infrastructure/api/vars.tf b/infrastructure/api/vars.tf index 82fc87ee..02db5a8e 100644 --- a/infrastructure/api/vars.tf +++ b/infrastructure/api/vars.tf @@ -103,5 +103,5 @@ variable "min_capacity" { } variable "max_capacity" { type = number - default = 5 + default = 3 } \ No newline at end of file diff --git a/migrations/Dockerfile b/migrations/Dockerfile index 0a192e48..fca440e6 100644 --- a/migrations/Dockerfile +++ b/migrations/Dockerfile @@ -1,4 +1,4 @@ -FROM flyway/flyway:10-alpine +FROM flyway/flyway:11 # Copy migrations COPY ./sql /flyway/sql @@ -9,4 +9,4 @@ USER app # Health check and startup HEALTHCHECK CMD info -CMD ["info", "migrate", "info"] +CMD ["info", "migrate", "repair"] From 4e6c989108e9a04011bfc95a98380ae8f9851f8f Mon Sep 17 00:00:00 2001 From: OMPRAKASH MISHRA Date: Sun, 15 Dec 2024 22:20:22 -0800 Subject: [PATCH 3/4] chore: add flyway to group all scripts and run them in single transactions --- infrastructure/api/ecs.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/infrastructure/api/ecs.tf b/infrastructure/api/ecs.tf index 2046194d..eda1b25e 100644 --- a/infrastructure/api/ecs.tf +++ b/infrastructure/api/ecs.tf @@ -70,6 +70,10 @@ resource "aws_ecs_task_definition" "node_api_task" { { name = "FLYWAY_CONNECT_RETRIES" value = "2" + }, + { + name = "FLYWAY_GROUP" + value = "true" } ] From 684f0d2b944e69b9525ada750d1d711d7d547e37 Mon Sep 17 00:00:00 2001 From: OMPRAKASH MISHRA Date: Sun, 15 Dec 2024 22:27:07 -0800 Subject: [PATCH 4/4] revert to alpine image --- migrations/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/Dockerfile b/migrations/Dockerfile index fca440e6..9f6c0675 100644 --- a/migrations/Dockerfile +++ b/migrations/Dockerfile @@ -1,4 +1,4 @@ -FROM flyway/flyway:11 +FROM flyway/flyway:11-alpine # Copy migrations COPY ./sql /flyway/sql