terraform-linters / tflint-ruleset-google

TFLint ruleset for terraform-provider-google
Mozilla Public License 2.0
69 stars 20 forks source link

tf.json support #13

Closed freddd closed 3 years ago

freddd commented 3 years ago

Hi @wata727,

I was experimenting a bit with the plugin and tried to run it on a few tf.json files and got the following error message:

08:52:17 runner_walk.go:36: [DEBUG] Walk `google_storage_bucket_access_control.test.role` attribute
Failed to check ruleset. An error occurred:
Error: Failed to check `google_storage_bucket_access_control_invalid_role` rule: bla.tf.json:31,19-19: JSON configuration syntax is not supported;

I've been able to run tflint on AWS resources that are tf.json. Is the error message because the plugin is experimental?

Here is the tf.json file:

{
   "data": {
      "google_service_account": {
         "test": {
            "account_id": "test"
         }
      }
   },
   "resource": {
      "google_storage_bucket": {
         "bucket": {
            "location": "eu",
            "name": "bucket",
            "storage_class": "STANDARD",
            "versioning": {
               "enabled": true
            }
         }
      },
      "google_storage_bucket_iam_binding": {
         "viewer": {
            "members": [
               "serviceAccount:email"
            ],
            "role": "roles/storage.objectViewer"
         }
      },
      "google_storage_bucket_access_control": {
        "test": {
          "bucket": "test",
          "role": "DOESNTEXIST",
          "entity": "test"
        }
      }
   }
}
wata727 commented 3 years ago

Yes, the plugin system doesn't support JSON syntax now. See also https://github.com/terraform-linters/tflint-plugin-sdk/issues/32.

Fortunately, the changes needed to support this have recently been merged into hashicorp/hcl. Therefore, if the next HCL version is released and a Terraform that uses it is released, we will be able to support this.

freddd commented 3 years ago

Alright! Thanks for the quick reply, we'll keep an eye out for the next version. We are looking forward to using and contributing to tflint and the gcp plugin.