Session Manager OS-level admin controlled by IAM policies
We are starting to use Session Manager at my organization, and it is simplifying how we grant direct access to EC2 instances for administrators. However, we also grant unprivileged OS-level access to some users via RDP/SSH. Being able to give those users unprivileged access via Session Manager would further simplify our configuration.
Would it be possible in the future to add IAM integration into Session Manager such that the Agent grants either unprivileged (non-sudo/non-Administrators) or privileged (sudo/Administrators) OS-level access to a connecting user based on an IAM policy?
Hello bryanburke@ Thank you for sharing the feedback! We will explore ways to support this scenario.
The new Run As Support for Linux Instances (see also: What's New post) appears to partially meet this need, by checking for a specific OS username tag on the IAM user or role. The actual OS user account and whether it is a sudoer or not needs to be provisioned separately.
SSM Agent 2.3.672.0+ supports this new feature.
It doesn't look like the resolving OS user from role tagging is actually working. (Tested on 2.3.760.0)
@cudandres, would you please help explain how you configured Run As user and what was the outcome. Thanks!
Digging around more it seems simply to be a matter of waiting for state to update. I configured "Run As default user" and would start session and it behaved as expected. I'd tag an IAM user and it then start a new session and the session would start as with the default user and not the tagged username. I did this a few times and noticed after a ~2-9minutes then the username would resolve to the IAM tag.
I think adding details to the documentation about there being state synchronization you may need to wait for will be useful.
IAM is eventual consistent and when you add the tag for RunAs, it takes some time to sync and be effective. Good feedback on updating the documentation, thanks for sharing!