Below are a couple of problems I ran into when writing a Python 2.7 Lambda function that created a file and then uploaded it to S3. (s3.upload_file)
- The file I was creating and writing to in the function was empty in S3 after the upload.
- Turns out I needed the “( )” braces on the Python “close” command. Silly issue, but took my like 20 minutes to figure out….
- In your Lambda function, you need to create your files under /tmp, which is your functions ephemeral storage.
- fileName = ‘/tmp/’ + name