Skip to content

Instantly share code, notes, and snippets.

@gm3dmo
Last active November 28, 2017 06:11
Show Gist options
  • Save gm3dmo/418320c79f48005c740e7ae148a3883c to your computer and use it in GitHub Desktop.
Save gm3dmo/418320c79f48005c740e7ae148a3883c to your computer and use it in GitHub Desktop.
R Studio Amazon S3

R Studio

Problems

Fetching file in R from AWS S3 fails with: Error in parse_aws_s3_response

Get a csv file from s3:

aws.signature::use_credentials(profile = "rstudio")
library("aws.s3")
bucketlist()

wanted_bucket = "testbucket"
wanted_file = "/test.csv"

bkt <- get_bucket(wanted_bucket)
print(bkt)

obj <- get_object(wanted_file, wanted_bucket, check_region = F)
c <- rawToChar(obj)
print(c)

In the the ~/.aws/credentials file:

[rstudio]
aws_secret_access_key = ***
aws_access_key_id = ***
aws_default_region = eu-west-2

If we didn't put check_region = F

everything went danish and failed with:

Error in parse_aws_s3_response(r, Sig, verbose = verbose) : 
  Forbidden (HTTP 403)

This was very confusing because the lines:

bkt <- get_bucket(wanted_bucket)
print(bkt)

worked properly and listed the contents of the bucket and the aws s3 cp command worked outside of R studio.

See this issue from cloudyr cloudyr/aws.s3#175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment