Skip to content

Instantly share code, notes, and snippets.

@grohiro
Last active November 29, 2023 09:03
Show Gist options
  • Select an option

  • Save grohiro/84c978c05b34e98055e1db30b5a8896e to your computer and use it in GitHub Desktop.

Select an option

Save grohiro/84c978c05b34e98055e1db30b5a8896e to your computer and use it in GitHub Desktop.
ecsh
#!/bin/bash
ecs_cluster_arn=$(aws ecs list-clusters | jq -r '.clusterArns[]' | fzf --layout=reverse-list)
ecs_cluster=${ecs_cluster_arn##*/}
container=$(aws ecs describe-tasks --tasks $(aws ecs list-tasks --cluster $ecs_cluster | jq -r '.taskArns[]') --cluster $ecs_cluster | jq -r '.tasks[] | (.group + "|" + (.containers[] | (.name + "|" + .taskArn)))' | fzf --layout=reverse-list)
task_id=$(echo $container | cut -d'|' -f3)
container_name=$(echo $container | cut -d'|' -f2)
aws ecs execute-command --cluster $ecs_cluster \
--task $task_id \
--container $container_name \
--interactive \
--command "/bin/sh"
@grohiro

grohiro commented Nov 29, 2023 •

Copy link
Copy Markdown
Author
$ chmod 755 ecsh
$ export AWS_PROFILE=your-profile
$ ecsh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment