This is slightly related to this previous question .
Similar to that time, I am trying to use pygsheets on AWS Lambda and I'm having trouble with the json file. Like what he discussed, the json file is included in the zip.
What I'm having trouble with now is a write error. When I invoke the function I get the following error.
{
"errorMessage": "[Errno 30] Read-only file system: 'sheets.googleapis.com-python.json'",
"errorType": "OSError",
"stackTrace": [
" File \"/var/lang/lib/python3.8/imp.py\", line 234, in load_module\n return load_source(name, filename, file)\n",
" File \"/var/lang/lib/python3.8/imp.py\", line 171, in load_source\n module = _load(spec)\n",
" File \"<frozen importlib._bootstrap>\", line 702, in _load\n",
" File \"<frozen importlib._bootstrap>\", line 671, in _load_unlocked\n",
" File \"<frozen importlib._bootstrap_external>\", line 783, in exec_module\n",
" File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n",
" File \"/var/task/handler.py\", line 151, in <module>\n gc = py.authorize(client_secret='google-sheets-credentials.json')\n",
" File \"/var/task/pygsheets/authorization.py\", line 129, in authorize\n credentials = _get_user_authentication_credentials(client_secret, scopes, credentials_directory, local)\n",
" File \"/var/task/pygsheets/authorization.py\", line 64, in _get_user_authentication_credentials\n with open(credentials_path, 'w') as file:\n"
]
}
The user who had trouble with the json file seemed to have gotten things working and yet I've read that lambda functions are immutable. Can anyone clear this up for me? If possible, how can I get past this issue?
Edit:
This is the portion of code that is relevant to the question. As I stated, the json file is included in the zip that I uploaded to AWS Lambda. The other question on stack overflow that I linked to got things working so my guess is I need to put one or both of the two json files in a different directory, but I'm not sure as there are very little details in their answer.
import pygsheets as py
gc = py.authorize(client_secret='google-sheets-credentials.json')