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.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay