Is there any library using which we can extract information about variables used in terraform scripts?
I see “terraform-config-inspect” as a utility but it gives only from that folder which is used in that but does not go into child modules. We can do that recursively but looking for a readymade library? or any other approach to get all variables used in terraform script that I can get before running the plan?
I can also write an antlr4 parser to do that by simply reading the variables block in all files under that folder but in that, I won’t know unused files/modules which are present inside the folder.
Does terraform-config-inspect have any limitations or restrictions in fetching variables for different terraform scripts, folders, or files? or any terraform versions
or it will work with all terraform versions and scripts
Another query Does terraform config inspect perform validation also like the “terraform validate” command or do we need to do validation first and then run “terraform-config-inspect explicitly”?
terraform-config-inspect is only capable of shallow syntax analysis.
It does not include any expression evaluation logic, and so it cannot implement anything equivalent to terraform validate. If terraform-config-inspect returns errors during loading then they will be only syntax errors, and not semantic errors.