Skip to content

Commit

Permalink
Clean up ecs scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
johnf committed Sep 8, 2024
1 parent a2a7db5 commit 27aea2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 10 additions & 11 deletions bin/aws/ecs_rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,32 @@

export AWS_OUTPUT="json"

TASK_NAME=App
TASK_NAME="${1^}"
shift

echo "Getting cluster..."
CLUSTER=$(aws ecs list-clusters | jq -r '.clusterArns | .[]')
CLUSTER=$(aws ecs list-clusters | jq -r '.clusterArns | .[]' | grep nabu)

if [ -z "$TASK_NAME" ]; then
TASKS=$(aws ecs list-services --cluster $CLUSTER)
# | jq -r '.taskDefinitionArns | .[]' \
# | sed 's/.*task-definition\/StageCdkStack//;s/Definition.*//')
TASKS=$(aws ecs list-services --cluster "$CLUSTER")

echo "Please specify a task to run"
echo Select from $TASKS | tr '' '\n'
echo Select from "$TASKS" | tr '' '\n'
exit 1
fi

echo "Getting service..."
SERVICE=$(aws ecs list-services --cluster $CLUSTER | jq -r '.serviceArns | .[]' | grep -i -- $TASK_NAME | tail -1)
SERVICE=$(aws ecs list-services --cluster "$CLUSTER" | jq -r '.serviceArns | .[]' | grep -i -- "$TASK_NAME" | tail -1)

echo "Getting service name..."
SERVICE_NAME=$(aws ecs describe-services --services $SERVICE --cluster $CLUSTER | jq -r .services[0].serviceName)
SERVICE_NAME=$(aws ecs describe-services --services "$SERVICE" --cluster "$CLUSTER" | jq -r .services[0].serviceName)

echo "Getting task..."
TASK=$(aws ecs list-tasks --cluster $CLUSTER --service-name $SERVICE_NAME | jq -r .taskArns[0])
TASK=$(aws ecs list-tasks --cluster "$CLUSTER" --service-name "$SERVICE_NAME" | jq -r .taskArns[0])

aws ecs execute-command \
--cluster $CLUSTER \
--task $TASK \
--cluster "$CLUSTER" \
--task "$TASK" \
--interactive \
--container "${TASK_NAME}Container" \
--command "bundle exec rake $@"
2 changes: 0 additions & 2 deletions bin/aws/ecs_shell
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ CLUSTER=$(aws ecs list-clusters | jq -r '.clusterArns | .[]' | grep nabu)

if [ -z "$TASK_NAME" ]; then
TASKS=$(aws ecs list-services --cluster "$CLUSTER")
# | jq -r '.taskDefinitionArns | .[]' \
# | sed 's/.*task-definition\/StageCdkStack//;s/Definition.*//')

echo "Please specify a task to run"
echo Select from "$TASKS" | tr '' '\n'
Expand Down

0 comments on commit 27aea2f

Please sign in to comment.