This is a tflint plugin for enforcing UW rules over our kafka config.
You can install the plugin with tflint --init
. Declare a config in .tflint.hcl
as follows:
plugin "uw-kafka-config" {
enabled = true
version = "x.y.z"
source = "github.com/utilitywarehouse/tflint-ruleset-kafka-config"
}
Name | Description |
---|---|
msk_module_backend |
Requires an S3 backend to be defined, with a key that has as suffix the name of the team (taken from the current directory name) |
msk_app_topics |
Requires apps consume from and produce to only topics define in their module. |
msk_topic_name |
Requires defined topics in a module to belong to that team. |
msk_topic_config |
Checks the configuration for MSK topics |
msk_topic_config_comments |
Checks the comments for topic configurations expressed in millis |
msk_unique_app_names |
Checks that TLS app names are unique |
msk_app_consume_groups |
Checks that TLS app consume groups are prefixed with a team name |
Clone the repository locally and run the following command:
$ make
You can easily install locally the built plugin with the following:
$ make install
You can run the built plugin like the following:
$ cat << EOS > .tflint.hcl
plugin "kafka-config" {
enabled = true
}
EOS
$ tflint
For releasing the binaries for the plugin you just need to create a Github release named vx.y.z, like v0.1.0.
Goreleaser is used in the pipeline. See config
Linting is handled via pre-commit
. Follow the install
instructions then install the hooks:
$ pre-commit install
$ pre-commit run --all-hooks
If you're developing some rules and want to see how they run on some actual Terraform code you will need to.
-
Install your changes:
make install
-
Enable the plugin in the repo, if the plugin is already installed, be sure to remove references to source and version (other wise it will install from there):
plugin "uw-kafka-config" { enabled = true # comment this out if it exists, ensure we use the plugin # we just installed, and not building from upstream source #version = "1.1.0" #source = "github.com/utilitywarehouse/tflint-ruleset-kafka-config" }
-
Run the plugin
The plugin expects to be run from the directory containing the files you want you'll need to change directory first and make sure you pass the :
$ cd ./path/to/debug
$ tflint --config=$(git rev-parse --show-toplevel)/.tflint.hcl
To view more logs you can set set the TFLINT_DEBUG
environment
variable,
combining all in one line:
cd ./path/to/debug && TFLINT_LOG=debug tflint --config=$(git rev-parse --show-toplevel)/.tflint-msk.hcl ; cd -
Similarly if you want to debug the plugin via a pre-commit
hook (assuming the
hook has name terraform_tflint_msk
):
TFLINT_LOG=debug pre-commit run --verbose --files ./path/to/debug/*.tf -- terraform_tflint_msk