aws-lambda-r icon indicating copy to clipboard operation
aws-lambda-r copied to clipboard

Call resources from within the R script?

Open brorio opened this issue 6 years ago • 2 comments

I assume that the R script in the Lambda has access to the AWS OS it's running on so theoretically it could use for example Clodyr's R library aws.s3 and fetch files from s3.

# get file as raw vector
get_object("mtcars.Rdata", bucket = "my_bucket")

Then you don't have to pass it thru Python and also you avoid rewriting your existing R code base. Or am I missing something? Is this not possible?

brorio avatar Nov 07 '18 19:11 brorio

  • We need Python to call R from within the AWS lambda container (since AWS lambda calls a Python function).
  • EC2 machines already have AWS CLI installed so it is easy to use (and up to date)
  • On the local machine, one could use the cloudyr packages. However, they did not (and still do not) provide all the functionality needed to set up all the AWS services (not only S3)
  • The AWS CLI tools are maintained by AWS and tested extensively

Thus, I made the decision not to make the R code dependent on any cloudyr packages (although I use them heavily in other projects). This has the additional advantage that keeps the number of libraries loaded by R at a minimum, leaving more space in the deployment package (zip ) for R packages and files provided by the user.

MikeBadescu avatar Nov 07 '18 20:11 MikeBadescu

Yes, you have a point there with the size of the deployment package.

brorio avatar Nov 07 '18 20:11 brorio