I was able to run the iac scanner via snyk using these commands:
$ npm install -g snyk
$ snyk auth my-hash-api-token-key
$ snyk iac test /path/to/my/terraform.tf
I tried to wrapped those commands into one bash script using this format
#!/bin/bash
token=$1
directory=$2
echo "PERFORMING SNYK SCAN"
echo "INSTALL SNYK"
npm install -g snyk
echo "AUTHENTICATE TO SNYK PORTAL"
snyk auth ${token}
echo "PERFORM SNYK TEST"
snyk iac test ${directory}
However I always got this result from terminal = /usr/bin/env: node: No such file or directory and looking to a package.json Sample output when executing the wrapper script below:
$ pwd
/home/user
$ ls -ltrh
total 0
drwxrwxr-x 3 user user 59 Feb 22 08:55 terraform-files
$ my-wrapper-script.sh my-hash-api-token-key /home/user/terraform-files
PERFORMING SNYK SCAN
INSTALL SNYK
/usr/bin/snyk -> /usr/lib/node_modules/snyk/dist/cli/index.js
+ snyk@1.458.0
updated 1 package in 11.49s
AUTHENTICATE TO SNYK PORTAL
Authenticating
PERFORM SNYK TEST
npm WARN saveError ENOENT: no such file or directory, open '/home/user/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/user/package.json'
npm WARN SOURCE_REPO_FOLDER No description
npm WARN SOURCE_REPO_FOLDER No repository field.
npm WARN SOURCE_REPO_FOLDER No README data
npm WARN SOURCE_REPO_FOLDER No license field.
/usr/bin/env: node: No such file or directory
/usr/bin/env: node: No such file or directory
PS: I also tried the suggested solutions I found on other articles like creating sym link on nodejs and node but that is not applicable cause I already have node on my box. I still have limited knowledge in npm/node. My goal is to make the scanning work
sorry for I lost track, this has been resolved. We have removed the snyk from the wrapper script and use a different approach of running it. We can close this