6

I try to using Session Manager within my CI (with a vanilla configuration, so nothing too fancy).

All inputs (keys, etc.) and configurations (user/strategy/key) are valid. I succeed to start a session on my own laptop.

But on my pipeline i got the following message

Starting session with SessionId: xxxx-xxxxxxx
$ **Cannot perform start session: EOF**

Is this shell related ?

For reference, tools used on the CI :

  • Session Manager plugin : 1.2.30.0
  • AWS CLI : aws-cli/1.18.223 Python/2.7.17 Linux/5.4.0-1039-azure botocore/1.19.63
alxsbn
  • 340
  • 2
  • 14
  • 1
    Did you figure out the solution? I'm having the same issue. My case is I'm running `aws ecs execute-command` from github action. – Benjamin Hao Jun 06 '21 at 18:32
  • 1
    @BenjaminHao Yes, it's simply related to TTY. At the end we reserved start-session for SSHing through laptops. For our CD we're using `aws ssm send-command --document-name "AWS-RunShellScript"` and a script executed remotly (on EC2 on our case, not ECS). Regards – alxsbn Jun 07 '21 at 09:31
  • 2
    Thanks! I will try your solution. I found another one that worked for me. I installed `expect` by `sudo apt-get install expect` and run the command using `unbuffer aws ecs execute-command .... ` – Benjamin Hao Jun 07 '21 at 18:12
  • @BenjaminHao It's clever, since unbuffer allow to bypass the interactive behavior ;) – alxsbn Jun 08 '21 at 07:53

1 Answers1

8

If you bumped into this error like I did:

Cannot perform start session: EOF

and got here, then using the information from Benjamin Hao's comment, here are the steps I took to make it finally work:

Install expect, in my case I had to install it on the Github hosted runner which is installed with Ubuntu:

apt install -y expect

Then, add "unbuffer" before the command you're trying to execute, for example:

unbuffer aws ecs execute-command --region $REGION --cluster $ecs_cluster_name --task $ecs_task_id --container ops-machine --command 'clitool env start --confirm' --interactive
Itai Ganot
  • 5,873
  • 18
  • 56
  • 99