I am trying to download a file and store in /tmp of lambda, in log i can only see first hey, why i am not able to see any catch error or any other logs.
In local it works pretty fine.
const https = require('https');
const fs = require('fs');
// const url =
// 'someurl';
function downloadfile(url) {
console.log('hi')
const req = https.get(url, function (res) {
const fileStream = fs.createWriteStream('testObject.obj');
res.pipe(fileStream);
fileStream.on('error', function (err) {
console.log('error writing to the stream');
console.log(err);
});
fileStream.on('finish', function () {
fileStream.close();
console.log('done');
});
});
req.on('error', function (err) {
console.log('error downloading the file');
console.log(err);
});
}
exports.handler = async (event) => {
downloadfile(
'someurl'
);
};
You're trying to write to ./, the only directory accessible by lambdas is ./tmp
There is also a local file system available at /tmp for all Lambda functions