orange-cloudfoundry / terraform-provider-cloudfoundry

A terraform provider to manage a Cloud Foundry instance.
Apache License 2.0
31 stars 8 forks source link

cloudfoundry_quota creates space quotas even when org_id is defined, and quota unassigned #40

Open gberche-orange opened 6 years ago

gberche-orange commented 6 years ago

This is variation of #34

The cloudfoundry_quota documentation mentions

org_id: (Optional, default: null) If set to an organization id created from resource or data source cloudfoundry_organization, it will be considered as organization quota, else it will be a space quota.

Given the following specs (note the org is NOT referencing the quota as instructed in the organization documentation):

resource "cloudfoundry_organization" "org-orange-private-sandboxes" {
  name = "orange-private-sandboxes"
}

resource "cloudfoundry_quota" "quota_org-orange-private-sandboxes" {
  name                     = "tf_orange-private-sandboxes"
  org_id                   = "${cloudfoundry_organization.org-orange-private-sandboxes.id}"
  total_memory             = "30G"
  instance_memory          = "30G"
  routes                   = 2000
  service_instances        = 400
  app_instances            = 400
  allow_paid_service_plans = true
  reserved_route_ports     = 0
}

then the tf apply succeeds

cloudfoundry_quota.quota_org-orange-private-sandboxes: Creating...
  allow_paid_service_plans: "" => "true"
  app_instances:            "" => "400"
  instance_memory:          "" => "30G"
  name:                     "" => "tf_orange-private-sandboxes"
  org_id:                   "" => "6c5ea025-074d-4b41-8c0d-fc7924782f57"
  reserved_route_ports:     "" => "0"
  routes:                   "" => "2000"
  service_instances:        "" => "400"
  total_memory:             "" => "30G"

but actually creates a space quota, and not an org quota:

cf t
api endpoint:   https://api.redacted
api version:    2.102.0
user:           redacted
org:            orange-private-sandboxes

$ cf space-quotas
Getting space quotas as redacted...
OK

name                          total memory   instance memory   routes   service instances   paid plans   app instances   route ports
tf_orange-private-sandboxes   30G           30G              2000     400                 allowed      400             0

$ cf quotas | grep private