如何获取可以执行某些 AWS 操作(例如 iam-CreateAccessKey、ec2-AssociateIamInstanceProfile)的所有用户?

发布于 2025-01-14 03:19:52 字数 416 浏览 2 评论 0原文

这可能吗?如果没有,也许我可以用其他方法来实现,比如获取每个用户的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尝蛊 2025-01-21 03:19:52

不幸的是,事情并没有那么简单。

最接近的选项是使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文