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 imprecise error message:

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

It is telling us that there's something wrong with that file but we have no other clue. 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 we are defining some variable twice within a profile:

[profile test]

Posted on 01/12/2022