-
- Downloads
Add how-to for accessing AWS S3 bucket from within R - initial committ.
Showing
- howTo/aws-s3.md 29 additions, 0 deletionshowTo/aws-s3.md
- howTo/r-with-aws/access_keys/example_credentials_script.R 8 additions, 0 deletionshowTo/r-with-aws/access_keys/example_credentials_script.R
- howTo/r-with-aws/bucket-policy 33 additions, 0 deletionshowTo/r-with-aws/bucket-policy
- howTo/r-with-aws/rconnector-access-policy 118 additions, 0 deletionshowTo/r-with-aws/rconnector-access-policy
- howTo/r-with-aws/using_aws-s3_example.R 48 additions, 0 deletionshowTo/r-with-aws/using_aws-s3_example.R
howTo/aws-s3.md
0 → 100644
# Guide to accessing data from Amazon Web Services (AWS) S3 buckets using R | ||
This guide provides details of how to set up and access files/data stored within an AWS S3 bucket directly from an R session using the [aws.s3 package](https://github.com/cloudyr/aws.s3). | ||
Prerequisite: access to the AWS account where the S3 bucket is located in order to create a user access policy. | ||
## Creating a user access policy (in the AWS console) | ||
Following guidance here: https://www.gormanalysis.com/blog/connecting-to-aws-s3-with-r/ | ||
Create user 'rconnector' ... and create user policy 'test-bucket-connector' (see [example access policy](howTo/r-with-aws/rconnector-access-policy). | ||
Make sure to save access key ID and secret access key to use with S3 API client. | ||
Use these details to set the following environment variable (see below for code) and store the credentials in an R script e.g. in your project folder (in this example in a subfolder called [access keys](howTo/r-with-aws/access_keys). Note, for security exclude this file from the project repository by adding to your .gitignore file). The R script will look something like the following ... | ||
|
||
``` | ||
Sys.setenv( | ||
"AWS_ACCESS_KEY_ID" = "mykey", | ||
"AWS_SECRET_ACCESS_KEY" = "mysecretkey", | ||
"AWS_DEFAULT_REGION" = "eu-west-2" | ||
) | ||
``` | ||
An example script can be found [here](howTo/r-with-aws/access_keys/example_credentials_script.R). | ||
## Connecting to the S3 bucket with R | ||
You're ready to go! See [example code](howTo/r-with-aws/using_aws-s3_example.R) showing some commands to authenticate R with AWS and read and write files from/to AWS S3 buckets. |
howTo/r-with-aws/bucket-policy
0 → 100644
howTo/r-with-aws/rconnector-access-policy
0 → 100644
howTo/r-with-aws/using_aws-s3_example.R
0 → 100644