Open akocbek opened 1 year ago
The problem was mis-configured module code. The wrong commit https://github.ibm.com/GoldenEye/redis-module/pull/9/commits/2631f6cc4d011725830f042151bf0bdb9b6a2ec6 Closing the issue
Reopen this issue as similar event encountered in the "client-to-site-vpn". The error which I am getting is the following:
2022/11/28 12:49:06 [INFO] This template doesn't have any modules and hence no modules are downloaded for .
panic: interface conversion: interface {} is float64, not int
goroutine 1 [running]:
github.com/IBM-Cloud/terraform-config-inspect/tfconfig.ExtractVariableMetadata(0xc000083080, 0x13317e0, 0xc000eb20f0, 0xc0000b6240, 0x11, 0xc0000b8a70, 0x7)
github.com/IBM-Cloud/terraform-config-inspect/tfconfig/load.go:566 +0x1407
github.com/IBM-Cloud/terraform-config-inspect/tfconfig.findVariableMetadataFromResourceOrDatasource(0x13796d1, 0x8, 0xc0000f8de0, 0xc0000f8d20, 0xc0000f8750)
github.com/IBM-Cloud/terraform-config-inspect/tfconfig/load.go:505 +0x3bf
github.com/IBM-Cloud/terraform-config-inspect/tfconfig.LoadIBMModule(0x137868f, 0x1, 0x205883963, 0x63, 0xc000b7dd70, 0x13ec428, 0xc0000f8cf0, 0xc0000b3cd0, 0x12fcab4)
github.com/IBM-Cloud/terraform-config-inspect/tfconfig/load.go:98 +0x43f
github.com/IBM-Cloud/terraform-config-inspect/tfconfig.CheckForInitDirectoryAndLoadIBMModule(0x137868f, 0x1, 0x205883963, 0x63, 0x0, 0x0, 0x0, 0x60)
github.com/IBM-Cloud/terraform-config-inspect/tfconfig/load.go:50 +0x43d
main.main()
github.com/IBM-Cloud/terraform-config-inspect/main.go:33 +0xe5
For the given code
locals {
# Check subnet_ids has minimum 1 value in the standalone mode, and 2 values in the high availability mode.
min_subnet_ids = var.is_ha_enabled == true ? (length(var.subnet_ids) >= 2 ? true : false) : (length(var.subnet_ids) >= 1 ? true : false)
# Pass first 2 subnet IDs if High Availability is enabled. Otherwise just the first subnet ID.
subnet_ids = var.is_ha_enabled == true && local.min_subnet_ids == true ? slice(var.subnet_ids, 0, 2) : slice(var.subnet_ids, 0, 1)
}
# Client to Site VPN
resource "ibm_is_vpn_server" "vpn" {
certificate_crn = var.server_cert_crn
client_authentication {
method = var.client_auth_methods
identity_provider = var.client_auth_methods == "username" ? "iam" : null
client_ca_crn = var.client_auth_methods == "certificate" ? var.client_ca : null
}
client_idle_timeout = var.client_idle_timeout
client_ip_pool = var.client_ip_pool
enable_split_tunneling = var.enable_split_tunneling
name = var.vpn_gateway_name
subnets = var.subnet_ids
resource_group = var.resource_group_id
}
Here in the resource "vpn" if I set subnets = local.subnet_ids
it works fine, but when I change that to subnets = var.subnet_ids
then it generates empty module metadata and throws the panic error.
The value for var.subnet_ids is
variable "subnet_ids" {
type = list(string)
description = "List must have at least 1 subnet ID for standalone VPN and at least 2 subnet IDs for the High Availability mode."
default = []
}
Working commit: https://github.ibm.com/GoldenEye/client-to-site-vpn-module/pull/161/commits/0540db9f8e6d8d3c08feb1f0c43aa4bae5e57a3d
Current commit (failed): https://github.ibm.com/GoldenEye/client-to-site-vpn-module/pull/161/commits/68dd1aafc2d6b2257e236ad85d4179044e3eec4d
UPDATE: Locally, I am able to encounter the same issue even when there wasn't any local block. In the VPN resource if subnet ids are referenced to var.subnet_ids
it fails.
One of our repo (Redis module) has problems to use
terraform-config-inspect
tool with IBM provider. If we runterraform-config-inspect --json > metadata.json
without specifying metadata provider then metadata.json is created with values and everything works fine.when metadata provider is included then we get the following error and
metadata.json
is empty fileError
Steps to reproduce: