Any call to iam.CurrentUser() (lazy loaded) will blow up when having assumed a role, throwing api error: An error occurred (ValidationError) when calling the ListAccessKeys operation: Must specify userName when calling with non-User credentials
This is a bit annoying when having the AWS_MFA_ROTATE_IDENTITY_KEYS environment variable set.
awsmfa arn:aws:iam:: 123456789012:role/myRole -d 3600 --rotate-identity-keys
MFA Token Code:
Temporary credentials will expire in 0:59:59.861841.
Traceback (most recent call last):
File "/usr/local/bin/awsmfa", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/awsmfa/__main__.py", line 47, in main
err = rotate(args, credentials)
File "/usr/local/lib/python2.7/site-packages/awsmfa/__main__.py", line 193, in rotate
in iam.CurrentUser().access_keys.all()
File "/usr/local/lib/python2.7/site-packages/awsmfa/__main__.py", line 192, in <genexpr>
current_access_key = next((key for key
File "/usr/local/lib/python2.7/site-packages/boto3/resources/collection.py", line 83, in __iter__
for page in self.pages():
File "/usr/local/lib/python2.7/site-packages/boto3/resources/collection.py", line 166, in pages
for page in pages:
File "/usr/local/lib/python2.7/site-packages/botocore/paginate.py", line 255, in __iter__
response = self._make_request(current_kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/paginate.py", line 332, in _make_request
return self._method(**current_kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 661, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the ListAccessKeys operation: Must specify userName when calling with non-User credentials
Any call to iam.CurrentUser() (lazy loaded) will blow up when having assumed a role, throwing api error: An error occurred (ValidationError) when calling the ListAccessKeys operation: Must specify userName when calling with non-User credentials
This is a bit annoying when having the
AWS_MFA_ROTATE_IDENTITY_KEYSenvironment variable set.