terraform-provider-cloudfoundry icon indicating copy to clipboard operation
terraform-provider-cloudfoundry copied to clipboard

Get nested credentials from service key (data and resource)

Open LukasHeimann opened this issue 4 years ago • 0 comments

Hi everyone,

I'm currently trying to create a terraform module based on your great provider!

One thing I try to do involves passing around credentials of service keys. One of my requirements is to keep them unmodified. However, I noticed that the (nested) json is flattened by the provider ("normalized")

  • https://github.com/cloudfoundry-community/terraform-provider-cloudfoundry/blob/master/cloudfoundry/utils_map.go#L33
  • https://github.com/cloudfoundry-community/terraform-provider-cloudfoundry/blob/master/cloudfoundry/data_source_cf_service_key.go#L54
  • https://github.com/cloudfoundry-community/terraform-provider-cloudfoundry/blob/master/cloudfoundry/resource_cf_service_key.go#L79

I found this old issue explaining why this behavior was necessary in the past: https://github.com/cloudfoundry-community/terraform-provider-cloudfoundry/issues/11 Unfortunately, there is no way to work back to the nested form, as the delimiter _ can (and in my case does) appear in one of the json keys inside the credentials.

Since 2019, it seems, nested maps are supported by terraform: https://github.com/hashicorp/terraform/blob/v0.12/CHANGELOG.md#new-features

Would it be possible to add in a way to get the unflattened credentials from a service key? Looking at the original change to support flattening (https://github.com/cloudfoundry-community/terraform-provider-cloudfoundry/commit/a4dd617190ee2de391e54d592a8b5357fde12a33), this would be rather straightforward.

Thank you very much for your support and kind regards Lukas

LukasHeimann avatar Dec 21 '21 13:12 LukasHeimann