Lambdaからcurlしようとしたらエラー
Lambdaで遊んでるんだけど、ちょっとした検証をしたくてLambdaからhttpリクエストをcurlで出そうとした。ちなみに言語はPython。requestsをimportしてもいいが、zipにしてあげるのがめんどくさかった。
subprocessをimportして、curlをしてみたらエラーが。。。
どうやら標準でインストールされていないらしい。
[ERROR] FileNotFoundError: [Errno 2] No such file or directory: 'curl' Traceback (most recent call last): File "/var/task/lambda_function.py", line 51, in lambda_handler subprocess.run(['curl', 'example.com']) File "/var/lang/lib/python3.8/subprocess.py", line 489, in run with Popen(*popenargs, **kwargs) as process: File "/var/lang/lib/python3.8/subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/var/lang/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename)END RequestId: 54771e23-e24a-4e75-9de9-fa9729347f06
残念だけど、まあ納得。requestsをimportがいいのかな。
ちなみに/usr/bin配下をみてみた。
alias arch awk base64 basename bash bashbug bashbug-64 bg ca-legacy captoinfo cat catchsegv cd chcon chgrp chmod chown cksum clear comm command cp csplit cut date dd df dgawk dir dircolors dirname du echo egrep env expand expr factor false fc fg fgrep fmt fold gawk gencat getconf getent getopts grep groups head hostid iconv id igawk info infocmp infokey infotocap install jobs join ldd link ln locale localedef logname ls makedb md5sum mkdir mkfifo mknod mktemp mv nice nl nohup nproc numfmt od p11-kit paste pathchk pgawk pinky pldd pr printenv printf ptx pwd read readlink realpath reset rm rmdir rpcgen runcon sed seq sh sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf sleep sort sotruss split sprof stat stdbuf stty sum sync tabs tac tail tee test tic timeout toe touch tput tr true truncate trust tset tsort tty tzselect umask unalias uname unexpand uniq unlink update-ca-trust users vdir wait wc who whoami yes
ぐへ。