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_domain fails to report domain creation failure #37

Open gberche-orange opened 6 years ago

gberche-orange commented 6 years ago

Given a domain declared such as the following which is in conflict with an existing domain visible in another org

resource "cloudfoundry_domain" "tf-preprod-system-domain" {
  name = "${var.cloudfoundry["system_domain"]}"
  org_owner_id = "${cloudfoundry_organization.tf-system_domain.id}"
}

Terraform plan properly displays the need to delete and create the resource:

-/+ cloudfoundry_domain.tf-preprod-system-domain (new resource required)
      id:                                "e9ced353-bb66-4d3b-8e03-2c33f4920db3" => <computed> (forces new resource)
      name:                              "nd-int-cfapi.mydomain.org" => "nd-int-cfapi.mydomain.org"
      org_owner_id:                      "612c1b99-e8df-4d58-8412-df7fa440290e" => "87505508-4c09-499e-933c-eb89582cb9a5" (forces new resource)

however the terraform apply silently completes with success:

cloudfoundry_domain.tf-preprod-system-domain: Creating...
  name:         "" => "nd-int-cfapi.mydomain.org"
  org_owner_id: "" => "87505508-4c09-499e-933c-eb89582cb9a5"
[...]
cloudfoundry_domain.tf-preprod-system-domain: Creation complete after 1s (ID: e9ced353-bb66-4d3b-8e03-2c33f4920db3)

while the equivalent Cf CLI command fails:

cf create-domain system_domain nd-int-cfapi.mydomain.org 
Creating domain nd-int-cfapi.mydomain.org for org system_domain as gberche...
FAILED
Server error, status code: 400, error code: 130003, message: The domain name is taken: nd-int-cfapi.mydomain.org

I did not finish checking the provider info traces that require https://github.com/orange-cloudfoundry/cf-ops-automation/issues/39 in our environment