DEV Community

Alexey Melezhik
Alexey Melezhik

Posted on

Sparrow plugin to lint Terraform scripts using tflint go utility

SYNOPSIS

Meet Sparrow plugin to lint Terraform scripts using tflint go utility.

Let's get started


Setup tom helper.

$ tom --edit tflint
Enter fullscreen mode Exit fullscreen mode
task-run "lint my code", "tflint", %(
 args => [
   "examples",
   [
     "force", 
     "no-color"
   ]
 ]
);
Enter fullscreen mode Exit fullscreen mode

Put your Terraform scripts to a directory.

# put your terraform code to `examples/` directory
$ mkdir examples
Enter fullscreen mode Exit fullscreen mode

Run it.

$ tom tflint
22:10:29 10/18/2020 [repository] index updated from file:///home/ubuntu/repo/api/v1/index
22:10:30 10/18/2020 [lint my code] os: linux
22:10:30 10/18/2020 [lint my code] run [/home/ubuntu/sparrow6/plugins/tflint/linux/tflint examples --force --no-color] ...
22:10:30 10/18/2020 [lint my code] 1 issue(s) found:
22:10:30 10/18/2020 [lint my code]
22:10:30 10/18/2020 [lint my code] Error: "t1.2xlarge" is an invalid value as instance_type (aws_instance_invalid_type)
22:10:30 10/18/2020 [lint my code]
22:10:30 10/18/2020 [lint my code]   on examples/example.tf line 3:
22:10:30 10/18/2020 [lint my code]    3:   instance_type = "t1.2xlarge" # invalid type!
22:10:30 10/18/2020 [lint my code]
Enter fullscreen mode Exit fullscreen mode

Args

See tflint documentation.

OS supported

  • linux

  • mac os

Author

Alexey Melezhik


That is it. Checkout new plugins on SparrowHub.io. I've been adding new stuff weekly.

Top comments (0)