Closed janritter closed 3 years ago
I want to create a rule which iterates over all resources and checks if their style matches the convention. While testing I found out that tflint runs into a segmentation violation when no terraform remote state backend is configured.
My test rule: https://github.com/janritter/tflint-ruleset-codestyle/blob/ec319421144054006fc888266fe88347e3e02f38/rules/terraform_this.go#L39
When I execute tflint with my test rule against this terraform definition:
resource "aws_s3_bucket" "wrong_name" { bucket = "my-tf-test-bucket" acl = "private" }
The following error is thrown:
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x188f3da] goroutine 860 [running]: github.com/terraform-linters/tflint/plugin.(*Server).encodeBackend(0xc00040e380, 0x0, 0xc00098d7e0) /private/tmp/tflint-20210110-4829-12nifkt/tflint-0.23.1/plugin/encode.go:271 +0x3a github.com/terraform-linters/tflint/plugin.(*Server).encodeModule(0xc00040e380, 0xc0004c13b0, 0x21fd0c0) /private/tmp/tflint-20210110-4829-12nifkt/tflint-0.23.1/plugin/encode.go:94 +0xea7 github.com/terraform-linters/tflint/plugin.(*Server).encodeConfig(0xc00040e380, 0xc0002bbba0, 0x0) /private/tmp/tflint-20210110-4829-12nifkt/tflint-0.23.1/plugin/encode.go:21 +0x5b github.com/terraform-linters/tflint/plugin.(*Server).Config(0xc00040e380, 0x36ad8c0, 0xc00040e7e0, 0x0, 0x0) /private/tmp/tflint-20210110-4829-12nifkt/tflint-0.23.1/plugin/server.go:101 +0x36 reflect.Value.call(0xc0008da4e0, 0xc0000eaac0, 0x13, 0x270d83b, 0x4, 0xc00008ff08, 0x3, 0x3, 0xc0009523c0, 0x29dce00, ...) /usr/local/Cellar/go/1.15.6/libexec/src/reflect/value.go:476 +0x8c7 reflect.Value.Call(0xc0008da4e0, 0xc0000eaac0, 0x13, 0xc0008b4f08, 0x3, 0x3, 0xc0009523c0, 0x3577868, 0xc0009cd680) /usr/local/Cellar/go/1.15.6/libexec/src/reflect/value.go:337 +0xb9 net/rpc.(*service).call(0xc0005dfe00, 0xc0008c1720, 0xc0000e1578, 0xc0000e1590, 0xc00015f300, 0xc00040e420, 0x21fd080, 0x36ad8c0, 0x16, 0x21fd0c0, ...) /usr/local/Cellar/go/1.15.6/libexec/src/net/rpc/server.go:377 +0x189 created by net/rpc.(*Server).ServeCodec /usr/local/Cellar/go/1.15.6/libexec/src/net/rpc/server.go:474 +0x445
resource "aws_s3_bucket" "wrong_name" { bucket = "my-tf-test-bucket" acl = "private" } terraform { backend "s3" { region = "eu-central-1" bucket = "my-bucket" key = "my-project/s3/terraform.tfstate" dynamodb_table = "terraform-state-lock" } }
My rule is returning the test error as expected:
Failed to check ruleset. An error occurred: Error: Failed to check `terraform_resource_name_this` rule: End of check
Fixed in TFLint v0.24.0 and SDK v0.8.0
I want to create a rule which iterates over all resources and checks if their style matches the convention. While testing I found out that tflint runs into a segmentation violation when no terraform remote state backend is configured.
My test rule: https://github.com/janritter/tflint-ruleset-codestyle/blob/ec319421144054006fc888266fe88347e3e02f38/rules/terraform_this.go#L39
Without backend configuration
When I execute tflint with my test rule against this terraform definition:
The following error is thrown:
With backend configuration
When I execute tflint with my test rule against this terraform definition:
My rule is returning the test error as expected: