Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform provider crashes when running terraform.modules {*} #3377

Closed
scottford-io opened this issue Feb 21, 2024 · 1 comment · Fixed by #3433
Closed

Terraform provider crashes when running terraform.modules {*} #3377

scottford-io opened this issue Feb 21, 2024 · 1 comment · Fixed by #3433
Assignees
Labels
bug Something isn't working terraform

Comments

@scottford-io
Copy link
Contributor

Describe the bug

terraform.modules {*}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x1010317b0]

goroutine 97 [running]:
go.mondoo.com/cnquery/v10/providers/terraform/resources.(*mqlTerraformBlock).MqlID(0x101ee7060?)
        /home/runner/_work/cnquery/cnquery/providers/terraform/resources/terraform.lr.go:1152
go.mondoo.com/cnquery/v10/llx.resource2result({0x1015298e0?, 0x0?}, {0x140003f2950, 0x10})
        /home/runner/_work/cnquery/cnquery/llx/data_conversions.go:321 +0x58
go.mondoo.com/cnquery/v10/llx.raw2primitive({0x1015298e0, 0x0}, {0x140003f2950, 0x10})
        /home/runner/_work/cnquery/cnquery/llx/data_conversions.go:352 +0x14c
go.mondoo.com/cnquery/v10/llx.(*RawData).Result(0x1400074d618)
        /home/runner/_work/cnquery/cnquery/llx/data_conversions.go:377 +0x7c
go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin.(*TValue[...]).ToDataRes(0x101211e88?, {0x140003f2950?, 0x10104b448?})
        /home/runner/_work/cnquery/cnquery/providers-sdk/v1/plugin/runtime.go:214 +0x1b0
go.mondoo.com/cnquery/v10/providers/terraform/resources.init.func30({0x10158a080?, 0x140005dd6c0?})
        /home/runner/_work/cnquery/cnquery/providers/terraform/resources/terraform.lr.go:232 +0x74
go.mondoo.com/cnquery/v10/providers/terraform/resources.GetData({0x10158a080, 0x140005dd6c0}, {0x14000456038, 0x5}, 0x1400073a050?)
        /home/runner/_work/cnquery/cnquery/providers/terraform/resources/terraform.lr.go:389 +0x130
go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin.(*Service).GetData(0x10143e720?, 0x1400024e070)
        /home/runner/_work/cnquery/cnquery/providers-sdk/v1/plugin/service.go:139 +0x290
go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin.(*GRPCServer).GetData(0x101ee6700?, {0x1014b3b20?, 0x14000742988?}, 0x100b19774?)
        /home/runner/_work/cnquery/cnquery/providers-sdk/v1/plugin/grpc.go:129 +0x2c
go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin._ProviderPlugin_GetData_Handler({0x1014b3b20, 0x140000a2c80}, {0x101592418, 0x1400071c210}, 0x14000744000, 0x0)
        /home/runner/_work/cnquery/cnquery/providers-sdk/v1/plugin/plugin_grpc.pb.go:299 +0x1c0
google.golang.org/grpc.(*Server).processUnaryRPC(0x140000e5c00, {0x101592418, 0x1400071c180}, {0x10159a150, 0x140001bc4e0}, 0x1400072a000, 0x1400009f9e0, 0x101f0b690, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1385 +0xb40
google.golang.org/grpc.(*Server).handleStream(0x140000e5c00, {0x10159a150, 0x140001bc4e0}, 0x1400072a000)
        /home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1796 +0xc00
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        /home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1029 +0x8c
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 9
        /home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1040 +0x13c
x plugin process exited error="exit status 2" id=20326 plugin=/Users/scottford/.config/mondoo/providers/terraform/terraform
2 errors occurred:
        * the 'terraform' provider crashed: rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial unix /var/folders/0h/g13vfqvn2xq7gxj9gdn1z33r0000gn/T/plugin1513657310: connect: connection refused"
        * the 'terraform' provider crashed: rpc error: code = Unavailable desc = error reading from server: EOF
terraform.modules: [
  0: {
    key: ""
    version: ""
    block: terraform.block type="module" labels=[
      0: "linux_sg"
    ]
    dir: "."
    source: ""
  }
  1: {
    key: the 'terraform' provider crashed: rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial unix /var/folders/0h/g13vfqvn2xq7gxj9gdn1z33r0000gn/T/plugin1513657310: connect: connection refused"
    version: the 'terraform' provider crashed: rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial unix /var/folders/0h/g13vfqvn2xq7gxj9gdn1z33r0000gn/T/plugin1513657310: connect: connection refused"
    block: the 'terraform' provider crashed: rpc error: code = Unavailable desc = error reading from server: EOF
    dir: the 'terraform' provider crashed: rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial unix /var/folders/0h/g13vfqvn2xq7gxj9gdn1z33r0000gn/T/plugin1513657310: connect: connection refused"
    source: the 'terraform' provider crashed: rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial unix /var/folders/0h/g13vfqvn2xq7gxj9gdn1z33r0000gn/T/plugin1513657310: connect: connection refused"
  }
  2: {
    key: the 'terraform' provider crashed: rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial unix /var/folders/0h/g13vfqvn2xq7gxj9gdn1z33r0000gn/T/plugin1513657310: connect: connection refused"
    version: the 'terraform' provider crashed: rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial unix /var/folders/0h/g13vfqvn2xq7gxj9gdn1z33r0000gn/T/plugin1513657310: connect: connection refused"
    block: the 'terraform' provider crashed: rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial unix /var/folders/0h/g13vfqvn2xq7gxj9gdn1z33r0000gn/T/plugin1513657310: connect: connection refused"
    dir: the 'terraform' provider crashed: rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial unix /var/folders/0h/g13vfqvn2xq7gxj9gdn1z33r0000gn/T/plugin1513657310: connect: connection refused"
    source: the 'terraform' provider crashed: rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial unix /var/folders/0h/g13vfqvn2xq7gxj9gdn1z33r0000gn/T/plugin1513657310: connect: connection refused"
  }
]

This was tested with cnspec 10.4.0

@scottford-io scottford-io added bug Something isn't working terraform labels Feb 21, 2024
@scottford-io
Copy link
Contributor Author

@arlimus code to reproduce...

module "project-factory" {
  source  = "terraform-google-modules/project-factory/google"
  version = "14.4.0"
}
  1. create a folder to work from and cd to that folder
  2. create maint.tf with above contents
  3. run terraform init
  4. start cnspec shell: cnspec shell terraform .
  5. run query: terraform.modules {*}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working terraform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants