cloudfoundry / terraform-provider-cloudfoundry

Terraform provider to manage Cloud Foundry resources using v3 APIs
https://registry.terraform.io/providers/cloudfoundry/cloudfoundry/latest
Apache License 2.0
7 stars 3 forks source link

[FEATURE] Support CF_TRACE environment variable #91

Open mogul opened 2 days ago

mogul commented 2 days ago

What area do you want to see improved?

terraform provider

Is your feature request related to a problem? Please describe.

When I apply a seemingly-reasonable terraform plan only to then see opaque, API-relevant errors from the provider, I'm not sure what I'm doing wrong.

Describe the solution you would like

I would like the provider to respect the CF_TRACE=true environment variable, so that I can see what API calls the provider is making.

Describe alternatives you have considered

I tried using TF_LOG=DEBUG but the output was not helpful since it didn't tell me anything about what the provider was actually doing, only the parts that Terraform cares about.

Additional context

In this particular case, I was seeing:

│ Error: Error pushing app
│ 
│   with module.spiff.cloudfoundry_app.connector,
│   on ../main.tf line 134, in resource "cloudfoundry_app" "connector":
│  134: resource "cloudfoundry_app" "connector" {
│ 
│ error while waiting for app spiffworkflow-connector package to build: received state FAILED while waiting for async process
╵

The actual problem was that I was pushing a docker image using a bad imageref, and staging was failing with a 403. Setting CF_TRACE=true might not have revealed that was the problem, but it was something I tried along the way, and I was surprised that it didn't work.

Similarly, I was seeing:

│ Error: API Error in creating managed service instance
│ 
│   with module.spiff.cloudfoundry_service_instance.database,
│   on ../main.tf line 24, in resource "cloudfoundry_service_instance" "database":
│   24: resource "cloudfoundry_service_instance" "database" {
│ 
│ Unable to create service instance spiffworkflow-database: executing POST request for /v3/service_instances failed: cfclient error (CF-UnprocessableEntity|10008): Invalid
│ space. Ensure that the space exists and you have access to it.

The actual problem was that cloudfoundry_service_instance wants the space attribute to be the .id (GUID) for the space, not the name, which is what I supplied. It would be good to get a "that doesn't look like a GUID" hint. Or, to be consistent, cloudfoundry_service_instance could optionally accept org_name + space_name in lieu of space, with behavior similar to cloudfoundry_app: it expects names attributes for its target org and space and looks up the GUID transparently.

github-actions[bot] commented 2 days ago

Thanks for the feature request. We evaluate it and update the issue accordingly.

Community Note

Voting for Prioritization

Volunteering to Work on This Issue