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

Can't parse Terraform variable field: nullable #1176

Closed
lostplan opened this issue Mar 2, 2022 · 3 comments · Fixed by #1211
Closed

Can't parse Terraform variable field: nullable #1176

lostplan opened this issue Mar 2, 2022 · 3 comments · Fixed by #1211

Comments

@lostplan
Copy link

lostplan commented Mar 2, 2022

  • terrascan version: v1.13.2
  • Operating System: macOS 12.2.1

Description

After adding nullable = false to a variable definition, terrascan can no longer parse the file.

See https://www.terraform.io/language/values/variables#disallowing-null-input-values for documentation of the field.

Here is a minimal example:

terraform {
}

variable "in" {
  type     = string
  nullable = false
}

resource "null_resource" "test_resource" {
  triggers = {
    input_value = var.in
  }
}

What I Did

Terraform validates OK:

$ terraform validate
Success! The configuration is valid.

The terrascan scan also appears to be successful:

$ terrascan scan --iac-type terraform
Scan Summary -

	File/Folder         :	/path/to/terrascan-test
	IaC Type            :	terraform
	Scanned At          :	2022-03-02 09:19:21.960337 +0000 UTC
	Policies Validated  :	786
	Violated Policies   :	0
	Low                 :	0
	Medium              :	0
	High                :	0

However the process exited with code 4 (“scan summary has errors but no violations” – https://runterrascan.io/docs/usage/command_line_mode/):

$ echo $?
4

Enabling debug logging shows the error:

$ terrascan scan --iac-type terraform --log-level debug

2022-03-02T09:29:52.023Z	debug	commons/load-dir.go:146	failed to load terraform config dir '/path/to/terrascan-test'. error from terraform:
/path/to/terrascan-test/main.tf:6,3-11: Unsupported argument; An argument named "nullable" is not expected here.
@leadenmoth
Copy link

This is still a bug in v1.18.0. Looking at code in #1211 I can't see how it was related to this issue or #1182 - the issue is that valid terraform syntax isn't recognized, not that the message is imprecise

@davidjeddy
Copy link

Related / Duplicate of #1266 ?

@leadenmoth
Copy link

@davidjeddy this is actually the earliest mention of this bug, as far as I can find, but it is incorrectly closed by an unrelated fix. A few more duplicates are listed at the end of this comment: #1547 (comment)
I'm not sure if our team is still using terrascan and waiting for a fix at this point, or have replaced it with something else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants