Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nothing you mentioned has anything to do with the ability to test a Lambda. You’re trying to use limitations and restrictions as friction to backup your inability to test.

There’s a lot of annoying things about lambda. And a lot of stuff I wish was easier to find in documentation. But that doesn’t change the fact that Lambda is more or less passing an event object to your function and executing it.

Writing a function in node 12 and then running it on node 4 and throwing your hands in the air cos it didn’t work isn’t the fault of Lambda.



It's great to see that factual evidence is answered with ad-hominem by the Lambda hype crowd.

In any case, if you have a Node.js module or code with a native C/C++ build, that runs shell commands, that writes to disk (not allowed besides /tmp in Lambda) or makes assumptions about the OS, your "simple" function will absolutely return different results.

e.g: My lambda is called when somebody uploads an image and returns a resized and compressed version of it. This is done using Node.js and the mozjpeg module which is dependent on cjpeg which is built natively on install.

If I test my function on my machine and in Lambda it's very possible that I get different results.

Also, certain OSs like Alpine which are heavily used for Docker don't event use glibc as compiler, so again, another difference.


"In any case, if you have a Node.js module or code with a native C/C++ build, that runs shell commands, that writes to disk (not allowed besides /tmp in Lambda) or makes assumptions about the OS, your "simple" function will absolutely return different results."

This is true, but it's not Lambda qua Lambda. That's just normal production vs. testing environment issues, with the same basic solutions.

Lambda may offer some minor additional hindrances vs. something like Docker, but I wouldn't consider that catastrophic.


I think you are right with your assumption that Docker images that don't resemble the production environment aren't sufficient to test.

But isn't the idea of Docker that you can recreate the production environment? If you can't why use Docker in the first place?


You are absolutely right that you could recreate a similar environment to Lambda in Docker. But you would first need to reverse engineer Lambda's environment to discover how it is actually configured and the limits that are set.

Even if you did find a way, you would still need to keep it up to date in case AWS decides to update that environment.


Logged in to say that this has actually been done (not by me) and my team has been finding it very helpful for local “serverless” SDLC: https://github.com/lambci/docker-lambda . It‘s billed as “ A sandboxed local environment that replicates the live AWS Lambda environment almost identically – including installed software and libraries, file structure and permissions, environment variables, context objects and behaviors – even the user and running process are the same.” We test our functions mocked and against local deployments of that lambci container . There also lambda “layers” (container images for building custom runtimes for AWS Lambda) but we have not used that feature at this point. Interesting space with lots of room for improvement in this tool chain though for sure


Nice!

I saw that the SAM CLI uses an Alpine based image, does yours use Amazon Linux 2?

I'm jusz asking, because I compiled some libs on Cloud9 (which uses AL) and they worked on Lambda, so I assumed it's the same dist.


I’m not 100% sure as I didn’t create the image (though I’m evangelizing as someone who has found it truly helpful for daily dev.) . I believe the creators tarball’d the entire distro/execution environment from a running lambda so the file system layout and libs likely match Amazon Linux if that’s the default lambda execution distro image. If not I assume it matches the default


At least the Docker image used by AWS SAM CLI is created by AWS.

Also, you compile before packaging, so you dev/CI system already has to be able to compile for Lambda, independenly from testing/debugging with Docker.


> > Writing a function in node 12 and then running it on node 4 and throwing your hands in the air cos it didn’t work isn’t the fault of Lambda.

> It's great to see that factual evidence is answered with ad-hominem by the Lambda hype crowd.

I don't think that was a personal attack.

We've answered technical questions with technical answers.

- You have a definition of stateless which includes having no persistence layer, which is at best at odds with the industry.

- You think serverless was created with AWS Lambda which we've been kind about, but most people would say you're simply wrong.

- You're advocating for containers, which are well known for having their own hype as people write their own cloud providers on top of the cloud provider their employer pays for with dubious benefit.


The place where I work, we have "cloud in a cloud" initiative, total waste of time But you can't blame containers for it


Saying that local dev and Lambda are different is a strawman. How is that harder than developing on a Mac or Windows (or even Linux) and then testing on a different OS and config via CI/CD?

You shouldn't be testing "on your machine" - that's the oldest excuse in the book!

You should build your function in a container based on AWS Linux, just the same as you should for a Lambda deploy. That guarantees you the same versions of software, packages, libraries, etc. It makes it possible for me to develop Lambda functions on a Mac and test binary-for-binary to the deployed version.

"Nothing you mentioned has anything to do with the ability to test a Lambda" is not ad-hominem, it's a statement of fact.


Why not then have lambda run the same container you can run and test locally?

I don't use lambda but we have our jenkins spin up the same ec2 to run tests that we would spin up to do development so that we never run into this problem.


I'm not sure I understood your question correctly.

If you mean running a Docker container in Lambda, that is to may knowledge to possible. You could schedule Docker tasks in AWS ECS (their managed container service) but it's not meant for anything realtime and more for cron job type tasks.

If you mean emulating the Lambda environment in Docker, then I wrote an answer with the difficulties of doing that below to another user.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: