amazon-web-servicesaws-cliaws-sts

InvalidClientTokenId error aws when trying to get caller identity


hi I am unable to run this command aws sts get-caller-identity.

when I do sudo nano ~/.aws/credentials I can only locate this

[default]
aws_access_key_id = my_id
aws_secret_access_key = my_secret_id

and after doing successful steps of command aws configure when I am doing aws sts get-caller-identity I am getting this error

An error occurred (InvalidClientTokenId) when calling the GetCallerIdentity operation: The security token included in the request is invalid.

any reason which could cause this ?


Solution

  • Sometimes this kind of issues are caused by another credential configuration.

    Environment variables credential configuration takes prority over credentials config file. So in case there are present the environment variables "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY" or "AWS_SESSION_TOKEN" these could generate issues if it were missconfigured or have been expired.

    Try checking the env vars associated to AWS Credentials and removing them using the 'unset' command in linux.

    Additionally, to remove env vars permanently you need to remove the lines related on configuration files like:


    Reference:

    Configuration settings and precedence