如何获取可以执行某些 AWS 操作(例如 iam-CreateAccessKey、ec2-AssociateIamInstanceProfile)的所有用户?
这可能吗?如果没有,也许我可以用其他方法来实现,比如获取每个用户的 AWS 操作?
我尝试了以下命令,但这没有任何操作信息。 :(
for user in $(aws iam list-users | jq -r '.Users[].UserName'); do echo '{ "Username": "'$user'", "Info": ['; aws iam list-user-policies --user-name $user; echo ','; aws iam list-groups-for-user --user-name $user; echo ','; aws iam list-attached-user-policies --user-name $user; echo '] },'; done > users.json
Is this possible? If not, maybe I can do it the other way around like getting the AWS actions per user?
I tried the below command but this doesn't have any action info. :(
for user in $(aws iam list-users | jq -r '.Users[].UserName'); do echo '{ "Username": "'$user'", "Info": ['; aws iam list-user-policies --user-name $user; echo ','; aws iam list-groups-for-user --user-name $user; echo ','; aws iam list-attached-user-policies --user-name $user; echo '] },'; done > users.json
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,事情并没有那么简单。
最接近的选项是使用 IAM 策略模拟器测试 IAM 策略 - AWS 身份和访问管理。您可以询问特定用户是否可以使用特定参数执行给定的操作。
否则,您所能做的就是自己解析策略并尝试找出它们可以做什么。
Unfortunately, it isn't that simple.
The closest option is to Test IAM policies with the IAM policy simulator - AWS Identity and Access Management. You can ask it whether a particular user can perform a given Action with particular parameters.
Otherwise, all you can do is parse the policies yourself and try to figure out what they can do.