lambdr icon indicating copy to clipboard operation
lambdr copied to clipboard

Serverless integration

Open fmmattioni opened this issue 3 years ago • 7 comments

Hi @mdneuzerling!

Thanks a lot for the amazing tool you put together! I just started today playing around with it – it is great.

I usually use AWS lambda for deploying JS functions, and serverless is simply great for deployment. One of the great advantages is to define function-level memory allocation, timeout, etc, in a yml file.

I have just successfully deployed a function using {lambdr} and serverless as a test to see how it works. It turns out it seems to work great. Would you be interested in adding a function to simplify this integration? I can happily make a PR, let me know.

Best, Felipe

fmmattioni avatar Nov 08 '21 20:11 fmmattioni

Hi @fmmattioni. I'm glad you got it working so quickly! That's a good sign.

It might just be because it's early in the morning here and I'm a little slow before my coffee, but could you please help me understand what you want to raise a PR for? Would I need to include a serverless integration in lambdr, or would lambdr need to be integrated into serverless?

Either is fine with me. And the projects are both MIT-licenced so there shouldn't be any issues there.

mdneuzerling avatar Nov 08 '21 20:11 mdneuzerling

hey @mdneuzerling,

It would be simply a function to automate the creation of the yml file with a few instructions on how to install serverless and set up an AWS profile to deploy it (or use root). I was thinking something like lambdr::deploy_serverless(), which would then create the yml skeleton and that is basically it.

fmmattioni avatar Nov 08 '21 20:11 fmmattioni

@fmmattioni would you mind sharing your serverless config? im working on this now and have a hit a few snags (very new to R)

any files and folder structure would be super helpful

dwbelliston avatar May 29 '22 02:05 dwbelliston

@dwbelliston sure! Please, see below a minimal example. I unfortunately still did not have the time to create a PR for @mdneuzerling, but this should get you started.

This uses API Gateway, by the way.

serverless.yml:

service: my-lambda-function

frameworkVersion: '3'

provider:
  name: aws
  lambdaHashingVersion: 20201221
  ecr:
    images:
      appimage:
        uri: [insert url of your docker image deployed in ECR here]
  stage: dev
  region: us-east-2
  profile: my-aws-profile
  httpApi:
    cors: true
  apiGateway:
    binaryMediaTypes:
      - '*/*'
functions:
  handler:
    timeout: 25
    memorySize: 1024
    image:
      name: appimage
      command:
        - handler
    events:
      - httpApi:
          path: /handler
          method: get

fmmattioni avatar Jun 23 '22 09:06 fmmattioni

Guys, you need any help writing a PR? My team uses serverless to deploy code written in python, but we'd definitely prefer to use R.

pedrocava avatar Jul 14 '22 06:07 pedrocava

Hi @pedrocava! Yes, feel free to start the PR 😄

fmmattioni avatar Jul 28 '22 08:07 fmmattioni

I think we should first have a specification for what should be implemented. A very minimal approach would be to generate the provider.ecr component and then let users do as they please with the resulting file. @mdneuzerling, @fmmattioni?

pedrocava avatar Jul 28 '22 14:07 pedrocava