0
votes

Disclaimer: I do have variable AWS_PROFILE set to default and echo $AWS_PROFILE does return default.

However though, my simple aws commands are failing if I do not pass --profile flag with it.

For example,

if I do aws2 s3 ls, then it fails with error : An error occurred (InvalidToken) when calling the ListBuckets operation: The provided token is malformed or otherwise invalid.

when I do, aws2 ec2 describe-instances, it fails with error An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials

even though message is different, the underlying problem is same. If I do aws2 s3 ls --profile default then it works fine, same with aws2 ec2 describe-instances command.

I have no idea how to not need the --profile flag even though I do have AWS_PROFILE set.

my credentials file look like following:

[default]
aws_access_key_id = AKIA****
aws_secret_access_key = VpR***

My config file looks like following:

[default]
region = us-west-1
output = json

I have set following two enviroment variables:

AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Also, Ihave echoed their values back and made sure that the values are same exact as in credentials file.

any ideas?

2

2 Answers

1
votes
  • Use unset AWS_PROFILE to remove profile plag.

  • Run aws configure to update the credential

  • Make sure your machine time is correct.

0
votes

The profile referenced by AWS_PROFILE is invalid or expired. Your default profile is valid. That is why you see the error behavior. Check all credentials via cat ~/.aws/configure and remove or correct any that are invalid.