tedsmitt / ecsgo

Provides an interactive prompt to connect to ECS Containers using the ECS ExecuteCommand API.
Apache License 2.0
81 stars 13 forks source link

Default behaviour tries to start /bin/sh in Windows Containers #16

Closed tedsmitt closed 2 years ago

tedsmitt commented 2 years ago

With the addition of https://aws.amazon.com/about-aws/whats-new/2022/04/amazon-commands-windows-container-aws-fargate/

When attempting to start a session on a Windows Container you'll get the following error

>> ~/.../github/ecsgo (main) [edintheclouds-dev] $ ecsgo
? Select a task: 
Cluster: bluegreen | Service: * | Task: 78619b12e30f4652a20c1ce840f2bf60
Connecting to container windows_container
Starting session with SessionId: ecs-execute-command-057be7bbf24366b94
/bin/sh : The term '/bin/sh' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or 
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ /bin/sh
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (/bin/sh:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

This can be worked around by specifying the command powershell.exe when using the tool

e.g. ecsgo -c powershell.exe

Will look at adding a check to see what the OS family is, and then decide the default command based on that information.

There also seems to be an empty space that gets printed to stdout so need to look into that as well if possible. (This happens when using the AWS CLI as well)