I suspect what's going on is that the `awscli` actually spawns to the session-manager-plugin. I imagine that Royal sees the custom command as executed and stopped but it can't pick up the stdin/stdout of the interactive session that session-manager-plugin is doing.
(If unfamiliar, that session-manager-plugin is something one needs to install additionally from awscli.)
I've not yet found docs on using the plugin directly. That's where the need for a Royal plugin might come into play.
session-manager-plugin AWS_SSM_START_SESSION_RESPONSE us-east-1 StartSession {"Target": "i-09xxxxxxxxxx"} https://ssm.us-east-1.amazonaws.com /opt/homebrew/Cellar/[email protected]/3.11.9/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python /opt/homebrew/bin/aws ssm start-session --target i-09xxxxxxxxxx
Hi Matt,
you might want to try running the AWS stuff inside a login shell.
For instance, if you're using bash you could try the following:
/bin/bash -l -c 'ls -lh /; /bin/bash -l'
Replace "ls -lh /" with whatever you want to execute inside the login shell.
Hope that helps!
cheers,
Felix
Felix,
Thanks for replying. It's an interesting puzzle and I think could be a boost of a feature for those in the AWS space. This thing will also do tunnel configs. Maybe with a Royal TS plugin it could map onto the existing SSH Tunnel functionality? It would be yet more of a "do anything" client for AWS admins.
The commands approach is still failing for me. I also tried directly invoking the resulting spawned session-manager-plugin as well. I'll admit to being a bit confused as to why the need for the second call of `/bin/bash -l`. (small note for others reading, but I think you mean to escape the ; with \; not /;?)
From reading some of the source of the aws cli and the session-manager-plugin, it's doing this with web sockets, which makes sense. It's just a bit beyond my python/go skills to see how the current terminal session gets attached to that process. And therefore how to get it attached in Royal TS.
I've only tried this so far as a Custom Commands on a Custom Terminal. I'll try the pre-connect task later.
Best,
Matt
Matt Warren
We are looking to migrate our EC2 connections from SSH over a VPN to the AWS Systems Manager Session Manager. We have a Dynamic Folder that will populate the host inventory. I was hoping there would be a way to do a Custom Terminal type and using either Advanced/Custom Commands or a Task/Connect Task but I've not been able to get it to work.
The aws cli command is
I can easily token the instance-id as $URI$.
Any of the options I've tried seems to execute the connection command, but then the shell I get back is just my local. I'm not sure if a plugin would be needed for this connection type or if it's possible to get this session to instansiate in Royal TSX.