HasChange and removed items


I put in my terraform provider code in function update for each resource attribute:

if d.HasChange("description") {                                                                   
    description := d.Get("description").(string)                                                    
    params.Description = description                                                                

But when the specified attribute (here description) is removed from the tf code, it seems that the HasChange function is not returning true, is-it correct ?


1 Like

Does the description field in the schema.Schema have Computed set to true?

Here is the definition of description:

"description": {                                                                              
        Type:         schema.TypeString,                                                            
        Optional:     true,                                                                         
        ValidateFunc: validation.StringLenBetween(1, 100),                                          

Any idea ?
I need some information to release a new version of my provider.


I have also this error with DEBUG activated:

The following problems may be the cause of any confusing errors from downstream operations:
- .description: was null, but now cty.StringVal("IP created by terraform")

What does it mean ?

This probably means that there was no description stored in state. At least I see this message in current version of GitLab provider, where d.Set for some fields is called in Read call after Create.

I’m having a bit of trouble following along from the snippets you’re sharing. Is your code online somewhere?