英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论