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

panic: value is null #1019

Closed
josh-barker opened this issue Sep 15, 2021 · 0 comments · Fixed by #1020
Closed

panic: value is null #1019

josh-barker opened this issue Sep 15, 2021 · 0 comments · Fixed by #1020
Assignees
Labels

Comments

@josh-barker
Copy link

  • terrascan version: v1.10.0

Description

terrascan scan

What I Did

Terraform module definition:

variable "name" {
  type = string
}

variable "location" {
  type = string
}

variable "resource_group_name" {
  type = string
}

variable "kind" {
  type    = string
  default = "StorageV2"
}

variable "tier" {
  type    = string
  default = "Standard"
}

variable "replication_type" {
  type    = string
  default = "GRS"
}

variable "network_rules" {
  type = object({
    default_action             = string
    bypass                     = list(string)
    ip_rules                   = list(string)
    virtual_network_subnet_ids = list(string)
  })
  default = {
    default_action             = "Deny"
    bypass                     = null
    ip_rules                   = []
    virtual_network_subnet_ids = []
  }
}

resource "azurerm_storage_account" "this" {
  name                = var.name
  resource_group_name = var.resource_group_name
  location            = var.location

  account_kind              = var.kind
  account_tier              = var.tier
  account_replication_type  = var.replication_type

  network_rules {
    default_action = var.network_rules.default_action
    bypass                     = var.network_rules.bypass
    ip_rules                   = var.network_rules.ip_rules
    virtual_network_subnet_ids = var.network_rules.virtual_network_subnet_ids
  }
}

I found if I commented out network_rules in the resource definition the panic error did not occur.

Stack Trace

panic: value is null

goroutine 16 [running]:
github.com/zclconf/go-cty/cty.Value.LengthInt(0x748b7b8, 0xc0003cac50, 0x0, 0x0, 0xc000fdd050)
        github.com/zclconf/[email protected]/cty/value_ops.go:1063 +0x28b
github.com/zclconf/go-cty/cty.Value.AsValueSlice(0x748b7b8, 0xc0003cac50, 0x0, 0x0, 0x203000, 0x203000, 0xc0000531d9)
        github.com/zclconf/[email protected]/cty/value_ops.go:1299 +0x9d
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.ctyToSlice(0x748b7b8, 0xc0003cac50, 0x0, 0x0, 0xc000c5cd50, 0x1a, 0xffffffffffffffff, 0x0)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/cty-converters.go:67 +0x85
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.convertComplexType(0x748b7b8, 0xc0003cac50, 0x0, 0x0, 0xc000fdd180, 0x40146e5, 0xc000fdd210, 0xc000c5cd50)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/cty-converters.go:143 +0x5e
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.convertCtyToGoNative(0x748b7b8, 0xc0003cac50, 0x0, 0x0, 0xc000c5ccf0, 0xc00025b660, 0x67e7e20, 0xc00025b670)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/cty-converters.go:127 +0xc5
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.ctyToMap(0x748b828, 0xc0003cae80, 0x6943600, 0xc0009b77a0, 0x0, 0x401815d, 0xc00072eb70, 0xc000136ea6)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/cty-converters.go:107 +0x193
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.convertComplexType(0x748b828, 0xc0003cae80, 0x6943600, 0xc0009b77a0, 0x0, 0xc000330f18, 0x0, 0xc000330ed0)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/cty-converters.go:145 +0xdd
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.convertCtyToGoNative(0x748b828, 0xc0003cae80, 0x6943600, 0xc0009b77a0, 0x1, 0x0, 0x0, 0x0)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/cty-converters.go:127 +0xc5
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.(*RefResolver).ResolveVarRef(0xc000fddb58, 0xc000136ea0, 0x2f, 0xc000136ea0, 0x2f, 0x67e7e20, 0xc00025b650)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/variable-references.go:83 +0x1b6
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.(*RefResolver).ResolveStrRef(0xc000fddb58, 0xc000136ea0, 0x2f, 0x0, 0x0, 0x10, 0x67e7720)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/references.go:180 +0x32b
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.(*RefResolver).ResolveRefs(0xc000fddb58, 0xc000c5ccc0, 0x11)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/references.go:72 +0x1bd
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.(*RefResolver).ResolveRefs(0xc000fddb58, 0xc000c5cc60, 0x1c)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/references.go:120 +0x85d
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.TerraformDirectoryLoader.loadDirRecursive(0xc00005a8c0, 0x40, 0x0, 0x7489838, 0xc0003e7a10, 0xc000627518, 0x0, 0xc0003e7a70, 0xc00064a200, 0x3, ...)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/load-dir.go:203 +0x95f
github.com/accurics/terrascan/pkg/iac-providers/terraform/commons.TerraformDirectoryLoader.LoadIacDir(0xc00005a8c0, 0x40, 0x0, 0x7489838, 0xc0003e7a10, 0xc000627518, 0x0, 0xc0003e7a70, 0x0, 0x0, ...)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/commons/load-dir.go:123 +0x2b5
github.com/accurics/terrascan/pkg/iac-providers/terraform/v15.(*TfV15).LoadIacDir(0x899fc18, 0xc00005a8c0, 0x40, 0xc0003e78c0, 0x0, 0x0, 0x0)
        github.com/accurics/terrascan/pkg/iac-providers/terraform/v15/load-dir.go:30 +0xb4
github.com/accurics/terrascan/pkg/runtime.(*Executor).getResourceConfigs.func1(0xc000376500, 0xc0003e78c0, 0xc00061e600, 0x11aa8e78, 0x899fc18)
        github.com/accurics/terrascan/pkg/runtime/executor.go:275 +0x59
created by github.com/accurics/terrascan/pkg/runtime.(*Executor).getResourceConfigs
        github.com/accurics/terrascan/pkg/runtime/executor.go:274 +0x1e5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants