![]() Create a pre-commit config fileīelow is a copy of my config file: repos: - repo: rev: "v0.16.0" hooks: - id: terraform-docs-go args: If you follow the links above for the other tools, you will find instructions on installing these. Terraform fmt and validate are part of Terraform, so make sure to have this installed. Installing these tools before proceedingĪs the pre-commit will run locally, you must ensure you have these installed. Tfsec - TFSec reviews the config files for any security concerns based on best practices and reports to the user how to change them to resolve the error. Tflint - TFLint will check for errors and encourage best practices. Terraform validate - Terraform validate will check to ensure the configuration is correct based on HCL. Terraform fmt - Terraform format will structure your config files so it presents cleanly. Terraform_docs - This tool auto-generates readme files containing information on modules, providers and resources that gives users an easy-to-read and central page that can be digested faster than reading the code. Let's look at the hooks I use when working with Terraform: With PIP, install pre-commit using the following command: pip install pre-commit Using brew, install pre-commit using the following command: brew install pre-commit This is a shift left approach that will improve security and best practices in coding. If a tool finds any errors, for example a misconfiguration of a coding language, it will stop the commit from happening. You can set what tools to use to scan your local repository using a configuration file. Pre-commit operates as a git hook, commits triggering a set of tools to check your code. Yes, pre-commit can use in a broad range of scenarios, but I will be covering how to use it with Terraform. In this post, I will cover how I use the pre-commit tool to run checks locally when I try committing my Terraform code. You may even forget to run these, resulting in Pull Request checks failing. Manually running CLI commands to check your code before committing can be repetitive, slow, and drain your time. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |