3 ms·
Has anyone used the AWS API Gateway service with lambdas to set up a small backend for a web service? The next thing I'm thinking about setting up is a slush re
by mojoe 10y ago
Has anyone used the AWS API Gateway service with lambdas to set up a small backend for a web service? The next thing I'm thinking about setting up is a slush reader with a GUI, and I'm wondering how difficult it will be to pipe binary files from S3 -> Lambda -> API Gateway -> client. It looks like I'll probably need to encode the binaries to base64 on the lambda side, and will need a library for that.
- adzicg 10y agoshameless plug: have a look at https://claudiajs.com https://claudiajs.com - I wrote lots of tutorials and example projects for common use cases of API GW+Lambda
- mojoe 10y agoThis looks cool -- I'm using Python right now, but if I ever use javascript lambdas I'll give this a try.
- balls187 10y agoYes extensively. API-Gateway => Lambda isn't fun to trouble shoot. That said, once you get it working, it works really well, and it's ridiculously cheap.
- mojoe 10y agoHave you written anything about this, or can you point me to any resources that might help me avoid pitfalls? I'd appreciate it!
- balls187 10y agoSadly, no I haven't written anything. (if my comments are any indication--I kinda suck as a writer). The biggest pains are: * Mapping parameters in API Gateway * Setting the IAM Roles for API Gateway & Lambda (the latter is required to provide execution for API Gateway) * Setting up custom domains for your API (it uses cloudfront, but must be done via the commandline, and the process kind of sucks) I've done this work now 3 times. Feel free to email me any questions you have: balasuar@gmail.com and I'll be happy to answer, and provide guidance.
- mojoe 10y agoThanks, I may take you up on that down the road!
- MrMullen 10y agoZappa is a Python tool that can be extremely helpful for persons getting into Lambda. It basically handles everything except for code creation (You have to do that). You can make crontab like jobs or a website and then push the code up to Lamba with a single command. It handles all the temporary S3 buckets, IAM account creation, fetching the Lambda URL, uploading code and connecting Lambda to API Gateway. Deployments are super smooth. pip install zappa It supports all of the Languages for Lambda, not just Python.
- mojoe 10y agoI'm glad that tools like this exist, I wasn't aware of them, thanks
- ak217 10y agoTake a look at https://github.com/awslabs/chalice https://github.com/awslabs/chalice. IMO it's better than zappa if you are Python-centric. As you can tell from the name, it strives to be the Lambda-based equivalent of Flask. One tip regarding your workflow: don't pipe data from S3 to Lambda to your client unless you really have to. You can use S3 pre-signed URLs to granularly delegate access to S3 objects for a limited time, then refer your client to them. Even if you are generating the binary content on the fly in your lambda, it's easier to save it to S3 and refer the client to that. That said, if your content is truly too dynamic to live on S3, then gzip+base64 encoding it, serving it in json and decoding/displaying it in javascript should be straightforward.
- mojoe 10y agoI'll check this out, thanks!
- talawahdotnet 10y agoFor binary content I would recommend serving those files directly from S3 via Cloudfront under a different domain. Lambda and API gateway really aren't set up to work with binaries right now. Even serving .csv files requires some workarounds. FYI it is also possible to go directly from the API Gateway to S3 without going thru Lambda
- defen 10y agohttps://www.zappa.io/ https://www.zappa.io/ if you value your sanity. The raw tools provided by Amazon are extremely powerful but are basically the cloud equivalent of programming in assembly.