我试图通过使用层缓存选项在本地测试lambda层,但无法使其工作,我使用sam cdk和python3。
在我的api/ lambda _layers/ function中,我有一个名为common.py容器的文件,这是一个简单的函数,我喜欢在我的lambda中共享它。
sam local invoke createLocations --event api/events/create_location_event.json -t cdk/cdk.out/LocationsAPI.template.json --layer-cache-basedir api/lambda_layers/common --force-image-build --docker-network lambda-local虽然在我的app.py中我导入了“公共”,但我得到了
commonlayer8CAC0AFA is a local Layer in the template
Building image........................
"errorMessage": "Unable to import module 'app': No module named 'common'", "errorType": "Runtime.ImportModuleError", "stackTrace": []}```
is there any other solution than --layer-cache-basedir ?发布于 2022-08-01 22:24:37
在sam命令中尝试--docker-volume-basedir选项。
https://stackoverflow.com/questions/73199348
复制相似问题