Coder Social home page Coder Social logo

Comments (5)

mitchellh avatar mitchellh commented on August 30, 2024

Kind of confusing but I believe this is working as intended as shown here: hashicorp/terraform@fa9758e

Well, working as "intended" may not be working as designed... so this may still be a bug. @catsby @stack72: what do you think here? Should diff suppression be ignored when the default value is used?

from terraform-plugin-sdk.

marionettist avatar marionettist commented on August 30, 2024

This is still happening in terraform 0.11.10

Terraform itself handles this well, i.e. when a provider defines a resource which has an attribute foo with a default value and the diff function set, calling d.get("foo") in the provider correctly returns the default value when a resource does not specify the foo attribute.

However, the terraform provider acceptance test framework doesn't behave the same way: the default value for the attribute is ignored and the default value for the type is returned instead.
So I believe ti's a bug in the testing framework...

It would be great to get this fixed as it makes testing providers quite difficult in some cases.
I will have a look to see if I can identify where the change should be made and what it should be, but any pointers would be appreciated.

from terraform-plugin-sdk.

marionettist avatar marionettist commented on August 30, 2024

Just wanted to add that, if my understanding of the work-around is correct, it will only work with types such as TypeString or TypeInt, i.e. types that can have at least 3 values: one for the type's default, one for an arbitrary attribute default that helps determine whether or not the user has specified a value for the attribute, and one for the actual value of the attribute as specified by the user.

It then means that the work-around does not actually work for attributes of type TypeBool.
So imho, this bug prevents providers with attributes of type TypeBool defining a default value and a suppress func to be succesfully acceptance tested.

from terraform-plugin-sdk.

bflad avatar bflad commented on August 30, 2024

Hi folks 👋

A lot has changed with Terraform CLI and terraform-plugin-sdk between when this issue was raised and now. For example, there have been significant updates to the difference handling logic and the acceptance testing framework now uses real Terraform CLI commands and artifacts rather than re-implementing or emulating some of the previous Terraform core logic internally. State value checking should be wholly representative of an actual terraform apply.

If you are still running into problems in this area with recent versions of Terraform CLI and the SDK, my suggestion would be to open a new issue so we can take a fresh look. Thanks so much.

from terraform-plugin-sdk.

github-actions avatar github-actions commented on August 30, 2024

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

from terraform-plugin-sdk.

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.