Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I have problem with google drive credentials in AWS Lambda after I deploy my .zip file before calling the function on the local machine, all is work, but after I deploy zip in AWS after ~30min I having lambda function error

  "errorMessage": "[Errno 30] Read-only file system: 'drive-python-quickstart.json'",

"errorType": "OSError",

  "stackTrace": [

    [

      "/var/task/lambda_function.py",

      33,

      "lambda_handler",

      "pageSize=10,fields=\"nextPageToken, files(id, name)\").execute()"

    ],

    [

      "/var/task/oauth2client/_helpers.py",

      133,

      "positional_wrapper",

      "return wrapped(*args, **kwargs)"

    ],

    [

      "/var/task/googleapiclient/http.py",

      835,

      "execute",

      "method=str(self.method), body=self.body, headers=self.headers)"

    ],

    [

      "/var/task/googleapiclient/http.py",

      162,

      "_retry_request",

      "resp, content = http.request(uri, method, *args, **kwargs)"

    ],

    [

      "/var/task/oauth2client/transport.py",

      186,

      "new_request",

      "credentials._refresh(orig_request_method)"

    ],

    [

      "/var/task/oauth2client/client.py",

      761,

      "_refresh",

      "self._do_refresh_request(http)"

    ],

    [

      "/var/task/oauth2client/client.py",

      802,

      "_do_refresh_request",

      "self.store.locked_put(self)"

    ],

    [

      "/var/task/oauth2client/file.py",

      79,

      "locked_put",

      "f = open(self._filename, 'w')"

    ]

  ]

}

in file file.py I have this code :

 def locked_put(self, credentials):

    """Write Credentials to file.

    Args:

        credentials: Credentials, the credentials to store.

    Raises:

        IOError if the file is a symbolic link.

    """

    self._create_file_if_needed()

    _helpers.validate_file(self._filename)

    f = open(self._filename, 'w')

    f.write(credentials.to_json())

    f.close()

def locked_delete(self):

    """Delete Credentials file.

    Args:

        credentials: Credentials, the credentials to store.

    """

    os.unlink(self._filename)

I try to set f = open(self._filename, 'w') set to 'r', but it doesn't help, maybe whom know how can I fix it?

1 Answer

+1 vote
by (44.4k points)

You are trying to write a file in a different directory but Lambda only supports /tmp directory for storing temporary files.

If you are interested to learn Python from Industry experts, you can sign up for this Python Certification Course by Intellipaat.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...