Yafaa
Yafaa

Reputation: 337

I need aws_access_key_id and aws_secret_access_key for Amazon

I'm totally new to AWS. I want to download an s3 bukcet into my EC2 instance but I am geeting this error

   raise NoCredentialsError()
    botocore.exceptions.NoCredentialsError: Unable to locate credentials

in order for that to work I need to specify aws_access_key_id and aws_secret_access_key but I don't know from where I can get them

Upvotes: 0

Views: 2874

Answers (1)

Marcin
Marcin

Reputation: 238111

If you run your code on an EC2 instance, you should setup IAM role for Amazon EC2 with arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess policy. Hardcoding credentials into an EC2 instance is a bad security practice.

Once you setup the role, boto3 on the instance will be able to automatically get the AWS credentials from the role to access the S3.

Upvotes: 1

Related Questions