Juniper / terraform-provider-apstra

Apstra Terraform Provider
Apache License 2.0
15 stars 2 forks source link

Exactly one of `allocated_from` and `integer_value` must be set when `type` is set to "integer" for 'apstra_freeform_resource' #828

Open ihadi581 opened 2 months ago

ihadi581 commented 2 months ago

if using apstra 0.68.2-0.68.3, this issue not facing but after upgrade with new version provider issue facing.

this tf file

resource "apstra_freeform_resource" "vni_dc1_2" {
  blueprint_id  = apstra_freeform_blueprint.dc1.id
  name          = "vni"
  type          = "integer"
  group_id      = apstra_freeform_resource_group.Internet_400.id
  allocated_from = apstra_freeform_allocation_group.vni_allocation.id
  integer_value = "400"
}

output :

terraform plan 
╷
│ Error: invalid configuration
│ 
│   with apstra_freeform_resource.vni_dc1_2,
│   on vlans-generate.tf line 65, in resource "apstra_freeform_resource" "vni_dc1_2":
│   65: resource "apstra_freeform_resource" "vni_dc1_2" {
│ 
│ Exactly one of `allocated_from` and `integer_value` must be set when `type` is set to "integer"
╵

which we expect we can add manual integer value of allocated data, because apstra UI can use this method, to adopt flexibility

bwJuniper commented 2 months ago

We don't exactly copy the GUI in all terraform resources. In this case if you want to specify a value and not use a generated resource, you will need to remove the resource generator from the resource specification.

ihadi581 commented 2 months ago

can make allocated_from optional mode ?

bwJuniper commented 2 months ago

The code is not written that way. We would have to rewrite the code. There should be no reason to specify allocated from if you want to manually set the resource.

chrismarget-j commented 2 months ago

@bwJuniper I thought we tested this, and found that when specifying both an "allocated_from" and an "override" value, that the value was not pulled from the "allocated_from" ... thing.

But I've just tested it (with an integer pool), and found that the integer pool had one fewer integers after I created the resource, so long as the "override" value was within range.

We may need to revisit these experiments.

bwJuniper commented 2 months ago

Certainly can re-visit. We made simple choices to get the functionality out. We can make it more complex. I like to keep things simple but if there is a use case/reason then I am up for it.