Skip to content

Commit d434774

Browse files
committed
Updates based on style guide
Signed-off-by: Michael Ethridge <[email protected]>
1 parent 103c4c9 commit d434774

File tree

7 files changed

+89
-29
lines changed

7 files changed

+89
-29
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ repos:
99
pass_filenames: false
1010
stages: ["commit", "push"]
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
12-
rev: v4.5.0
12+
rev: v4.6.0
1313
hooks:
1414
- id: check-merge-conflict
1515
- id: end-of-file-fixer
1616
- repo: https://github.com/antonbabenko/pre-commit-terraform
17-
rev: v1.83.6
17+
rev: v1.88.4
1818
hooks:
1919
- id: terraform_fmt
2020
- id: terraform_validate

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Template repo for Terraform modules
22

33
This repository contains my template for creating Terraform modules, yes even my
4-
root modules.
4+
root modules. This template is based on the best practices I have learned and
5+
the
6+
[HashiCorp style guide](https://developer.hashicorp.com/terraform/language/style).
57

68
## Tools that I use
79

@@ -49,13 +51,14 @@ commit process.
4951
JSON processor. required for `terraform_validate` with
5052
`--retry-once-with-cleanup` flag, and for `infracost_breakdown` hook.
5153
- `brew install jq`
54+
- [TFLint](https://github.com/terraform-linters/tflint): A Terraform linter that
55+
checks for best practices and errors in your Terraform code.
56+
- `brew install tflint`
5257
- One or more of these terraform security scanning tools
5358
- [checkov](https://github.com/bridgecrewio/checkov)
5459
- `brew install checkov`
5560
- [terrascan](https://github.com/tenable/terrascan)
5661
- `brew install terrascan`
57-
- [TFLint](https://github.com/terraform-linters/tflint)
58-
- `brew install tflint`
5962
- [TFSec](https://tfsec.dev)
6063
- `brew install tfsec`
6164

backend.tf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
###############################################################################
2+
# backend.tf
3+
#
4+
# Contains your backend configuration
5+
###############################################################################
6+
7+
# Documentation
8+
# https://developer.hashicorp.com/terraform/language/settings/backends/configuration
9+
10+
# terraform {
11+
# backend "remote" {
12+
# organization = "example_corp"
13+
14+
# workspaces {
15+
# name = "my-app-prod"
16+
# }
17+
# }
18+
# }
19+
20+
# Terraform Cloud storage block for CLI driven
21+
# https://developer.hashicorp.com/terraform/language/settings/terraform-cloud
22+
23+
# terraform {
24+
# cloud {
25+
# organization = "example_corp"
26+
# ## Required for Terraform Enterprise; Defaults to app.terraform.io for Terraform Cloud
27+
# hostname = "app.terraform.io"
28+
29+
# workspaces {
30+
# tags = ["app"]
31+
# }
32+
# }
33+
# }

outputs.tf

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
############################
1+
###############################################################################
22
# outputs.tf
33
#
4-
# Module outputs
5-
############################
4+
# Module outputs in alphabetical order
5+
###############################################################################
6+
7+
# output "web_public_ip" {
8+
# description = "Public IP of the web instance"
9+
# value = aws_instance.web.public_ip
10+
# sensitive = true
11+
# }

providers.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
###############################################################################
2+
# providers.tf
3+
#
4+
# Contains all provider blocks and configuration.
5+
###############################################################################
6+
7+
provider "google" {
8+
# Configuration options
9+
# Environment variables needed for auth
10+
# GOOGLE_OAUTH_ACCESS_TOKEN="..."
11+
# GOOGLE_PROJECT="..."
12+
# GOOGLE_REGION="..."
13+
# GOOGLE_ZONE="..."
14+
}
15+
16+
provider "hcp" {
17+
# Configuration options
18+
# Environment variables needed for auth
19+
# HCP_CLIENT_ID="..."
20+
# HCP_CLIENT_SECRET="..."
21+
}

terraform.tf

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
###############################################################################
22
# terraform.tf
33
#
4-
# Terraform and Provider blocks
4+
# Contains a single terraform block which defines your required_version and
5+
# required_providers.
56
###############################################################################
67

78
terraform {
@@ -17,19 +18,3 @@ terraform {
1718
}
1819
}
1920
}
20-
21-
provider "google" {
22-
# Configuration options
23-
# Environment variables needed for auth
24-
# GOOGLE_OAUTH_ACCESS_TOKEN="..."
25-
# GOOGLE_PROJECT="..."
26-
# GOOGLE_REGION="..."
27-
# GOOGLE_ZONE="..."
28-
}
29-
30-
provider "hcp" {
31-
# Configuration options
32-
# Environment variables needed for auth
33-
# HCP_CLIENT_ID="..."
34-
# HCP_CLIENT_SECRET="..."
35-
}

variables.tf

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
###############################################################################
22
# variables.tf
33
#
4-
# Variable definitions
4+
# Contains all variable blocks in alphabetical order
5+
#
6+
# Two groups Required (no default values)
7+
# Optional (has a default value)
58
###############################################################################
69

10+
###############################################################################
711
# Required Variables (no default values)
8-
# variable "environment" {
12+
###############################################################################
13+
# variable "image_id" {
914
# type = string
10-
# description = "Application Environment (dev|prod)"
15+
# description = "The id of the machine image (AMI) to use for the server."
16+
17+
# validation {
18+
# condition = length(var.image_id) > 4 && substr(var.image_id, 0, 4) == "ami-"
19+
# error_message = "The image_id value must be a valid AMI id, starting with \"ami-\"."
20+
# }
1121
# }
1222

13-
# Variables with Defaults
23+
###############################################################################
24+
# Optional Variables (has a default value)
25+
###############################################################################
1426
# variable "instance_type" {
1527
# type = string
1628
# description = "Instance Type"

0 commit comments

Comments
 (0)