terraform-linters / tflint-ruleset-google

TFLint ruleset for terraform-provider-google
Mozilla Public License 2.0
70 stars 19 forks source link

compute instance type #12

Closed wyardley closed 4 years ago

wyardley commented 4 years ago

Not sure if this is related to https://github.com/terraform-linters/tflint-ruleset-google/pull/7, or if it's just a limitation of magic modules itself (the compute stuff being very old), but is it intended that this rule can validate compute instance types yet?

For example, something like this passes validation with tflint and the plugin, as best I can see:

resource "google_compute_instance" "foobar" {
  name         = "foobar"
  machine_type = "f1-microasdf"
  zone         = "us-central1"
}

from the same directory:

% tflint --loglevel=debug
15:33:34 config.go:93: [INFO] Load config: .tflint.hcl
15:33:34 config.go:105: [INFO] Default config file is not found. Ignored
15:33:34 config.go:114: [INFO] Load fallback config: /Users/wyardley/.tflint.hcl
15:33:34 config.go:122: [INFO] Fallback config file is not found. Ignored
15:33:34 config.go:124: [INFO] Use default config
15:33:34 option.go:54: [DEBUG] CLI Options
15:33:34 option.go:55: [DEBUG]   Module: false
15:33:34 option.go:56: [DEBUG]   DeepCheck: false
15:33:34 option.go:57: [DEBUG]   Force: false
15:33:34 option.go:58: [DEBUG]   IgnoreModules: map[string]bool{}
15:33:34 option.go:59: [DEBUG]   EnableRules: []string(nil)
15:33:34 option.go:60: [DEBUG]   DisableRules: []string(nil)
15:33:34 option.go:61: [DEBUG]   Only: []string(nil)
15:33:34 option.go:62: [DEBUG]   Varfiles: []string{}
15:33:34 option.go:63: [DEBUG]   Variables: []string{}
15:33:34 loader.go:57: [INFO] Initialize new loader
15:33:34 loader.go:82: [INFO] Load configurations under .
15:33:34 loader.go:90: [INFO] Module inspection is disabled. Building a root module without children...
15:33:34 loader.go:170: [INFO] Load values files
15:33:34 runner.go:52: [INFO] Initialize new runner for root
15:33:34 provider.go:87: [INFO] Prepare rules
15:33:34 provider.go:123: [INFO]   768 rules enabled
wata727 commented 4 years ago

Yes, the valid list of machine types is not included in the Magic Modules, so it is out of scope in v0.1.0. The difficulty is that GCP allows you to add custom machine types, so there is no single valid list. However, I plan to minimize false positives by allowing machine types that start with custom-.

Duplicate of #1

wyardley commented 4 years ago

Oh right. Good point. And thanks for getting this started, and for your work on tflint in general.