This repository contains my template for creating Terraform modules, yes even my root modules. This template is based on the best practices I have learned and the HashiCorp style guide.
I use a wide array of tools to make things easier for me.
brew install 1password
brew install 1password-cli
brew install direnv
brew install go-task
brew install hashicorp/tap/terraform
brew install git
git commit
process.
brew install pre-commit
brew install trufflesecurity/trufflehog/trufflehog
brew install pantheon-systems/autotag/autotag
All of these tools can be used standalone, but I use them as part of the git commit process.
brew install terraform-docs
brew install infracost
terraform_validate
with--retry-once-with-cleanup
flag, and for infracost_breakdown
hook.
brew install jq
brew install tflint
Here are a couple of tools I use to help with managing Terraform versions.
brew install warrensbox/tap/tfswitch
brew install tfupdate
brew install idoavrah/tap/tftui
I use Visual Studio Code as my code editor. I have included my settings and extensions in the .vscode directory, so they should be automatically installed when you open the project. They are also listed below.
I use the following extensions for VS Code.
I use the following settings for VS Code.
{
"[sentinel]": {
"editor.defaultFormatter": "hashicorp.terraform"
},
"[terraform]": {
"editor.defaultFormatter": "hashicorp.terraform"
},
"[tfvars]": {
"editor.defaultFormatter": "hashicorp.terraform"
},
"editor.bracketPairColorization.enabled": true,
"editor.formatOnSave": true,
"editor.rulers": [
{
"color": "#A5FF90",
"column": 80
},
{
"color": "#FF628C",
"column": 100
}
],
"editor.tabCompletion": "on",
"editor.tabSize": 2,
"files.associations": {
"*.hcl": "terraform",
"*.nomad": "terraform",
"*.policy": "sentinel"
},
"terraform.indexing": {
"delay": 500,
"enabled": false,
"exclude": [".terraform/**/*", "**/.terraform/**/*"],
"liveIndexing": false
},
"terraform.languageServer.enable": true
}
I've included example config files for some of the tools.
direnv
: Rename .envrc.example
to .envrc
and update.
pre-commit
: Review .pre-commit-config.yaml
to enable/disable hooks.
terraform-docs
: Review .terraform-docs.yml
to adjust document formatting
options.
TFLint
: Review .tflint.hcl
Task
: Review Taskfile.yaml
and or remove tasks.
Terraform
: Rename terraform.tfvars.example
to terraform.tfvars
and update.
Everything above this should be removed and replaced with your module description.
The following two lines specify where the terraform-docs
dynamic content will
be placed.
Name | Version |
---|---|
terraform | ~> 1.0 |
~>4.55 | |
hcp | ~>0.54 |
No providers.
No modules.
No resources.
No inputs.
No outputs.