【发布时间】:2020-12-08 19:28:22
【问题描述】:
我有一个 lambda 函数返回一个错误,即没有找到这样的文件或目录。
为了清楚起见,下图显示了我的 lambda 中存在的文件结构,很明显我正在寻找的目录确实存在。
My current file structure in the lambda function
我收到的错误消息:
[ERROR] FileNotFoundError: [Errno 2] No such file or directory: 'config'
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 23, in lambda_handler
os.chdir("config")
下面是 lambda_handler:
import os
import json
def lambda_handler(event, context):
print(event)
os.chdir("config")
loginInfo = json.load(open('secrets.json'))
return loginInfo
我将目录更改为 config 的原因是我可以访问我的 secrets.json 文件。
请让我知道这是否足以重现细节。
【问题讨论】:
标签: python json amazon-web-services aws-lambda boto3