0

Normally, to test my aws lambda functions, Id do this:

IMG_FILE='/some/image/loc//img.jpg' &&\
jo img=%"$IMG_FILE" | curl -X POST -H 'Content-Type: application/json' -d @- "$LAMBDA_HOST" >> output.bin

Id like to replicate the same with aws lambda invoke function like so:

IMG_FILE='/some/image/loc//img.jpg' &&\
jo img=%"$IMG_FILE" |aws lambda invoke --payload XXXXXX --function-name funky_func output.bin

How do I pass the jo output to the --payload param? :(

JohnJ
  • 6,736
  • 13
  • 49
  • 82

1 Answers1

0

Oh, looking at the documentation, it appears that --payload can take a file:// parameter. So you can do:

IMG_FILE='/some/image/loc/img.jpg' &&
  jo img=%"$IMG_FILE" > img.json &&
  aws lambda invoke --payload file://img.json \
    --function-name funky_func output.bin

...but it's possible you'll hit some limitation on command line length depending on the size of your image.


It's possible -- but I'm unable to test this at the moment -- that if you were to provide a file argument of file:///dev/stdin that you could provide the JSON on stdin. Maybe worth a try.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • yea the whole point of using jo was to not do this :( – JohnJ Jan 27 '22 at 12:49
  • I've read the documentation for you and suggested and alternative. – larsks Jan 27 '22 at 12:51
  • yea.. I tried this option `--payload file://img.json` aswell.. but for some weird reason, it litters/outputs on my terminal with the payload contents and there is no `output.bin` :( so bizzare. – JohnJ Jan 27 '22 at 13:06
  • I tried this aswell now `file:///dev/stdin` again, it just outputs the json on my terminal.... odd.. – JohnJ Jan 27 '22 at 13:10