AWS Lambda Cannot Execute External Commands

Asked 2 years ago, Updated 2 years ago, 157 views

exports.handler=function(event, context){
  var exec = require('child_process').exec;
  exec('./youtube-dl --version', function(error, stdout, stderr){
    if(stdout){
      console.log('stdout:'+stdout);
    }
    if(stderr){
      console.log('stderr:'+stderr);
    }
    if(error!==null){
      console.log('Exec error:'+error);
    }
    context.succeed(stdout);
  });
};

Even if I want to change the execution permission, it seems that I don't have write permission, so I can't change it with chmod.
After copying the executable to a writable /tmp

chmod755 youtube-dl

If so, you can change the permissions and execute them, but it is inconvenient.
Can't I manage to run it in the same directory as the function?

node.js aws aws-lambda

2022-09-30 21:11

1 Answers

(Comment transcription)

I solved myself. I could have done it if I had set the permission on the unix machine before compressing it to zip.


2022-09-30 21:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.