2

I am working on setting up something with S3 and Chef, I have AWS CLI installed and working but I need to figure out how to specify the access ID and the secret access key. I know there are cookbooks out there for this but I have tried a few with no luck so I am not using anyone else's cookbooks for this project anymore.

Suggestions on how I can run aws configure and then output the correct value for each of the 4 things it asks?

Code in my script to set env variables:

export AWS_ACCESS_KEY_ID=<key>

export AWS_SECRET_ACCESS_KEY=<secret_key>

export AWS_DEFAULT_REGION=<region>
1

Have you tried setting the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables? By setting these variables before you run your cli commands, you should not have to run the aws configure command.

Environment Variables

Environment variables override configuration and credential files and can be useful for scripting or temporarily setting a named profile as the default. The AWS CLI supports the following environment variables.

AWS_ACCESS_KEY_ID – AWS access key.

AWS_SECRET_ACCESS_KEY – AWS secret key. Access and secret key variables override credentials stored in credential and config files.

AWS_SESSION_TOKEN – Specify a session token if you are using temporary security credentials.

AWS_DEFAULT_REGION – AWS region. This variable overrides the default region of the in-use profile, if set.

....

  • Yes those are the settings I wanted to change, I was not aware they were env variables, thanks – Josh Kirby Aug 14 '18 at 15:09
  • I have the values for everything except AWS_SESSION_TOKEN am I fine to go without it? I can't seem to find anything about this in the credentials I was provided. – Josh Kirby Aug 14 '18 at 19:21
  • I'm assuming you don't have multifactor authentication enabled? You should be good then. – PrestonM Aug 14 '18 at 19:33
  • No 2FA enabled correct, it seems I am not so fine doing export AWS_ACCESS_KEY_ID="value" doesn't seem to be working and setting it correctly in my script. – Josh Kirby Aug 15 '18 at 12:44
  • I tried it without the " and the export as well with no luck – Josh Kirby Aug 15 '18 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.