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 org quotas even when org_id is omitted #34

Open gberche-orange opened 6 years ago

gberche-orange commented 6 years ago

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.

Using the following terraform config

resource "cloudfoundry_quota" "tf_coab_smoketests_quota" {
  name = "tf_coab_smoketests_quota"
  total_memory = "2G"
  instance_memory = "2G"
  routes = 5
  service_instances = 15 #Restrict to 15
  app_instances = 5
  allow_paid_service_plans = true
  reserved_route_ports = 0
}

resource "cloudfoundry_space" "coa-cassandra-smoke-tests-space" {
  name = "coa-cassandra-smoke-tests"
  org_id = "${data.cloudfoundry_organization.org-service-sandbox.id}"
[...]  
  quota_id = "${cloudfoundry_quota.tf_coab_smoketests_quota.id}"
}

fails with the following message

cloudfoundry_quota.tf_coab_smoketests_quota: Creating...
  allow_paid_service_plans: "" => "true"
  app_instances:            "" => "5"
  instance_memory:          "" => "2G"
  name:                     "" => "tf_coab_smoketests_quota"
  reserved_route_ports:     "" => "0"
  routes:                   "" => "5"
  service_instances:        "" => "15"
  total_memory:             "" => "2G"

cloudfoundry_space.coa-cassandra-smoke-tests-space: Creating...
  allow_ssh:             "" => "true"
  name:                  "" => "coa-cassandra-smoke-tests"
  org_id:                "" => "a95b339c-c52f-4b7d-bc70-d0c57af38f73"
  sec_groups.#:          "0" => "2"
  sec_groups.1097534615: "" => "8df01522-a1c4-4c65-a213-1c7657a6fd6e"
  sec_groups.142526119:  "" => "ec556d93-acd8-49e2-a0e6-4f57bebde4c8"

cloudfoundry_quota.tf_coab_smoketests_quota: Creation complete after 0s (ID: 38d39477-eb72-4421-8f52-c155392de53c)

cloudfoundry_space.coa-cassandra-broker-space: Modifying... (ID: 43eaa3ef-50d1-45ef-8647-cb3a3c7af49c)
  quota_id: "" => "38d39477-eb72-4421-8f52-c155392de53c"

cloudfoundry_space.coa-cassandra-smoke-tests-space: Creation complete after 2s (ID: 0981269a-47d9-45a4-b1de-5bede572e86c)

Error: Error applying plan:

1 error(s) occurred:

* cloudfoundry_space.coa-cassandra-broker-space: 1 error(s) occurred:
* cloudfoundry_space.coa-cassandra-broker-space: Server error, status code: 404, error code: 310007, message: Space Quota Definition could not be found: 38d39477-eb72-4421-8f52-c155392de53c

leads to the generation of an org quota as not a space quota

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

$ cf quotas 
Getting quotas as xx...
OK

name                                        total memory   instance memory   routes   service instances   paid plans   app instances   route ports
[...]
tf_coab_smoketests_quota                    2G             2G                5        15                  allowed      5               0