I have a requirement that my lambda functions creates a new CSV file and uploads it after writing to it . I am using Python boto3 for this purpose
with open('mycsv.csv', 'w', newline ='') as f:
thewriter = csv.writer(f)
thewriter.writerow(['col1','col2','col3'])
s3_client = boto3.client('s3')
response = s3_client.upload_file('/tmp/' + mycsv.csv, 'my-bucket', 'myfoleder/'+mycsv.csv)
Note that the file 'mycsv.csv' does not exist already and I want to be able to create it on the fly as part of the lambda function. Is this even possible? I get the following error when the lambda is triggered
[Errno 30] Read-only file system: 'mycsv.csv'