cloudstack-terraform-provider icon indicating copy to clipboard operation
cloudstack-terraform-provider copied to clipboard

Error with regex using vpc datasource

Open ferdinandopaes opened this issue 10 months ago • 3 comments

Hello,

I am using the VPC datasource to retrieve the data. But I am receiving the following error:

Error: No VPC is matching with the specified regex

It occurs even when changing and using any other filter.

My main.tf

terraform {
  required_providers {
    cloudstack = {
        source  = "cloudstack/cloudstack"
        version = "0.5.0"
    }
  }
}

provider "cloudstack" {
  api_url     = "https://<my_cloudstack_url>/client/api"
  api_key     = "${var.cloudstack_api_key}"
  secret_key  = "${var.cloudstack_secret_key}"
}

variable "cloudstack_api_key" {
  description = "API KEY for CloudStack"
  type        = string
}

variable "cloudstack_secret_key" {
  description = "SECRET KEY for CloudStack"
  type        = string
}

My data.tf

data "cloudstack_vpc" "vpc" {
  filter{
    name  = "cidr"
    value = "10.25.0.0/16"
  }
  filter{
    name  = "name"
    value = "boilerplate"
  }
  filter{
    name = "project"
    value  = "boilerplate"
  }
}

I tried using the datasource with all the filters, but I also tried one filter at a time to identify any issues with the values.

ferdinandopaes avatar Mar 10 '25 14:03 ferdinandopaes

Hi @ferdinandopaes,

I tried reproducing it and the data sources don't actually list project resources, even the two (IpAddress and VPC) that have a project filter. They simply call their respective list APIs without any parameters. It seems simple enough to fix and I'll open a PR soon, if no one is already working on it.

But, for now, could you try with resources owned directly by accounts, not projects?

gpordeus avatar Mar 10 '25 23:03 gpordeus

Hi @gpordeus,

I tried retrieve data directly by accounts, with a vpc out of project and its work fine!!! Thanks for the workaround.

I'll waiting for the PR.

ferdinandopaes avatar Mar 11 '25 12:03 ferdinandopaes

@gpordeus are you working on a PR for this issue

kiranchavala avatar May 12 '25 08:05 kiranchavala

this seems to be addessed by #144

related work on project support: #167 #82

weizhouapache avatar Aug 26 '25 08:08 weizhouapache