question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python error IndexError: list index out of range

See original GitHub issue

Describe the bug I get this error for any of my terraform modules. Could it be due to tfvars files? Is there some way to specify a var file to use?

$ checkov -d /path/to/module
Traceback (most recent call last):
  File "/usr/local/bin/checkov", line 24, in <module>
    report = Runner().run(root_folder)
  File "/usr/local/lib/python3.8/site-packages/checkov/terraform/runner.py", line 22, in run
    scanned_file = definition[0].split(root_folder)[1]
IndexError: list index out of range

My terraform module is formatted as folows:

├── apis.tf
├── dataflow.tf
├── env
│   ├── backend
│   │   ├── development.tfvars
│   │   ├── production.tfvars
│   │   └── staging.tfvars
│   ├── development.tfvars
│   ├── production.tfvars
│   └── staging.tfvars
├── main.tf
├── variables.tf
└── versions.tf

To Reproduce Steps to reproduce the behavior:

  1. run checkov -d /path/to/module
  2. See error

Expected behavior Output

Desktop (please complete the following information):

  • OS: python:alpine docker image
  • Checkov Version [e.g. 22]: 1.0.78

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
dogmatic69commented, Dec 19, 2019

Hi, that is correct. The path I entered is to the location of main.tf. It’s version 0.12

I’ll send an example shortly. Will try narrow it down too 👍🏻

0reactions
schosterbarakcommented, Jan 6, 2020

closing due to inactivity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

List Index Out of Range – Python Error Message Solved
You'll get the Indexerror: list index out of range error when iterating through a list and trying to access an item that doesn't...
Read more >
Indexerror: list Index Out of Range in Python - STechies
“List index out of range” error occurs in Python when we try to access an undefined element from the list. The only way...
Read more >
Python IndexError: List Index Out of Range [Easy Fix] - Finxter
The error “list index out of range” arises if you access invalid indices in your ...
Read more >
Index Error: list index out of range (Python) - Stack Overflow
Generally it means that you are providing an index for which a list element does not exist. E.g, if your list was [1,...
Read more >
Python IndexError: List Index Out of Range Error Explained
What is the Python IndexError? ... We can break down the text a little bit. We can see here that the message tells...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found