Search code examples
ramazon-web-servicesamazon-ec2rstudio-server

Rstudio not able to find AWS credentials


I am trying to run s3 commands for a private bucket via Rstudio hosted on an EC2 server. I have ssh'ed into the EC2, downloaded AWS Client and stored the keys, however when I launch RStudio, running

aws configure

returns

The program 'aws' is currently not installed. To run 'aws' please ask your administrator to install the package 'awscli'

Therefore, I installed aws client and configured my keys. So when I now run the R command,

aws.signature::locate_credentials()

which attempts to locate my aws credentials, I get an empty set of keys:

$key
NULL

$secret
NULL

$session_token
NULL

$region
[1] "eu-west-2"

Does anyone know what is going wrong or why Rstudio cannot find the AWS credentials stored in the EC2?

Thanks!


Solution

  • What file extension do your credential files have? Some modules (like python/boto3) read credential files with .ini extensions by default, while others (R/aws.signature) reads files with no extension by default. So, for example:

    .aws/credentials.ini -> .aws/credentials

    .aws/config.ini -> .aws/config

    Or, you can specify the files directly in your aws.signature::locate_credentials() call:

    locate_credentials(file = PATH_TO_CREDENTIALS_FILE))