TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The Case of the Broken Lambda

85 点作者 josep2超过 6 年前

9 条评论

ak217超过 6 年前
If you are frustrated by the complexity of packaging Python-based Lambda applications, I highly recommend checking out Chalice: <a href="https:&#x2F;&#x2F;github.com&#x2F;aws&#x2F;chalice" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;aws&#x2F;chalice</a>. It&#x27;s very well engineered and drastically simplifies the process (for example, it handles pre-built wheels properly, so you can cross-compile your Lambda (build and deploy it from a Mac, etc).<p>Actually, we just open-sourced a template for using Lambda with Chalice and Terraform that automates this and many other relevant steps: <a href="https:&#x2F;&#x2F;github.com&#x2F;chanzuckerberg&#x2F;chalice-app-template" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;chanzuckerberg&#x2F;chalice-app-template</a>. It&#x27;s not 100% directly applicable to this use case yet, because SAM&#x2F;CloudFormation templates don&#x27;t have a good way to manage bucket event subscriptions. But domovoi (<a href="https:&#x2F;&#x2F;github.com&#x2F;kislyuk&#x2F;domovoi" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kislyuk&#x2F;domovoi</a>) can manage S3 event subscriptions (direct or bridged through SNS, SQS, or SNS-SQS) in an idempotent declarative (non-IaC) process.
评论 #18063061 未加载
评论 #18059198 未加载
guitarbill超过 6 年前
Lambda does have a learning curve, and so does deployment safety. Many Python deployment strategies are kinda interesting because they simply always re-download the packages. Lambda doesn&#x27;t allow this.<p>And they were close to a solution. They have a CI pipeline which can and should be doing the packaging for them. The Linux image only has to be close enough to Amazon Linux, not exactly Amazon Linux. Heck, even CodeBuild uses Ubuntu [0].<p>It also doesn&#x27;t help that there&#x27;s a lack of information or simply misinformation out there. Sometimes I think frameworks with a very specific use-case like Zappa do more harm than good. Yes, it&#x27;s easier to get running, but it doesn&#x27;t give you a general purpose solution and makes you think everyone is just hacking around the mess.<p>Serverless&#x27; serverless-python-requirements is a good solution if you can&#x27;t be bothered having the CI do the packaging&#x2F;artifact creation.<p>[0] <a href="https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;codebuild&#x2F;latest&#x2F;userguide&#x2F;build-env-ref-available.html" rel="nofollow">https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;codebuild&#x2F;latest&#x2F;userguide&#x2F;build...</a>
评论 #18059849 未加载
reilly3000超过 6 年前
It boggles the mind that JSON to arvo support for Athena isn&#x27;t a native part of Firehose. Thousands of devs have had to fight, and in my case lose, this same battle. I&#x27;ve had decent luck with Severless framework&#x27;s python requirements plugin for other C libs and for large modules. Outside of that is a hellscape of logs with import errors and a lot of waiting for feedback.
scarface74超过 6 年前
The easy way to get around this is to use AWS CodeBuild with the built in Python Docker image and have it trigger when you push. You can trigger a build from either AWS Code Commit or GitHub.<p>As part of the buildspec.yml just import all of your dependencies using<p>pip install {package} -t . # (The period at the end forces it to install in the local directory.<p>In your artifacts section make sure you include everything.<p>CodeBuild will then create a zip file that you can load into the console.<p>For bonus points, once you create the lambda manually for the first time using the AWS console, you can export the CloudFormation yml file and use that as part of your automation strategy where you have a CF Parameter that specifies the name of your zip file that was uploaded to S3 by CodeBuild.<p>I use this strategy all of the time to develop on Windows and deploy to lambda.
teej超过 6 年前
I recommend following the author Vicki Boykis on Twitter (@vboykis). I&#x27;ve been following her for quite awhile, she full of data science jokes.
skunkworker超过 6 年前
We&#x27;ve been developing some products for lambda but have been building them completely in Go. We can compile them into a single fat binary with the text files inside so our deploys become a simple zip file with the binary inside. Another advantage is warmup time for go is quite fast.
lostmsu超过 6 年前
TL;DR; It&#x27;s not trivial to add a native binary (from Python package) to a Lambda function.
评论 #18060166 未加载
评论 #18062115 未加载
jocastro超过 6 年前
You can use a free ec2 instance for compiling, then upload to lambda
评论 #18059602 未加载
doombolt超过 6 年前
That&#x27;s a rude awakening but an expected one. It&#x27;s very easy to write an elegant piece of code in scripting language only to find that some of dependencies who work magic are pretty messy to deploy.<p>You can usually count on having native libraries for a given activity for Java, so you can just use a JVM-based language (does Lambda support that? I bet it does.)
评论 #18059158 未加载
评论 #18058725 未加载