AWS CLI: Error parsing AWS config file

AWS parse config file .aws/config

1 min read | by Jordi Prats

One mistake on the .aws/config can lead to a very confusing error message:

$ aws sts get-caller-identity
(...)
botocore.exceptions.ConfigParseError: Unable to parse config file: /home/pet2cattle/.aws/config

What it is trying (and failing) to tell us, is that there's something wrong with that file. Beside obvious syntax errors, we'll get this error when there's something repeated, for example we have added a profile twice:

$ grep '\[profile' ~/.aws/config | sort | uniq -c
   1 #[profile oldprod]
   1 [profile dev-infra]
   1 [profile preprod]
   1 [profile prodblue]
   1 [profile prodgreen]
   1 [profile tst1]
   1 [profile dev-k8s]
   2 [profile tst2]
   1 [profile tst3]

Or, in a profile, we have repeated keys:

[profile test]
region=us-west-2
aws_access_key_id=ABBBBAAAABBBBBBA
aws_secret_access_key=0000111111100000111/UUUUAA
region=us-west-2

Posted on 01/12/2022

Categories