Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Terrascan can't initialise in Super Linter #63

Open
jacobwoffenden opened this issue Feb 13, 2024 · 0 comments
Open

🐛 Terrascan can't initialise in Super Linter #63

jacobwoffenden opened this issue Feb 13, 2024 · 0 comments
Labels
bug Observability Platform Bug

Comments

@jacobwoffenden
Copy link
Member

ministryofjustice/terraform-aws-observability-platform-tenant#10 was failing because Terrascan can't initialise

2024-02-13 09:31:56 [DEBUG]   Started GitHub Actions log group: TERRAFORM_TERRASCAN
  2024-02-13 09:31:56 [INFO]   Linting TERRAFORM_TERRASCAN items...
  2024-02-13 09:31:56 [DEBUG]   PARALLEL_RESULTS_FILE_PATH for TERRAFORM_TERRASCAN: /tmp/super-linter-worker-results-TERRAFORM_TERRASCAN.json
  2024-02-13 09:31:56 [DEBUG]   LOG_DEBUG is enabled. Enable verbose ouput for parallel
  2024-02-13 09:31:56 [DEBUG]   PARALLEL_COMMAND for TERRAFORM_TERRASCAN: parallel --will-cite --keep-order --max-procs 4 --xargs --results /tmp/super-linter-worker-results-TERRAFORM_TERRASCAN.json --verbose
  2024-02-13 09:31:56 [DEBUG]   TERRAFORM_TERRASCAN doesn't support linting files in batches. Configure the linter to run over the files to lint one by one
  2024-02-13 09:31:56 [DEBUG]   PARALLEL_COMMAND for TERRAFORM_TERRASCAN after updating the number of files to lint per process: parallel --will-cite --keep-order --max-procs 4 --xargs --results /tmp/super-linter-worker-results-TERRAFORM_TERRASCAN.json --verbose --max-lines 1
  2024-02-13 09:31:56 [DEBUG]   LINTER_WORKING_DIRECTORY for TERRAFORM_TERRASCAN: /github/workspace
  2024-02-13 09:31:56 [DEBUG]   PARALLEL_COMMAND for TERRAFORM_TERRASCAN after updating the working directory: parallel --will-cite --keep-order --max-procs 4 --xargs --results /tmp/super-linter-worker-results-TERRAFORM_TERRASCAN.json --verbose --max-lines 1 --workdir /github/workspace
  2024-02-13 09:31:56 [DEBUG]   Checking if /action/lib/.automation/.checkov.yaml contains a 'directory:' configuration option
  2024-02-13 09:31:56 [DEBUG]   /action/lib/.automation/.checkov.yaml doesn't contain a 'directory:' statement
  2024-02-13 09:31:56 [DEBUG]   Adding the '--directory' option to the Checkov command.
  2024-02-13 09:31:56 [DEBUG]   LINTER_COMMAND_ARRAY for TERRAFORM_TERRASCAN has 9 elements: terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f
  2024-02-13 09:31:56 [DEBUG]   PARALLEL_COMMAND for TERRAFORM_TERRASCAN after LINTER_COMMAND_ARRAY concatenation: parallel --will-cite --keep-order --max-procs 4 --xargs --results /tmp/super-linter-worker-results-TERRAFORM_TERRASCAN.json --verbose --max-lines 1 --workdir /github/workspace terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f
  2024-02-13 09:31:59 [DEBUG]   PARALLEL_COMMAND_OUTPUT for TERRAFORM_TERRASCAN (exit code: 3): cd /github/workspace || exit 255; terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f /github/workspace/variables.tf
  cd /github/workspace || exit 255; terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f /github/workspace/main.tf
  cd /github/workspace || exit 255; terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f /github/workspace/providers.tf
  2024-02-13 09:31:59 [DEBUG]   Parallel output file (/tmp/super-linter-worker-results-TERRAFORM_TERRASCAN.json) contents for TERRAFORM_TERRASCAN:
  { \"Seq\": 1, \"Host\": \":\", \"Starttime\": 1707816716.786, \"JobRuntime\": 0.242, \"Send\": 0, \"Receive\": 0, \"Exitval\": 1, \"Signal\": 0, \"Command\": \"terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f /github/workspace/variables.tf\", \"V\": [ \"/github/workspace/variables.tf\" ], \"Stdout\": \"\", \"Stderr\": \"2024-02-13T09:31:57.026Z	error	cli/init.go:42	failed to initialize terrascan. error : failed to download policies. error: 'repository already exists'
  \" }
  { \"Seq\": 2, \"Host\": \":\", \"Starttime\": 1707816716.795, \"JobRuntime\": 2.294, \"Send\": 0, \"Receive\": 0, \"Exitval\": 1, \"Signal\": 0, \"Command\": \"terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f /github/workspace/main.tf\", \"V\": [ \"/github/workspace/main.tf\" ], \"Stdout\": \"\", \"Stderr\": \"2024-02-13T09:31:59.084Z	error	cli/init.go:42	failed to initialize terrascan. error : failed to download policies. error: 'already up-to-date'
  \" }
  { \"Seq\": 3, \"Host\": \":\", \"Starttime\": 1707816716.809, \"JobRuntime\": 2.280, \"Send\": 0, \"Receive\": 0, \"Exitval\": 1, \"Signal\": 0, \"Command\": \"terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f /github/workspace/providers.tf\", \"V\": [ \"/github/workspace/providers.tf\" ], \"Stdout\": \"\", \"Stderr\": \"2024-02-13T09:31:59.081Z	error	cli/init.go:42	failed to initialize terrascan. error : failed to download policies. error: 'packfile not found'
  \" }
  Error: 4-02-13 09:31:59 [ERROR]   Found errors when linting TERRAFORM_TERRASCAN. Exit code: 3.
  2024-02-13 09:31:59 [DEBUG]   RESULTS_OBJECT for TERRAFORM_TERRASCAN:
  [
    {
      \"Seq\": 1,
      \"Host\": \":\",
      \"Starttime\": 1707816716.786,
      \"JobRuntime\": 0.242,
      \"Send\": 0,
      \"Receive\": 0,
      \"Exitval\": 1,
      \"Signal\": 0,
      \"Command\": \"terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f /github/workspace/variables.tf\",
      \"V\": [
        \"/github/workspace/variables.tf\"
      ],
      \"Stdout\": \"\",
      \"Stderr\": \"2024-02-13T09:31:57.026Z	error	cli/init.go:42	failed to initialize terrascan. error : failed to download policies. error: 'repository already exists'
  \"
    },
    {
      \"Seq\": 2,
      \"Host\": \":\",
      \"Starttime\": 1707816716.795,
      \"JobRuntime\": 2.294,
      \"Send\": 0,
      \"Receive\": 0,
      \"Exitval\": 1,
      \"Signal\": 0,
      \"Command\": \"terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f /github/workspace/main.tf\",
      \"V\": [
        \"/github/workspace/main.tf\"
      ],
      \"Stdout\": \"\",
      \"Stderr\": \"2024-02-13T09:31:59.084Z	error	cli/init.go:42	failed to initialize terrascan. error : failed to download policies. error: 'already up-to-date'
  \"
    },
    {
      \"Seq\": 3,
      \"Host\": \":\",
      \"Starttime\": 1707816716.809,
      \"JobRuntime\": 2.280,
      \"Send\": 0,
      \"Receive\": 0,
      \"Exitval\": 1,
      \"Signal\": 0,
      \"Command\": \"terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f /github/workspace/providers.tf\",
      \"V\": [
        \"/github/workspace/providers.tf\"
      ],
      \"Stdout\": \"\",
      \"Stderr\": \"2024-02-13T09:31:59.081Z	error	cli/init.go:42	failed to initialize terrascan. error : failed to download policies. error: 'packfile not found'
  \"
    }
  ]
  2024-02-13 09:31:59 [DEBUG]   Set INDEX for TERRAFORM_TERRASCAN to: 3
  2024-02-13 09:31:59 [DEBUG]   Stdout for TERRAFORM_TERRASCAN is empty
  2024-02-13 09:31:59 [INFO]   Command output for TERRAFORM_TERRASCAN:
  ------
  2024-02-13T09:31:57.026Z	error	cli/init.go:42	failed to initialize terrascan. error : failed to download policies. error: 'repository already exists'
  
  2024-02-13T09:31:59.084Z	error	cli/init.go:42	failed to initialize terrascan. error : failed to download policies. error: 'already up-to-date'
  
  2024-02-13T09:31:59.081Z	error	cli/init.go:42	failed to initialize terrascan. error : failed to download policies. error: 'packfile not found'
  ------
  2024-02-13 09:31:59 [DEBUG]   Ending GitHub Actions log group: TERRAFORM_TERRASCAN

Temporary solution is to add VALIDATE_TERRAFORM_TERRASCAN: false to Super Linter


This does work locally if you execute locally

docker run -it --rm --platform linux/amd64 \
  --env ACTIONS_RUNNER_DEBUG="true" \
  --env RUN_LOCAL="true" \
  --env DEFAULT_BRANCH="main" \
  --volume "${PWD}":/tmp/lint \
  --workdir /tmp/lint \
  --entrypoint /bin/bash \
  ghcr.io/super-linter/super-linter:slim-v6.0.0

terrascan scan -i terraform -t all -c /action/lib/.automation/terrascan.toml -f main.tf
@jacobwoffenden jacobwoffenden added the bug Observability Platform Bug label Feb 13, 2024
@jacobwoffenden jacobwoffenden transferred this issue from ministryofjustice/terraform-aws-observability-platform-tenant Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observability Platform Bug
Projects
Status: 👀 TODO
Development

No branches or pull requests

1 participant