github.com/terraform-linters/tflint@v0.51.2-0.20240520175844-3750771571b6/docs/developer-guide/plugins.md (about) 1 # Writing Plugins 2 3 If you want to add custom rules, you can write ruleset plugins. 4 5 ## Overview 6 7 Plugins are independent binaries and use [go-plugin](https://github.com/hashicorp/go-plugin) to communicate with TFLint over gRPC. TFLint executes the binary when the plugin is enabled, and the plugin process must act as an gRPC server for TFLint. 8 9 If you want to create a new plugin, [The template repository](https://github.com/terraform-linters/tflint-ruleset-template) is available to satisfy these specification. You can create your own repository from "Use this template" and easily add rules based on some reference rules. 10 11 The template repository uses the [SDK](https://github.com/terraform-linters/tflint-plugin-sdk) that wraps the go-plugin for communication with TFLint. See also the [Architecture](https://github.com/terraform-linters/tflint-plugin-sdk#architecture) section for the architecture of the plugin system. 12 13 ## 1. Creating a repository from the template 14 15 Visit [tflint-ruleset-template](https://github.com/terraform-linters/tflint-ruleset-template) and click the "Use this template" button. Repository name must be `tflint-ruleset-*`. 16 17 ## 2. Building and installing the plugin 18 19 The created repository can be installed locally with `make install`. Enable the plugin as follows and verify that the installed plugin works. 20 21 ```hcl 22 plugin "template" { 23 enabled = true 24 } 25 ``` 26 27 ```console 28 $ make install 29 go build 30 mkdir -p ~/.tflint.d/plugins 31 mv ./tflint-ruleset-template ~/.tflint.d/plugins 32 $ tflint -v 33 TFLint version 0.28.1 34 + ruleset.template (0.1.0) 35 ``` 36 37 ## 3. Changing/Adding the rules 38 39 Rename the ruleset and add/edit rules. After making changes, you can check the behavior with `make install`. See also the [tflint-plugin-sdk API reference](https://pkg.go.dev/github.com/terraform-linters/tflint-plugin-sdk) for communication with the host process. 40 41 ## 4. Creating a GitHub Release 42 43 You can build and install your own ruleset locally as described above, but you can also install it automatically with `tflint --init`. 44 45 The requirements to support automatic installation are as follows: 46 47 - The built plugin binaries must be published on GitHub Release 48 - The release must be tagged with a name like `v1.1.1` 49 - The release must contain an asset with a name like `tflint-ruleset-{name}_{GOOS}_{GOARCH}.zip` 50 - The zip file must contain a binary named `tflint-ruleset-{name}` (`tflint-ruleset-{name}.exe` in Windows) 51 - The release must contain a checksum file for the zip file with the name `checksums.txt` 52 - The checksum file must contain a sha256 hash and filename 53 54 When signing a release, the release must additionally meet the following requirements: 55 56 - The release must contain a signature file for the checksum file with the name `checksums.txt.sig` 57 - The signature file must be binary OpenPGP format 58 59 Releases that meet these requirements can be easily created by following the GoReleaser config in the template repository.