scastria / terraform-provider-apigee

Mozilla Public License 2.0
22 stars 19 forks source link

Operation quota in apiee_product resource is not working as expected #58

Open GavinCS opened 2 years ago

GavinCS commented 2 years ago

Given the below terraform setting a quota on an operation results in the following errors

"operation.0.quota": all of `operation.0.quota,quota_interval,quota_time_unit` must be specified
"operation.0.quota_interval": all of `operation.0.quota_interval,quota,quota_time_unit` must be specified
"operation.0.quota_time_unit": all of `operation.0.quota_time_unit,quota,quota_interval` must be specified

Looking at resource_product line 49 I see RequiredWith is used, which I don't see in schema behaviours for the terraform sdkv2.

Not sure if this is where the issue lies?

resource "apigee_product" "product" {
  name               = "foo"
  display_name       = "FOO"
  auto_approval_type = true
  description        = "A product"
  environments = [
    "default
  ]

  attributes = {
    category   = "foo"
    access     = "public"
    rate-limit = "5ps"
    active     = true
  }

  operation {
      api_source = "some-proxy"
      path       = "/"
      methods    = ["GET", "POST", "OPTIONS"]
      quota           = 100000000
      quota_interval  = 1
      quota_time_unit = "day"
  }
}
│ 
│   with apigee_product.product,
│   on product.tf line 947, in resource "apigee_product" "product":
│  947:       quota           = 100000000
│ 
│ "operation.0.quota": all of `operation.0.quota,quota_interval,quota_time_unit` must be specified
╵
╷
│ Error: Missing required argument
│ 
│   with apigee_product.product,
│   on product.tf line 948, in resource "apigee_product" "product":
│  948:       quota_interval  = 1
│ 
│ "operation.0.quota_interval": all of `operation.0.quota_interval,quota,quota_time_unit` must be specified
╵
╷
│ Error: Missing required argument
│ 
│   with apigee_product.product,
│   on product.tf line 949, in resource "apigee_product" "product":
│  949:       quota_time_unit = "day"
│ 
│ "operation.0.quota_time_unit": all of `operation.0.quota_time_unit,quota,quota_interval` must be specified
ev-the-dev commented 1 year ago

@GavinCS Late response, sorry. If this is still an issue for you then try adding all the quota properties to the root "apigee_product" "product" block as well.

This probably merits some cleanup in the provider code to only move the quota variables inside of the operation schema, but it would be a breaking change as of now.