I am trying to retrieve session token on the AWS CLI like so:
aws sts get-session-token --serial-number arn-string --token-code mfacode
where
arn-stringis copied from the IAM management console, security credentials for the assigned MFA device,format likearn:aws:iam:<number>:mfa/<name>mfacodeis taken from the registered virtual mfa device
error:
An error occurred (InvalidClientTokenId) when calling the GetSessionToken operation: The security token included in the request is invalid.
However, I use that MFA device to login to the console in the browser just fine
I have only a default profile in my ~/.aws/, but I don't see how this would have any influence.
tried this:
- try multiple time to ensure no mfa flip-over has happened
- delete MFA device assignment and reassign device -- same error
- ommitting
--token-codein hope to have it prompt me for the MFA device token -- same error - using the
arn:aws:iam:<number>:user/<name>-- same error as can be expected since theaws get-session-id helpclearly states it needs to be the arn of the mfa device
I figure this has to do with arn-string rather than the token, but what ? Any idea on what causes this problem most welcome.
Regards, Olaf