Giter Club home page Giter Club logo

Comments (4)

DRuggeri avatar DRuggeri commented on July 20, 2024

This is actually a feature I would love to have (hence the caveat in the doco about the current limitation). To be honest, I don't know if it is possible and would appreciate any research you can share. My assumption is that to be able to have a compound type in Terraform, the structure of that type must be known ahead of time in the provider declaration with Terraform. I make this assumption because I haven't seen a complex, dynamic object in other providers yet.

Relevant link - This validation method for objects requires all keys to be known:
https://github.com/hashicorp/terraform/blob/master/helper/schema/schema.go#L1507

from terraform-provider-restapi.

rberlind avatar rberlind commented on July 20, 2024

Thanks. I will research. I work at HashiCorp and might be able to ask some Terraform experts.

from terraform-provider-restapi.

rberlind avatar rberlind commented on July 20, 2024

Hi @DRuggeri : I had a discussion with several members of the Terraform team about this today. They said this could not be done today with Terraform 0.11 because it does not allow an attribute to be declared as map[string]interface{} which is what would be needed to support this.

The deep copy I suggested would have broken the code because api_data is declared in https://github.com/Mastercard/terraform-provider-restapi/blob/master/restapi/common.go#L59 as map[string]string and the nested strings could not themselves be maps. In retrospect, that should have been obvious to me.

However, they did suggest that the situation might be better in Terraform 0.12 which is adding a jsondecode() function in connection with rich value types. You might want to review https://www.hashicorp.com/blog/terraform-0-12-rich-value-types although that does not mention the jsondecode() function itself. A blog post that would have talked about jsonencode() and jsondecode() functions was planned, but not published for some reason. I'm sure you'll be able to read about these functions when 0.12 is released.

So, I'm closing this for now. When 0.12 is released, we might want to revisit this.

from terraform-provider-restapi.

rberlind avatar rberlind commented on July 20, 2024

Here is a link to the current doc for the new jsondecode() function that is being developed: https://github.com/hashicorp/terraform/blob/2f93ef274103bbeb583a5905e832b6dcf4a88735/website/docs/configuration/functions/jsondecode.html.md

What I think this would allow us to do is store the api_data as a single JSON document and then use Terraform code to decode it and work with nested items no matter how deep.

from terraform-provider-restapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.