0
  1. Want to read a file from S3 bucket (ex: text.txt) using lambda
  2. write file in current directory, to location(ex: __dirname + 'text.txt') using lambda

I am able to read file

let txtfilepath = __dirname + 'text.txt'
var params = {   

enter code here
Bucket: bucketname,   
Key: filepathInS3
}; 

S3.getObject(params, function(err, data){   
if (err)
      console.error(err.code, "-", err.message);
      return (err);  
enter code here
fs.writeFile(txtfilepath, data.Body, function(err){
    if(err)
    console.log(err.code, "-", err.message);
    return (err);   
});
});

getting error - read-only file system

1 Answer 1

3

The only directory you can write to in the Lambda execution environment is /tmp, all other folders are read-only.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.