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-cloudstack_v0.5.0 plugin crashed while trying to read datasource #118

Open
rakesh-p opened this issue May 31, 2024 · 1 comment

Comments

@rakesh-p
Copy link

rakesh-p commented May 31, 2024

I have a simple main.tf as follows that includes a data resource.
this plugin crashes when i run terraform plan
I have the correct values for api_key and secret as i could create a VM by not using "data resource"
What is that i am doing wrong please?

main.tf

terraform {
  required_version = ">= 1.6.6"
  required_providers {
    # Configure the CloudStack Provider
    cloudstack = {
      source  = "cloudstack/cloudstack"
      version = "0.5.0"
    }
  }
}

provider "cloudstack" {
  api_url    = "https://xxx.xxx.net/api"
  api_key    = "MY_KEY"
  secret_key = "MY_SECRET"
}


data "cloudstack_zone" "zone-data-source" {
  filter {
    name  = "regionid"
    value = 3
  }
}

terraform plan output:

data.cloudstack_zone.zone-data-source: Reading...

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Plugin did not respond
│ 
│   with data.cloudstack_zone.zone-data-source,
│   on versions.tf line 33, in data "cloudstack_zone" "zone-data-source":
│   33: data "cloudstack_zone" "zone-data-source" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadDataSource call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-cloudstack_v0.5.0 plugin:

panic: interface conversion: interface {} is nil, not string

goroutine 56 [running]:
github.com/terraform-providers/terraform-provider-cloudstack/cloudstack.applyZoneFilters(0xc000130448?, 0x114b50a?)
	github.com/terraform-providers/terraform-provider-cloudstack/cloudstack/data_source_cloudstack_zone.go:114 +0x28a
github.com/terraform-providers/terraform-provider-cloudstack/cloudstack.dataSourceCloudstackZoneRead(0x115f9d2?, {0x1019200?, 0xc0003d2500})
	github.com/terraform-providers/terraform-provider-cloudstack/cloudstack/data_source_cloudstack_zone.go:72 +0x16b
github.com/hashicorp/terraform/helper/schema.(*Resource).ReadDataApply(0xc000404280, 0xc0003a16c0, {0x1019200, 0xc0003d2500})
	github.com/hashicorp/[email protected]/helper/schema/resource.go:390 +0xc4
github.com/hashicorp/terraform/helper/schema.(*Provider).ReadDataApply(0xc000426000, 0xc0001998c8, 0xf996e0?)
	github.com/hashicorp/[email protected]/helper/schema/provider.go:442 +0x5e
github.com/hashicorp/terraform/helper/plugin.(*GRPCProviderServer).ReadDataSource(0xc00006c900, {0xc00053c4c0?, 0x4c21a6?}, 0xc00053c4c0)
	github.com/hashicorp/[email protected]/helper/plugin/grpc_provider.go:990 +0x2b1
github.com/hashicorp/terraform/internal/tfplugin5._Provider_ReadDataSource_Handler({0x10b9240?, 0xc00006c900}, {0x12ead38, 0xc0003daf60}, 0xc000531bd0, 0x0)
	github.com/hashicorp/[email protected]/internal/tfplugin5/tfplugin5.pb.go:3055 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000002480, {0x12ef698, 0xc000002000}, 0xc000144000, 0xc0004bf1a0, 0x19e0950, 0x0)
	google.golang.org/[email protected]/server.go:966 +0xe59
google.golang.org/grpc.(*Server).handleStream(0xc000002480, {0x12ef698, 0xc000002000}, 0xc000144000, 0x0)
	google.golang.org/[email protected]/server.go:1245 +0x987
google.golang.org/grpc.(*Server).serveStreams.func1.1()
	google.golang.org/[email protected]/server.go:685 +0x8d
created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 9
	google.golang.org/[email protected]/server.go:683 +0xd2

Error: The terraform-provider-cloudstack_v0.5.0 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

@kiranchavala
Copy link
Collaborator

Hi @rakesh-p The datasource is working fine

Please find the sample code

provider "cloudstack" {
  api_url    = var.cloudstack_api_url
  api_key    = var.cloudstack_api_key
  secret_key = var.cloudstack_secret_key

}


data "cloudstack_zone" "zone-data-source" {
  filter {
    name  = "name"
    value = "ref-trl-6530-k-Mol8-kiran-chavala"
  }
}


output "zonedetails" {
value = data.cloudstack_zone.zone-data-source.dns1
}

terraform apply

zonedetails = "10.0.32.1"

I could get the following zone details

name 
dns1 
internal_dns1 
network_type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants