Skip to content

Commit

Permalink
Update lint and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
toshi0607 committed Aug 28, 2022
1 parent 51eaf67 commit 2a8dae3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ Diffrent repository: [toshi0607/GKE-Microservices-Terraform-project-template](ht
### Chapter 8 Lint and validation

* [Lint and validation](./lint-and-validation/)
* [terraform fmt](./lint-and-validation/terraform-fmt)
* [terraform validate](./lint-and-validation/terraform-validate)
* [TFLint](./lint-and-validation/tflint)
* [Conftest](./lint-and-validation/conftest)
2 changes: 1 addition & 1 deletion lint-and-validation/conftest/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
provider "google" {
version = ">= 3.33.0"
version = ">= 4.32.0"
}

resource "google_project_service" "gcp_api_service" {
Expand Down
2 changes: 1 addition & 1 deletion lint-and-validation/conftest/policy/tf_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ no_violations {

test_provider_with_version_is_denied {
input := {
"provider": { { "version": ">= 3.33.0", "region": "somewhere" } }
"provider": { { "version": ">= 4.32.0", "region": "somewhere" } }
}
violations with input as input
}
Expand Down
4 changes: 2 additions & 2 deletions lint-and-validation/terraform-fmt/main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
resource "google_compute_instance" "tf_fmt_example" {
name = "tf-fmt-test"
machine_type = "f1-micro"
zone = "asia-northeast1-a"
zone = "asia-northeast1-c"

boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
image = "debian-cloud/debian-11"
}
}

Expand Down
4 changes: 2 additions & 2 deletions lint-and-validation/terraform-validate/main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
resource "google_compute_instance" "tf_validate_example" {
name = "tf-validate-test"
machine_type = "f1-micro"
zone = "asia-northeast1-a"
zone = "asia-northeast1-c"

boot_disk {
initialize_params = {
image = "debian-cloud/debian-9"
image = "debian-cloud/debian-11"
}
}

Expand Down
2 changes: 2 additions & 0 deletions lint-and-validation/tflint/.tflint.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugin "google" {
enabled = true
version = "0.19.0"
source = "github.com/terraform-linters/tflint-ruleset-google"
}

rule "google_compute_address_invalid_address_type" {
Expand Down
9 changes: 2 additions & 7 deletions lint-and-validation/tflint/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
```console
$ brew install tflint
$ git clone [email protected]:terraform-linters/tflint-ruleset-google.git
$ cd tflint-ruleset-google
$ make install

# Add .tflint.hcl

$ tflint --init
$ tflint
```
```
4 changes: 2 additions & 2 deletions lint-and-validation/tflint/main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
resource "google_compute_instance" "tflint_example" {
name = "tflint-test"
machine_type = "invalid-machine-type"
zone = "asia-northeast1-a"
zone = "asia-northeast1-c"

boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
image = "debian-cloud/debian-11"
}
}

Expand Down

0 comments on commit 2a8dae3

Please sign in to comment.