1

I am trying to run this command

$ aws iam  get-user --query 'User.UserName' --output text

and it failed with

An error occurred (ValidationError) when calling the GetUser operation:
Must specify userName when calling with non-User credentials

I thought it might be due to missing profile, so I added a --profile parameter.

$ aws --profile dev iam get-user --query 'User.UserName' --output text

It still fails with the same error.

Since I have enabled MFA, is it possible it is due to a mistyped token from the authenicator? If so, can I reset the token?

Anthony Kong
  • 3,288
  • 11
  • 57
  • 96

1 Answers1

2

I don't see a query parameter for the get-user command in the documentation

It should be possible to query for a user name with the user-name parameter.

aws iam get-user --user-name Bob

The get-current-user command

Retrieves details of the current user for whom the authentication token was generated.

which might be what you are looking for. If you don't specify the profile the aws cli will use the default profile from the credentials file.

Henrik Pingel
  • 9,380
  • 2
  • 28
  • 39