Cli "Unable to locate credentials" on EC2 instance

0

I'm trying to use the AWS CLI tool on an EC2 instance running Amazon Linux.

I configured it by using the "aws configure" command to set up an access key and secret key. When I run it directly from the linux prompt, it works fine.

However, I need to run it as part of a script that is executed nightly with cron. I put a link to my script in cron.daily. The script runs, but when it reaches the aws command, it fails with the error "Unable to locate credentials".

I suspect that cron must be running the script under some user other than the default ec2-user, but I can't figure out which user, or how to configure the credentials for that user.

I tried typing "sudo su" and then re-issuing the commands to set the credentials, but that did not fix the problem.

Thanks, Frank

Frank
질문됨 2년 전475회 조회
1개 답변
1

I suspect you're on the right path - the credentials are set up for a particular user and the cron job is executing as another user; or in some way cannot locate the file where the credentials are stored.

My recommendation is not to use static credentials. Instead, create a role for the instance - that way you don't have to worry about rotating credentials or even storing them on the instance.

profile pictureAWS
전문가
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠