AWS SAM – 本地测试 Lambda 时从本地主机复制文件

huangapple go评论67阅读模式
英文:

AWS SAM - Copy files from local host while locally testing lambda

问题

需要从本地主机复制文件,同时使用AWS SAM测试Lambda函数。这将模拟在实际情况下从S3复制文件的情况。在本地测试期间,有没有办法从Lambda函数内部复制本地主机上的文件?

我尝试将本地目录挂载为Docker容器中的卷,以执行Lambda函数,但结果显示,在AWS SAM中将卷附加到Docker容器尚不受支持(这是GitHub请求 https://github.com/aws/aws-sam-cli/issues/2589,该请求仍然处于打开状态)。

英文:

I need to copy files from a local host while testing lambda using AWS SAM. This will simulate a case when in a real scenario files are copied from S3. Is there any way to copy files from a local host inside lambda while local testing?

I was trying to mount the local directory as a volume in a Docker container which executes lambda, but it turns out that attaching volumes to a Docker container in AWS SAM is not supported yet ( here is GitHub request https://github.com/aws/aws-sam-cli/issues/2589 which is still open )

答案1

得分: 0

你可以使用安装localstack 并将其用作测试中的虚假本地S3端点。如果从S3中提取数据对于你的Lambda函数至关重要,那么你的测试在全面性方面会有所改善。

英文:

You could use install localstack and use that in your tests as a fake, local s3 endpoint. If pulling data from s3 is crucial for your lambda then your tests would improve in their comprehensiveness.

huangapple
  • 本文由 发表于 2023年4月7日 00:38:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/75951835.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定