0

I am using fs (Node Module) to manage files. I am getting the file's created time (BirthTime). It is working absolutely fine when I run this app on my local machine. But when I try to implement it on EFS using NodeJs Lambda function then it gives 1970-01-01T00:00:00.000Z which is not the actual time of the file that I created.

var efsDirectory = "/mnt/data/";
var filePath = path.join(efsDirectory, file);
console.log("This file is going to be executed :", file);
var response = fs.statSync(filePath);
let fileBirthTime = response.birthtime;
console.log("File path is : ", filePath);

After joining the path my filepath looks like this filepath = /mnt/data/172.807056.json which is the actual path of the file.

In the Cloudwatch logs I am getting this : CloudWatch Logs

On the local machine, it is working fine and giving the actual file birthtime. Can you tell me guys why I am getting this?

Rehan CH
  • 109
  • 1
  • 11

1 Answers1

0

I posted the same question on the AWS repost, and an engineer responded to me with the following answer. Pasting the same answer here, if someone is facing that problem too.

You are getting this result with birthtime, as it is not supported on most NFS filesystems like EFS. Even on Linux OSes it depends on the kernel and type of file system as to whether this field is supported. The default file system on Amazon Linux 2 on EBS doesn't return a value to birthtime. However with the latest Ubuntu image, it is supported. This is why you would be seeing a difference between running it locally and against EFS.

Rehan CH
  • 109
  • 1
  • 11