- Newest
- Most votes
- Most comments
Hello.
Despite the documentation below, the "ec2:Describe*" API actions do not support resource-level permissions, so you cannot control the individual resources that users can see in the console.
In other words, you can only set it to either "Show all EC2 instances" or "Do not show all."
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-policies-ec2-console.html#ex-read-only
The Amazon EC2 ec2:Describe* API actions do not support resource-level permissions, so you cannot control which individual resources users can view in the console. Therefore, the * wildcard is necessary in the Resource element of the above statement. For more information about which ARNs you can use with which Amazon EC2 API actions, see Actions, resources, and condition keys for Amazon EC2.
By the way, the condition keys that can be set are described in the following document.
https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonec2.html
So there is there another way to allow a user access/control to only specific ec2 instances?
You can extend the policy provided by @Riku_Kobayashi to define only the instances that can be started & stopped:
"Effect": "Allow",
"Action": [
"ec2:StartInstances",
"ec2:StopInstances"
],
"Resource": [
"arn:aws:ec2:ap-northeast-1:111111222222:instance/i-0123456789abcdef"
]
In terms of connecting to an instance, you can't use IAM to limit which users can SSH onto an instance on port 22.
You can control which IAM users can access through Session Manager by adding something like this to the policy https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started-enable-ssh-connections.html#ssh-connections-permissions
"Effect": "Allow",
"Action": "ssm:StartSession",
"Resource": [
"arn:aws:ec2:ap-northeast-1:111111222222:instance/i-0123456789abcdef",
"arn:aws:ssm:ap-northeast-1:111111222222:document/AWS-StartSSHSession"
]
Thanks for the speedy reply. So there is there another way to allow a user access/control to only specific ec2 instances?
Got, it. Thanks for the responses everyone!
So it seems tagging really isn't the way to go about this. We looked and the things we can do via tagging in EC2 seems to be quite limited. We'll probably have to redo how we deploy instances and have a different IAM user deploy every instance instead
Relevant content
- asked 3 years ago
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated a year ago
Unfortunately, it is not possible to restrict visibility via the management console. You cannot restrict the display, but there are some actions that can be controlled on a tag-based basis, as shown below, so it is a good idea to look at the documentation and narrow down the actions you need.