简体   繁体   English

让 sam 忽略 requirements.txt

[英]make sam to IGNORE requirements.txt

So I am using AWS SAM to build and deploy some function to AWS Lambda.所以我正在使用 AWS SAM 构建和部署一些 function 到 AWS Lambda。 Because of my slow connection speed uploading functions is very slow, so I decided to create a Layer with requirements in it.由于我的连接速度很慢,上传功能很慢,所以我决定在其中创建一个带有需求的图层。 So the next time when I try to deploy function I will not have to upload all 50 mb of requirements, and I can just use already uploaded layer.所以下次当我尝试部署 function 时,我不必上传所有 50 mb 的需求,我可以使用已经上传的层。

Problem is that I could not find any parameter which lets me to just ignore requirements file and just deploy the source code.问题是我找不到任何参数可以让我忽略需求文件并只部署源代码。

Is it even possible?甚至可能吗?

I hope I understand your question correctly, but if you'd like to deploy a lambda without any dependencies you can try two things:我希望我能正确理解您的问题,但如果您想部署没有任何依赖关系的 lambda,您可以尝试两件事:

  • not running sam build before running sam deploy在运行sam deploy之前不运行sam build
  • having an empty requirements.txt file.有一个空的 requirements.txt 文件。 Then sam build simply does not include any dependencies for that lambda function.然后sam build根本不包含该 lambda function 的任何依赖项。

Of course here I assume the layer is already present in AWS and is not included in the same template.当然,在这里我假设该层已经存在于 AWS 中,并且不包含在同一个模板中。 If they are defined in the same template, you'd have to split them into two stacks.如果它们在同一个模板中定义,则必须将它们分成两个堆栈。 One with the layer which can be deployed once and one with the lambda referencing that layer.一个带有可以部署一次的层,另一个带有引用该层的 lambda。

Unfortunately sam build has no flag to ignore requirements.txt as far as I know, since the core purpose of the command is to build dependencies.不幸的是,据我所知, sam build没有忽略 requirements.txt 的标志,因为该命令的核心目的是构建依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM