dev*_*yer 6 python layer amazon-web-services aws-lambda
如何在本地运行具有层的 AWS Lambda 函数?
我的环境:
+---.aws-sam
....
+---test
| app.py
| requirements.txt
|
+---dependencies
| \---python
| constants.py
| requirements.txt
| sql.py
| utils.py
Run Code Online (Sandbox Code Playgroud)
testFunc:
Type: AWS::Serverless::Function
Properties:
CodeUri: teest/
Handler: app.test
Runtime: python3.6
FunctionName: testFunc
Events:
test:
Type: Api
Properties:
Path: /test
Method: ANY
Layers:
- !Ref TempConversionDepLayer
TempConversionDepLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: Layer1
Description: Dependencies
ContentUri: dependencies/
CompatibleRuntimes:
- python3.6
- python3.7
LicenseInfo: 'MIT'
RetentionPolicy: Retain
Run Code Online (Sandbox Code Playgroud)
我可以正确部署该函数并且在 AWS 上运行它效果很好,每当我尝试在本地运行该函数时,它都会失败并显示错误消息:
`Unable to import module 'app': No module named 'sql'`
Run Code Online (Sandbox Code Playgroud)
我尝试阅读有关 Layers 和 Pycharm 的所有可能的资源,但没有任何真正的帮助。
有人可以帮忙吗?
谢谢你,
| 归档时间: |
|
| 查看次数: |
2310 次 |
| 最近记录: |