lord-kyron / terraform-provider-phpipam

Terrform provider for PHPIPAM
https://registry.terraform.io/providers/lord-kyron/phpipam/latest
Apache License 2.0
54 stars 30 forks source link

phpipam_subnet can't set "is_folder" #20

Open ghost opened 4 years ago

ghost commented 4 years ago

Trying the following code

resource "phpipam_subnet" "folders" {
  subnet_address = "192.168.10.0"
  subnet_mask    = "24"
  description        = "Test"
  section_id     = 54
  is_folder      = true
}

Produces the following error, despite the documentation saying it's supported

Error: "is_folder": this field cannot be set

subnet_address and subnet_mask also don't make sense in this resource (as a folder), but are required for some reason.

pavel-z1 commented 4 years ago

I am confirm that issue exists. But solution is not trivial because PHPIPAM use different API endpoints to get folders and subnets list. For example, to get subnets:

curl -X GET http://phpipam.local/api/apiclient/subnets/[id]/

But, to get folders need:

curl -X GET http://phpipam.local/api/apiclient/folders/[id]/

As I see, current phpipam terraform provider code don't have logic to handle this. Need code refactoring to implement folders support.

lord-kyron commented 4 years ago

@pavel-z1 - do you think you can do this? Or it is too much work? I am asking to know if can implement it in some upcoming version or mark it as obsolete and continue with other stuff.

pavel-z1 commented 4 years ago

@lord-kyron it will take a lot of time. Would appreciate anyone willing to help with this feature.

lord-kyron commented 4 years ago

@pavel-z1 - I'm not developer, so I couldn't help but will try to find someone willing to help.

lord-kyron commented 3 years ago

@thefirstofthe300 and @rhysxevans- it seems that you are working with GO. Can you please, try to help here? @pavel-z1 needs help for fixing this and I am not actually GO developer.

lord-kyron commented 1 year ago

@pavel-z1 - do you still think this will be a lot of work? Or you will be able to fix that?

pavel-z1 commented 1 year ago

Hi @lord-kyron It is not simple here.

The problem not with creation of folder. The problem with phpipam subnet GET methods which does not return subnets with folder=1. For example, curl -X GET "http://10.10.0.1/api/terraform/subnets/all" will return all subnets, except subnets with folder=1.

To implement folders, must be added phpipam folder controlled in the SDK and here. Help is still needed here