Skip to content

Doesn't support new Docker image syntax #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
smcelhinney opened this issue Jan 22, 2021 · 9 comments
Open

Doesn't support new Docker image syntax #227

smcelhinney opened this issue Jan 22, 2021 · 9 comments

Comments

@smcelhinney
Copy link

smcelhinney commented Jan 22, 2021

As per https://www.serverless.com/blog/container-support-for-lambda, you can now use the image property in function instead of a handler.

Error

  Type Error ---------------------------------------------
 
  TypeError: Cannot read property 'split' of undefined

is thrown at https://github.com/prisma-labs/serverless-plugin-typescript/blob/master/src/typescript.ts#L51 because it expects a handler property to be defined.

Required if you have (like I do) a mix of typescript handlers and Docker images in the same application.

@smcelhinney
Copy link
Author

If you've found this issue from a search engine, a (less-than-ideal) solution I've used for deployment is to create a separate serverless.docker.yml file with your Docker based deployments, and run serverless deploy -c serverless.docker.yml

@alanwilter
Copy link

Sorry, I found this issue by search... and I was doing, presumably, exactly what you said, yet, this not working for me:

Test based on example (which is awfully outdated).

Dockerfile:

FROM public.ecr.aws/lambda/nodejs:14
COPY handler.ts ./
CMD ["handler.hello"]

serverlessD.yml:

service: serverless-example
frameworkVersion: "2 || 3"
plugins:
  - serverless-plugin-typescript

provider:
  name: aws
  # runtime: nodejs14.x
  ecr:
    images:
      appimage:
        path: ./
  region: eu-west-2
  lambdaHashingVersion: 20201221

functions:
  hello:
    # handler: handler.hello
    image:
      name: appimage
    events:
      - http:
          path: hello
          method: get

Then:

$ sls deploy -s test -c serverlessD.yml

Serverless: Compiling with Typescript...
 
 Type Error ----------------------------------------------
 
  TypeError: Cannot read property 'split' of undefined
...

What am I doing wrong please?

@jamesjoung
Copy link

still happening anyone have work around?
It does look like the plugin is looking for handler property, but for instance with function that is mapped to docker image does not have this property.
Adding handler property with image gets error on serverless deploy.

@Rhysjc
Copy link

Rhysjc commented Mar 24, 2023

Add a specific runtime for your function that use the image. If you set it to python3.9 for example, the typescript plugin won't run against it. You may be able to set this to an empty string, but my container does actually use python 3.9

@nathanbbarton
Copy link

Any luck resolving this issue running into it myself now, switching from a handler to image.

@allavytalize
Copy link

Has any progress been made on this?
This bug makes it impossible to use ECR images with typescript lambdas in serverless.

@demi-encentral
Copy link

Trying in 2024 and the error seems to still be present

@douglasgsouza
Copy link

douglasgsouza commented Feb 2, 2024

I have the same error here when defining a function that uses image instead of handler.

@demi-encentral
Copy link

@douglasgsouza I was able to deploy my app by removing the plugin from my project and building it with tsc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants