Using a linter for best practices on templates
Let’s describe a linter again. A linter is a tool that is used for static source code analysis to flag obvious programming errors and bugs, as well as stylistic and non-idiomatic issues. A linter generally operates on a set of predefined rules and style guides. CloudFormation has two linters available: cfn-lint
, a previous generation yet still maintained linter, written in Python, and cloudformation-guard
, a policy-based linter written in Rust. In this section, we will take a look at both and find out which one serves the best for our use cases.
Evaluating templates with cfn-lint
cfn-lint
is a command-line tool that inspects your template and compares the declared resources against a wide range of written rules.
Unlike the template validator, cfn-lint
can detect tricky issues such as missing resource properties or arguments in an intrinsic function.
CloudFormation’s linter is an external tool that can be installed...