serverless-babel-plugin icon indicating copy to clipboard operation
serverless-babel-plugin copied to clipboard

Not working when a function handler is in a subdirectory

Open plbrault opened this issue 8 years ago • 17 comments

I have a Lambda function which the handler is in a subdirectory, e.g.:

functions:
  myFunction:
    handler: myFunction/handler.myFunction

When I deploy with the plugin enabled, the handler is not included in the generated archive, thus my deployed function does not work.

I am using this plugin with Serverless 1.2.0.

plbrault avatar Nov 22 '16 18:11 plbrault

@plbrault thx for reporting. That's indeed a bug. I hope I get to fix it tomorrow or Monday.

nikgraf avatar Nov 24 '16 09:11 nikgraf

Curious if there has been any progress towards this bug. This package would be amazing for my use case if you can use handlers within subdirectories.

Thanks for your work!

evfleet avatar Dec 10 '16 01:12 evfleet

Has there been any progress on this?

plbrault avatar Jan 26 '17 16:01 plbrault

I'm not working actively on it. Would you be interested taking ownership in this project?

nikgraf avatar Apr 10 '17 18:04 nikgraf

@nikgraf Do you know where i could start looking to fix this bug.

peisenhower avatar Aug 09 '17 23:08 peisenhower

@nikgraf @peisenhower any progress on this?

samwiseduzer avatar Jan 17 '18 18:01 samwiseduzer

Any workarounds for this for the moment?

mattishaden avatar Feb 12 '18 13:02 mattishaden

Still doesn't work in 2018.

brandon-arnold avatar May 07 '18 19:05 brandon-arnold

I have this issue. My functions are written in typescript and compiled to a folder called 'out'. They are then packaged up as so:

functions:
  myfunction:
    handler: out/myfunction.handler
    package:
      include:
        - out/myfunction.js

After running serverless package I can see the generated zip file contains the correct folder and file. After running serverless deploy, the lambda function created in AWS is empty.

I should also say, this has nothing to do with the babel plugin as I'm not using that.

johneast avatar May 23 '18 04:05 johneast

I was running into a similar problem, what helped me get around it was building my own .zip artifact with everything in the root and specifying that in the serverless.yml using the package.artifact key.

@johneast your serverless.yml looks odd, btw; package is a top-level directive, not a sub node of functions.<funcname>:

functions:
  myfunction:
    handler: out/myfunction.handler
package:
  include:
    - out/myfunction.js

Anyway, package.include didn't work for me (it would include the entire dir), so I ended up going with package.artifact, instead.

hraban avatar Jun 05 '18 15:06 hraban

Multi function independently packaged approach does not seem to work at all.

Handler function not present; unzip_requirement.py hidden in a complex directory structure; other irrelevant directories included in the zip.

Generally not up to it for a real use case. Shame

Chanonry avatar Jun 07 '18 09:06 Chanonry

Would also be interested in seeing this exist

mxkrn avatar Jul 18 '18 14:07 mxkrn

Yes !

On 18 Jul 2018, at 15:59, Max Kraan [email protected] wrote:

Would also be interested in seeing this exist

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/serverless/serverless-babel-plugin/issues/3#issuecomment-405961895, or mute the thread https://github.com/notifications/unsubscribe-auth/AT6OHRH35gUj2YZcICNbUmzfypCj67h6ks5uH002gaJpZM4K5zPd.

Chanonry avatar Jul 22 '18 18:07 Chanonry

This is interesting feature. I think this is might be useful for me who use Typescript, cases like @johneast. Yes, serverless-plugin-typescript is exist for Typescript project but that would be great if this alternative method to refer subfolder handler exist.

jundialwan avatar Nov 19 '18 05:11 jundialwan

I'm still facing the same issue. It seams that it is considered a very low priority bug

mtsz-thiago avatar Dec 21 '19 06:12 mtsz-thiago

I've been able to resolve this problem by placing a './' in front of the directory name.

Example Project Structure:

  • Project_Dir
    • lambda_functions
      • sample_lambda
        • app.py
    • template.yaml

Example Yaml:

Resources:

    SampleLambda:
        Type: AWS::Serverless::Function
        Properties:
            CodeUri: ./lambda_functions/sample_lambda/
            Handler: app.lambda_handler
            Runtime: python3.8

jdk514 avatar Jul 29 '20 21:07 jdk514

@plbrault thx for reporting. That's indeed a bug. I hope I get to fix it tomorrow or Monday.

I'm not working actively on it. Would you be interested taking ownership in this project?

paint me a clown

ronnathaniel avatar Aug 09 '21 19:08 ronnathaniel