AWS ECS Login via Shell

I am performing

aws ecs execute-command \
    --cluster <CLUSTER> \         
    --task <TASK ARN> \
    --container <CONTAINER NAME>\
    --interactive \
    --command "/bin/sh" \

But I still get an exception whether from AWS CLI terminal or CloudShell. Why so? I just want to have remote access via shell to troubleshoot some stuff rather than relaunching a CI/CD pipeline.

Unless you can share the exception there is not much we can do to help :slight_smile:

I also fixed your shared code. Please, use code blocks or shared codes will be changed by the forum and it will be unreadable.

Does the question has anything to do with Docker Hub? Did you just wanted to ask the question in a CI/CD category not related to Docker Hub?

The original post misses to mention 3 relevant details:

  • whether the session manager plugin for the aws cli is installed
  • whether the task execution (iam) role allows the required actions in the ssmmessage: namespace
  • whether the task definition is extended by the required configuration elements to actually allow to exec into the task

By default, a service does not allow to exec into the task. It needs to be configured specifically.

It’s well documented:

At the bottom of the page, it provides a link to GitHub - aws-containers/amazon-ecs-exec-checker: 🚀 Pre-flight checks for ECS Exec, which looks usefull when troubleshooting the root cause of ecs exec problems.