amazon-web-servicesaws-cli

AWS CLI is returning random hex string rather than output


All of the stdout on my AWS CLI commands is being replaced by a random hex string rather than the output I expect.

ie, I run:

aws ec2 list-images-in-recycle-bin --region us-west2 --output json

& get output:

`b31234fc8...'

& I run:

aws sts get-caller-identity --output text

And I get the same output. If I run some garbage like aws fodjf I get an expected help error message.


Solution

  • I followed a tip & added the --debug option to one of the commands. This gave me a much more helpful error message with

    2024-08-13 20:31:10,954 - MainThread - botocore.credentials - WARNING - Refreshing temporary credentials failed during mandatory refresh period.
    Traceback (most recent call last):
      File "awscli/botocore/utils.py", line 3231, in __getitem__
      File "json/__init__.py", line 293, in load
      File "json/__init__.py", line 346, in loads
      File "json/decoder.py", line 337, in decode
      File "json/decoder.py", line 355, in raw_decode
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "awscli/botocore/credentials.py", line 492, in _protected_refresh
      File "awscli/botocore/credentials.py", line 633, in fetch_credentials
      File "awscli/botocore/credentials.py", line 641, in _get_cached_credentials
      File "awscli/botocore/credentials.py", line 659, in _load_from_cache
      File "awscli/botocore/utils.py", line 3233, in __getitem__
    KeyError: 'b31234fc8...' (my hex string)
    

    This looked fairly log in related so I ran rm -rf ~/.aws/cli/cache & then logged in again. Now things are working.