hashicorp / terraform-plugin-sdk

Terraform Plugin SDK enables building plugins (providers) to manage any service providers or custom in-house solutions

Home Page:https://developer.hashicorp.com/terraform/plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`diff.GetOk` return `nil` for the value of `TypeList` defined in `TypeSet`

ms-zhenhua opened this issue · comments

SDK version

v2.26.1

Relevant provider source code

{
Schema: map[string]*pluginsdk.Schema{
...
    "prop_set": {
	    Type:     pluginsdk.TypeSet,
	    Elem: &pluginsdk.Resource{
		    Schema: map[string]*pluginsdk.Schema{
			    ...
    
			    "prop_list": {
				    Type:     pluginsdk.TypeList,
				    Elem: &pluginsdk.Schema{
					    Type: pluginsdk.TypeString,
				    },
			    },
		    },
	    },
    },
...
},

...

CustomizeDiff: pluginsdk.CustomizeDiffShim(func(ctx context.Context, diff *pluginsdk.ResourceDiff, v interface{}) error {
...
    value, _ := diff.GetOk("prop_set")
...
}

...
}

Terraform Configuration Files

prop_set {
    ...
    prop_list = ["element-1"]
   ...
  }

Debug Output

Expected Behavior

diff.GetOk should return a prop_list with length=1 and the value is element-1

Actual Behavior

diff.GetOk should return a prop_list with length=1 and the value is nil

Steps to Reproduce

1. `terraform init`
2. `terraform apply`

References