|
27 | 27 | - name: Pause AWS Resources |
28 | 28 | shell: bash |
29 | 29 | 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 0 --max-capacity 0 --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 0 --no-cli-pager --output json |
| 30 | + CLUSTER_NAME="ecs-cluster-${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-dev" |
| 31 | + SERVICE_NAME="${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-dev-service" |
| 32 | + CLUSTER_EXISTS=$(aws ecs describe-clusters --clusters $CLUSTER_NAME --query 'clusters[0].status' --output text) |
| 33 | + if [ "$CLUSTER_EXISTS" = "ACTIVE" ]; then |
| 34 | + SERVICE_EXISTS=$(aws ecs describe-services --cluster $CLUSTER_NAME --services $SERVICE_NAME --query 'services[0].status' --output text) |
| 35 | + if [ "$SERVICE_EXISTS" = "ACTIVE" ]; then |
| 36 | + aws application-autoscaling register-scalable-target --service-namespace ecs --resource-id service/$CLUSTER_NAME/$SERVICE_NAME --scalable-dimension ecs:service:DesiredCount --min-capacity 0 --max-capacity 0 --no-cli-pager --output json |
| 37 | + else |
| 38 | + echo "ECS service $SERVICE_NAME does not exist in cluster $CLUSTER_NAME." |
| 39 | + fi |
| 40 | + else |
| 41 | + echo "ECS cluster $CLUSTER_NAME does not exist." |
| 42 | + fi |
32 | 43 | 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) |
33 | 44 | if [ "$DB_CLUSTER_STATUS" = "available" ]; then |
34 | 45 | aws rds stop-db-cluster --db-cluster-identifier ${{ needs.stack-prefix.outputs.stack_prefix }}-aurora-dev --no-cli-pager --output json |
|
52 | 63 | - name: Pause AWS Resources |
53 | 64 | shell: bash |
54 | 65 | 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 0 --max-capacity 0 --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 0 --no-cli-pager --output json |
| 66 | + CLUSTER_NAME="ecs-cluster-${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-test" |
| 67 | + SERVICE_NAME="${{ needs.stack-prefix.outputs.stack_prefix }}-node-api-test-service" |
| 68 | + CLUSTER_EXISTS=$(aws ecs describe-clusters --clusters $CLUSTER_NAME --query 'clusters[0].status' --output text) |
| 69 | + if [ "$CLUSTER_EXISTS" = "ACTIVE" ]; then |
| 70 | + SERVICE_EXISTS=$(aws ecs describe-services --cluster $CLUSTER_NAME --services $SERVICE_NAME --query 'services[0].status' --output text) |
| 71 | + if [ "$SERVICE_EXISTS" = "ACTIVE" ]; then |
| 72 | + aws application-autoscaling register-scalable-target --service-namespace ecs --resource-id service/$CLUSTER_NAME/$SERVICE_NAME --scalable-dimension ecs:service:DesiredCount --min-capacity 0 --max-capacity 0 --no-cli-pager --output json |
| 73 | + else |
| 74 | + echo "ECS service $SERVICE_NAME does not exist in cluster $CLUSTER_NAME." |
| 75 | + fi |
| 76 | + else |
| 77 | + echo "ECS cluster $CLUSTER_NAME does not exist." |
| 78 | + fi |
57 | 79 | 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) |
58 | 80 | if [ "$DB_CLUSTER_STATUS" = "available" ]; then |
59 | 81 | aws rds stop-db-cluster --db-cluster-identifier ${{ needs.stack-prefix.outputs.stack_prefix }}-aurora-test --no-cli-pager --output json |
|
0 commit comments