25

Just configured the AWS CLI on my computer with my AWS Access and Secret Key. When I try to use the AWS CLI though it gives me this error.

Partial credentials found in env, missing: AWS_SECRET_ACCESS_KEY

I went to ~/.aws/config, and sure enough those credentials are there, including the AWS Secret Key, so I'm not sure why its squawking at me.

TJB
  • 3,706
  • 9
  • 51
  • 102
  • 3
    Is AWS_SECRET_ACCESS_KEY set in your environment? It sounds like AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) is set in the environment but not AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY). Depending on your programming environment and the `AWSCredentialsProvider` you're using it may be ignoring your `~/.aws/credentials` file. – stdunbar Feb 13 '18 at 18:52
  • Along with ensuring the file was in place, i had to manually export those variables into environment – HelpMatters May 07 '20 at 13:31
  • Agree with @stdunbar, the file was ignored if the environment variables are set and environment variables containing some other values. – Vikash Yadav Dec 07 '20 at 13:58

5 Answers5

21

You should have this file ~/.aws/credentials and the contents should be in the following format:

[default]
aws_access_key_id = XXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Carlos Rodriguez
  • 611
  • 5
  • 11
  • 3
    Hmmm I checked the credentials file and both keys are there. I even performed a export AWS_PROFILE=default, and that didn't work either. – TJB Feb 13 '18 at 20:07
  • nvm figured it out, Thanks Carlos ! – TJB Feb 13 '18 at 20:19
  • Along with this, you need to also make sure all these variables are populated in your environment variables. Without that, even if my file format was correct it didn't work for me. After I set environment variables it started working. – HelpMatters May 07 '20 at 13:31
  • I have this file, and it's been exported, but still when running `aws ecr get-login` i am getting the OP `Partial credentials found in env, missing: AWS_SECRET_ACCESS_KEY` error. There is a forward slash in the secret id, i am wondering if it id down to that? – Jeremy Apr 06 '21 at 12:52
14

For anyone who is having the same problem - this is solution that worked for me:

If you are on Windows - check if you don't have AWS_ACCESS_KEY_ID set in your system variables. AWS CLI uses something called configuration provider chain - and environment variables take precedence over configuration file. In my case somehow I had only set AWS_ACCESS_KEY_ID thus the error message.

saku
  • 3,476
  • 2
  • 19
  • 12
0

If you are using MacOS, this may be caused because you set other credentials in the environmental variables.

Setting the new credentials to the environmental variables might solve your problem.

To do so run this in the terminal:

export AWS_ACCESS_KEY_ID=X
export AWS_SECRET_ACCESS_KEY=Y
export AWS_DEFAULT_REGION=REGION

Substitute X, Y, and REGION with the values corresponding to your application.

Source documentation: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html

0

I ran with this problem and I did rerun the same workflow yml again and again but changes were never actually occurs. Finally, I had to remove existing workflow from GitHub and re-initiate/pushed yml configuration file again. Worked for me. Thank You!

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 25 '22 at 12:00
0

That happened to me because I only had export the variables AWS_ACCESS_KEY_ID and AWS_DEFAULT_REGION, but forgot to export the AWS_SECRET_ACCESS_KEY.

All in one command:

export AWS_ACCESS_KEY_ID=<XXXXXXXXXXX> && \
export AWS_SECRET_ACCESS_KEY=<XXXXXXXXXXX> && \
export AWS_DEFAULT_REGION=<XXXXXX>
Daniel Marques
  • 1,249
  • 8
  • 17