Skip to content

TFLint errors on JSON syntax with root array of blocks #2279

@mariusz-slowinski

Description

@mariusz-slowinski

Summary

Correct terraform import statements in import.tf.json file are reported by tflint as invalid.

Failed to check ruleset; failed to check "terraform_deprecated_index" rule: import.tf.json:1,1-2: Incorrect JSON value type; A JSON object is required here, setting the arguments for this block., and 4 other diagnostic(s)

Annotation does not help because JSON comment changes import file structure so it can't be used by terraform later.

Command

tflint

Terraform Configuration

[
  {
    "import": {
      "id": "/subscriptions/<redacted>",
      "to": "azurerm_resource_group.main"
    }
  }
]

TFLint Configuration

tflint {
    required_version = ">= 0.50"
}

Output

18:18:14 config.go:175: [INFO] Load config: .tflint.hcl
18:18:14 config.go:183: [INFO] file not found
18:18:14 config.go:190: [INFO] Load config: /home/maslow/.tflint.hcl
18:18:14 config.go:347: [DEBUG] Config loaded
18:18:14 config.go:348: [DEBUG]   CallModuleType: local
18:18:14 config.go:349: [DEBUG]   CallModuleTypeSet: false
18:18:14 config.go:350: [DEBUG]   Force: false
18:18:14 config.go:351: [DEBUG]   ForceSet: false
18:18:14 config.go:352: [DEBUG]   DisabledByDefault: false
18:18:14 config.go:353: [DEBUG]   DisabledByDefaultSet: false
18:18:14 config.go:354: [DEBUG]   PluginDir: 
18:18:14 config.go:355: [DEBUG]   PluginDirSet: false
18:18:14 config.go:356: [DEBUG]   Format: 
18:18:14 config.go:357: [DEBUG]   FormatSet: false
18:18:14 config.go:358: [DEBUG]   Varfiles: 
18:18:14 config.go:359: [DEBUG]   Variables: 
18:18:14 config.go:360: [DEBUG]   Only: 
18:18:14 config.go:361: [DEBUG]   IgnoreModules:
18:18:14 config.go:365: [DEBUG]   Rules:
18:18:14 config.go:369: [DEBUG]   Plugins:
18:18:14 config.go:476: [INFO] The "terraform" plugin block is not found. Enable the plugin "terraform" automatically
18:18:14 option.go:91: [DEBUG] CLI Options
18:18:14 option.go:92: [DEBUG]   CallModuleType: local
18:18:14 option.go:93: [DEBUG]   Force: false
18:18:14 option.go:94: [DEBUG]   Format: 
18:18:14 option.go:95: [DEBUG]   Varfiles: 
18:18:14 option.go:96: [DEBUG]   Variables: 
18:18:14 option.go:97: [DEBUG]   EnableRules: 
18:18:14 option.go:98: [DEBUG]   DisableRules: 
18:18:14 option.go:99: [DEBUG]   Only: 
18:18:14 option.go:100: [DEBUG]   EnablePlugins: 
18:18:14 option.go:101: [DEBUG]   IgnoreModules:
18:18:14 loader.go:39: [INFO] Initialize new loader
18:18:14 module_mgr.go:63: [INFO] Module manifest file found. Initializing...
18:18:14 loader.go:81: [INFO] Building the root module while calling local child modules...
18:18:14 loader.go:108: [DEBUG] Trying to load the local module: name=resource-group dir=../modules/resource-group
18:18:14 runner.go:46: [INFO] Initialize new runner for root
18:18:14 input_value.go:67: [INFO] TF_VAR_* environment variable found: key=TF_VAR_environment
18:18:14 input_value.go:67: [INFO] TF_VAR_* environment variable found: key=TF_VAR_azdo_org_guid
18:18:14 input_value.go:67: [INFO] TF_VAR_* environment variable found: key=TF_VAR_azdo_org_name
18:18:14 discovery.go:33: [INFO] Plugin "terraform" is not installed, but the bundled plugin is available.
18:18:14 discovery.go:54: [INFO] Plugin "terraform" found
18:18:14 [DEBUG] cmdrunner/cmd_runner.go:73: starting plugin: path=/usr/local/bin/tflint args=["/usr/local/bin/tflint", "--act-as-bundled-plugin"]
18:18:14 [DEBUG] cmdrunner/cmd_runner.go:80: plugin started: path=/usr/local/bin/tflint pid=88738
18:18:14 [DEBUG] go-plugin@v1.6.1/client.go:827: waiting for RPC address: plugin=/usr/local/bin/tflint
18:18:14 [DEBUG] go-plugin@v1.6.1/client.go:1216: tflint: 18:18:14 [DEBUG] go-plugin@v1.6.1/server.go:419: plugin address: network=unix address=/tmp/plugin191908899
18:18:14 [DEBUG] go-plugin@v1.6.1/client.go:880: using plugin: version=11
18:18:14 [DEBUG] host2plugin/client.go:124: starting host-side gRPC server
18:18:14 [DEBUG] go-plugin@v1.6.1/client.go:1216: tflint: 18:18:14 [ERROR] interceptor/logging.go:18: failed to gRPC request: direction=host2plugin method=/proto.RuleSet/Check err="rpc error: code = Aborted desc = failed to check \"terraform_deprecated_index\" rule: import.tf.json:1,1-2: Incorrect JSON value type; A JSON object is required here, setting the arguments for this block., and 4 other diagnostic(s)"
18:18:14 [DEBUG] go-plugin@v1.6.1/grpc_stdio.go:142: stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
18:18:14 [INFO]  go-plugin@v1.6.1/client.go:780: plugin process exited: plugin=/usr/local/bin/tflint id=88738
18:18:14 [DEBUG] go-plugin@v1.6.1/client.go:558: plugin exited
Failed to check ruleset; failed to check "terraform_deprecated_index" rule: import.tf.json:1,1-2: Incorrect JSON value type; A JSON object is required here, setting the arguments for this block., and 4 other diagnostic(s)

TFLint Version

0.53.0

Terraform Version

No response

Operating System

  • Linux
  • macOS
  • Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions