Im trying to copy files from my s3-bucket to my ec2-instance.
When i run this command inside my ec2-instance: aws s3 cp s3://amazing-demobucket-1/file.txt ./file.txt
i get following error: Unable to locate credentials
But the aws configure files is in my ~/.aws
in my local machine. Do i need to configure inside ec2-instance too? Or is there another command i can run outside my ec2-instance to download files from s3-bucket into ec2-instance ?
Thank for help!
Your AWS credentials on your local machine can't be seen by the awscli
program on your EC2 instance. If you want to run the S3 copy command on the EC2 instance, you have two options:
1) Run aws configure
on the EC2 instance and define the credentials on that machine (not recommended)
or
2) Create an IAM role with the required permissions to copy the files (for example, with the AmazonS3ReadOnlyAccess policy) and attach the role to your EC2 instance
It might be issue with order of precedence. AWS check Keys first in environment variables and then ~/.aws path
Try running below command to check where its looking for keys
aws configure list
You can find more details about precedence on below link
https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html#config-settings-and-precedence
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With