I am running a Jenkins server on Windows server with AWS CLI installed. while trying to run a script through Jenkins job i get the following error:

"You must specify a region. You can also configure your region by running "aws configure"."

AWS cli is configured (running the script manually - all good)

Script: aws ec2 run-instances --image-id ami-12345 --count 1 --instance-type m4.large --key-name my-key --security-groups defaultSG

(If i add a --region im getting: "Unable to locate credentials")

Thanks !


Try adding --region <your-region-name> to the options.

For example

aws ec2 run-instances --region your-region-name --image-id ami-12345 --count 1 --instance-type m4.large --key-name my-key --security-groups defaultSG 

Find which user you have configured awscli and on which user jenkins is running. If both users are different change that. In windows go to services select jenkins and change the user. In linux check pid on which jenkins is running and search who has that pid in /etc/passwd and check on which user u configured awscli or configure awscli on the user who running jenkins. I have the same issue i solved like this hope it helps.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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