101 AWS Lambda tutorial for Go developers
blog.mantil.com
blog.mantil.com
I've been using C# and looking up how to handle DI and have been trying to piece together things from old articles and SO posts that I have no idea hold true today or not. Why they simply can't provide up to date best practices for various scenarios is beyond frustrating. I guess they're big enough they don't need to care that much.
If you don't do this, your runtime DI will become one of the most expensive parts of your lambda stack. It will dramatically affect performance and your requirements for memory in ways it simply wouldn't for long running container services.
There’s absolutely 0 need for DI.
Some advice:
Don't use zip files. There's no reason to use them. The OCI image approach let's you use much larger images (which with Go binary sizes might occasionally be important - 10GB vs 50MB) and only sounds scary. It's as easy as using zip files, if not easier, cause you just end up with a 10 line multistage docker image which does everything you need to produce your final artifact.
Also important, though that part is actually fairly well documented in the runtime reference, the runtime of your Lambda will be hibernated between invocations (a warm lambda, I don't mean cold starts). That means, if you have asynchronous goroutines which are periodically doing IO, you might end up with loads of timeouts and broken TCP connections there, as you'll often get hibernated mid-IO-operation.
I purchased programming-aws-lambda from here https://learning.oreilly.com/library/view/programming-aws-la...
Highly recommend.
But I'm sure Terraform has some points for it too. I'm curious what people's thoughts are.
But it does seem to require human input in the Console. I'm not sure if that is a requirement or they just did it that way for the tutorial.
AWS SAM, Serverless, AWS CDK, ... are all valid tools. Just don't use AWS Console for changing infrastructure; your clicks are hard to share ;).
Here in Mantil we are using mostly Terraform but also the CloudFormation and AWS SDK for operations where they fit better.
In the article I was trying to highlight the difference between two approaches; one imperative (build infrastructure line by line) the other declarative (describe desired end state).
I greatly prefer declarative vs imperative. But since SAM is also declarative, I was just curious why TerraForm.
Use what you know and what you already have in you stack!
Pipedream also just launched Go support for workflow serverless steps, so you can write and execute Go serverless functions without managing deployments to Lambda. It's all through a Web UI.