@@ -27,14 +27,31 @@ jobs:
2727 - name : Resume AWS Resources
2828 shell : bash
2929 run : |
30- aws application-autoscaling register-scalable-target --service-namespace ecs --resource-id service/ecs-cluster-${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-dev/${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-dev-service --scalable-dimension ecs:service:DesiredCount --min-capacity 1 --max-capacity 2 --no-cli-pager --output json
31- aws ecs update-service --cluster ecs-cluster-${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-dev --service ${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-dev-service --desired-count 1 --no-cli-pager --output json
3230 DB_CLUSTER_STATUS=$(aws rds describe-db-clusters --db-cluster-identifier ${{ needs.stack-prefix.outputs.stack_prefix }}-aurora-dev --query 'DBClusters[0].Status' --output text)
3331 if [ "$DB_CLUSTER_STATUS" = "stopped" ]; then
3432 aws rds start-db-cluster --db-cluster-identifier ${{ needs.stack-prefix.outputs.stack_prefix }}-aurora-dev --no-cli-pager --output json
33+ # wait for the cluster to be available
34+ attempt=1
35+ max_attempts=20
36+ until [[ $(aws rds describe-db-clusters --db-cluster-identifier ${{ needs.stack-prefix.outputs.stack_prefix }}-aurora-dev --query 'DBClusters[0].Status' --output text) == "available" ]] || [[ $attempt -gt $max_attempts ]]
37+ do
38+ echo "Waiting for DB cluster to be available... Attempt $attempt of $max_attempts"
39+ sleep 60
40+ ((attempt++))
41+ done
42+
43+ if [[ $attempt -gt $max_attempts ]]; then
44+ echo "Timeout waiting for DB cluster to become available"
45+ exit 1
46+ fi
47+ echo "DB cluster is now available"
48+
3549 else
3650 echo "DB cluster is not in a stopped state. Current state: $DB_CLUSTER_STATUS"
3751 fi
52+ aws application-autoscaling register-scalable-target --service-namespace ecs --resource-id service/ecs-cluster-${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-dev/${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-dev-service --scalable-dimension ecs:service:DesiredCount --min-capacity 1 --max-capacity 2 --no-cli-pager --output json
53+ aws ecs update-service --cluster ecs-cluster-${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-dev --service ${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-dev-service --desired-count 1 --no-cli-pager --output json
54+
3855 resume-resources-test :
3956 name : Resume Resources Test
4057 environment : test
@@ -52,11 +69,27 @@ jobs:
5269 - name : Resume AWS Resources
5370 shell : bash
5471 run : |
55- aws application-autoscaling register-scalable-target --service-namespace ecs --resource-id service/ecs-cluster-${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-test/${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-test-service --scalable-dimension ecs:service:DesiredCount --min-capacity 1 --max-capacity 2 --no-cli-pager --output json
56- aws ecs update-service --cluster ecs-cluster-${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-test --service ${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-test-service --desired-count 1 --no-cli-pager --output json
5772 DB_CLUSTER_STATUS=$(aws rds describe-db-clusters --db-cluster-identifier ${{ needs.stack-prefix.outputs.stack_prefix }}-aurora-test --query 'DBClusters[0].Status' --output text)
5873 if [ "$DB_CLUSTER_STATUS" = "stopped" ]; then
5974 aws rds start-db-cluster --db-cluster-identifier ${{ needs.stack-prefix.outputs.stack_prefix }}-aurora-test --no-cli-pager --output json
75+ # wait for the cluster to be available
76+ attempt=1
77+ max_attempts=20
78+ until [[ $(aws rds describe-db-clusters --db-cluster-identifier ${{ needs.stack-prefix.outputs.stack_prefix }}-aurora-test --query 'DBClusters[0].Status' --output text) == "available" ]] || [[ $attempt -gt $max_attempts ]]
79+ do
80+ echo "Waiting for DB cluster to be available... Attempt $attempt of $max_attempts"
81+ sleep 60
82+ ((attempt++))
83+ done
84+
85+ if [[ $attempt -gt $max_attempts ]]; then
86+ echo "Timeout waiting for DB cluster to become available"
87+ exit 1
88+ fi
89+ echo "DB cluster is now available"
6090 else
6191 echo "DB cluster is not in a stopped state. Current state: $DB_CLUSTER_STATUS"
62- fi
92+ fi
93+ aws application-autoscaling register-scalable-target --service-namespace ecs --resource-id service/ecs-cluster-${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-test/${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-test-service --scalable-dimension ecs:service:DesiredCount --min-capacity 1 --max-capacity 2 --no-cli-pager --output json
94+ aws ecs update-service --cluster ecs-cluster-${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-test --service ${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-test-service --desired-count 1 --no-cli-pager --output json
95+
0 commit comments