mdneuzerling / lambdr

Run R containers on AWS Lambda
https://lambdr.mdneuzerling.com
Other
131 stars 12 forks source link

S3 #20

Closed YouNeedJ closed 1 year ago

YouNeedJ commented 2 years ago

hello, I am Johann Falla from Colombia and I am using the tutorial "https://mdneuzerling.com/post/r-on-aws-lambda-with-containers/", I generate a .RDATA file that has some functions and when I implement the lambda to make the call to the s3 generates me error "{ "error_message": "Error in parse_aws_s3_response(r, Sig, verbose = verbose) "error_message: "Error in parse_aws_s3_response(r, Sig, verbose = verbose): Bad Request (HTTP 400).\n" }" I already gave the lambda permission to use s3, also inside the function in sagemaker I put Sys.setenv("AWS_ACCESS_KEY_ID"="xxxxxxxx", "AWS_SECRET_ACCESS_KEY"="xxxxxxx", "AWS_DEFAULT_REGION"="us-east-1") what could I be missing, Thank you

Translated with www.DeepL.com/Translator (free version)

phoward38 commented 2 years ago

I'm also not able to access my S3 bucket from within lambda after setting the ENV variables & including a credentials file

YouNeedJ commented 2 years ago

I solved it, the credentials are ok when we are in console, but they must be removed to use the function from the lambda, and the lambda must be given s3 permission.

phoward38 commented 2 years ago

@YouNeedJ Do you mind explaining how you authenticate to s3? I've given lambda s3 permissions, but I'm not sure what you mean by:

they must be removed to use the function from the lambda

Would really appreciate it!

YouNeedJ commented 2 years ago

this is the function with the authentication parameters:

            Sys.setenv("AWS_ACCESS_KEY_ID"="xxxxxxxx",
            "AWS_SECRET_ACCESS_KEY"="xxxxxxx",
            "AWS_DEFAULT_REGION"="us-east-1")

             s3load(object = "xxxxxxxxxxxxxxxxx", bucket = "xxxxxxxx")

This is how it works in the Jupyter Notebook, but in order to upload the function already in the lambda you must remove the authentication parameters, so that the role of the lambda and the authentication of the code do not conflict, so that the final code remains:

              s3load(object = "xxxxxxxxxxxxxxxxx", bucket = "xxxxxxxx")
YouNeedJ commented 2 years ago

What error do you get when trying to log in?

phoward38 commented 2 years ago

@YouNeedJ That was the issue! Thanks so much