Is it possible to set up a bastion host in AWS that would be checking IAM to check if given user can connect to specific EC2 instance?
It might be a bit blurry but the idea is following.
Let's assume that a company has 2 customers and each of them operates on a single EC2 instance. So we have MachineA and MachineB for customers A and B. Then, we also have 3 employees:
- John - a sysadmin that needs to be able to connect everywhere
- Steve - developer working on a product for customer A. Clearly he should be able to connect to MachineA only
- Mary - developer working on a product for customer B. Clearly she should be able to connect to MachineB only
Both machines run in private subnet and connection to them would be possible through a bastion host in public subnet only. Now, would it be possible to configure this bastion so that it would verify user's group in IAM to make sure that this user can connect to a given machine?
So, when Mary connects through SSH to bastion she uses her own identity. There she tries to jump to MachineB
so Bastion checks user's credential, verifies that she is in group devsB
and allows her to connect but it would refuse to connect if she tried to connect to MachineA
for any reason...