Why am I getting 'Unable to locate credentials' in AWS CLI even with a credentials file?
Asked by
CuriousCoder42
I'm running into a frustrating issue using the AWS CLI: it keeps telling me 'Unable to locate credentials' even though I've placed my credentials file in the current directory. By default, the AWS CLI looks for the credentials file in ~/.aws/credentials, but that's not working for me. I've also tried setting the environment variable AWS_SHARED_CREDENTIALS_FILE to point to that path and even to "${pwd}/credentials" but nothing seems to work. I attempted to use the command `aws sts assume-role --role-arn $AWS_ARN --role-session-name temp-app-session --duration-seconds 3600 > ~/temp-creds.json' but I still get the same error asking me to run 'aws login' for configuration. Any advice on what I might be missing?
Answers
Have you tried using `aws configure` to set up your credentials instead? It's worth a shot to see if that resolves your issue.
Reply to this answer
Check your ~/.aws/config file to make sure the profile youโre using is correctly set up. Also, ensure that your AWS SSO user and permissions are still valid.
Reply to this answer
Honestly, it's probably a skill issue! Just kidding, but donโt forget, getting informative error messages can be hit or miss with the AWS CLI. Hang in there!
Reply to this answer
That error often doesn't mean the file is missing; it usually indicates there's an issue with the credentials youโre using. Could you outline all the steps you're taking to set things up? It might help clarify the root of the issue.
Reply to this answer
I suggest running the command `aws sso login` followed by `aws sts get-caller-identity` to check if your identity has permission to assume the target role. The role you're trying to access needs to allow your identity in its trust policy.
Reply to this answer
Have you checked the file permissions on your credentials file? Sometimes that can lead to issues with AWS being able to read it properly.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions