跳至内容

How to debug what permissions my user has?

0

I got an error about missing permissions: Resource handler returned message: \"User: arn:aws:sts::123:assumed-role/something/aws-go-sdk-123 is not authorized to perform: iam:CreateRole on resource arn:12345

Now I'm trying to map that to the IAM concepts of user, role, & policy.

First let's see who I'm logged in as. When I run aws sts get-caller-identity, I get something like this: { "UserId": "ABC123:botocore-session-123", "Account": "1234", "Arn": "arn:aws:sts::123:assumed-role/something/botocore-session-123" }

My user id is very unhelpful here; it doesn't seem to be listed on AWS console IAM page and iam list attached-user-policies takes a username, not a user id. How can I figure out what permissions my running user / assumed role has? From there I can probably figure out how to give myself the correct permissions.

已提问 5 个月前134 查看次数
3 回答
0
已接受的回答

Thanks for the answers folks. From Shajam's & AI's answer, the most important bit from the ARN is the "something" role which I'm assuming. This is what actually has permissions & policies attached to it. To see what policies I have access to, I can look in UI or with aws iam list-attached-role-policies --role-name something. From there I can see that my role indeed lacks the permissions necessary to CreateTag.

I used an admin account to grant such permissions. Unfortunately CreateRole in particular is very broad / I'm not sure how to allow a role to CreateRoles but not to create a role with admin permissions. This might involve IAM permissions boundaries. But all in all that's a separate question & my initial question of "what permissions does whoever I'm currently signed in as have?" has been answered.

已回答 5 个月前
AWS
支持工程师
已审核 5 个月前
0

To debug what permissions your assumed role has, you can use the get-account-authorization-details command from the AWS CLI. This command provides comprehensive information about all IAM users, groups, roles, and policies in your AWS account, which can help you identify your permissions.

Based on your get-caller-identity output, you're operating with an assumed role (arn:aws:sts::123:assumed-role/something/botocore-session-123), not as a regular IAM user. This explains why you can't find your identity in the IAM users section of the console or use list-attached-user-policies.

To check the permissions for your assumed role:

  1. Run the following command to get details about all roles in your account:
aws iam get-account-authorization-details --filter Role
  1. Look for the role named "something" in the output (the middle part of your assumed role ARN).

  2. Within that role's details, examine:

  • AssumeRolePolicyDocument - Shows who can assume this role
  • AttachedManagedPolicies - Lists managed policies attached to the role
  • RolePolicyList - Shows inline policies for the role

The error message indicates you're missing the iam:CreateRole permission. To fix this, you'll need to:

  1. Identify which policy needs to be modified (either an attached managed policy or an inline policy)
  2. Add the iam:CreateRole permission to that policy
  3. Ensure the policy is attached to your role

If you have administrator access through another user or role, you can add this permission by:

  • Creating a new policy with the required permission and attaching it to your role
  • Modifying an existing policy to include the permission
  • Adding an inline policy directly to the role

Remember that for creating IAM roles, you typically need additional permissions like iam:PassRole, iam:CreatePolicy, and iam:AttachRolePolicy to make the role fully functional.
Sources
Use GetAccountAuthorizationDetails with an AWS SDK or CLI - AWS Identity and Access Management
Creating a DAX cluster - Amazon DynamoDB

已回答 5 个月前
专家
已审核 5 个月前
  • This is a pretty good answer - the aws iam get-account-authorization-details --filter Role command actually works. My answer highlights aws iam list-attached-role-policies --role-name something which is more specific / precisely what I asked for as opposed to needing some searching through a larger output.

0

Let's decode the user arn: arn:aws:sts::123:assumed-role/something/botocore-session-123

role name: something
session: botocore-session-123

You can find the IAM role in IAM console depending on your access level. You may or may not be able to modify your IAM permissions. It is dependent on your permissions.

专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。