terraform-plugin-sdk
terraform-plugin-sdk copied to clipboard
`ResourceDiff.Get()` doesn't return all the data
SDK version
v2.21.0
Relevant provider source code
&schema.Resource{ // Root resource
Schema: map[string]*schema.Schema{
"analysis_definition": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Elem: &schema.Resource{
Schema: analysisDefinitionSchema,
},
},
},
CustomizeDiff: func(ctx context.Context, rd *schema.ResourceDiff, i any) error {
helper.Logger.Printf("Data: %#v", rd.Get("string"))
helper.Logger.Printf("Raw: %#v", rd.GetRawConfig())
return nil
},
}
Terraform Configuration Files
Some text was replaced but structure is unchanged
Note fields field is a TypeSet, and items is a TypeList
resource "analysis_definitions" "test" {
analysis_definition {
name = "name"
description = "description"
model_id = "d9f4e470-f4ad-456c-8b8e-47577a8212cd"
node_id = var.node_id
inputs {
type = "STRUCTURE"
fields {
name = "example1"
type = "STRUCTURE"
fields {
name = "example2"
type = "ARRAY"
items {
type = "STRUCTURE"
fields {
name = "id"
type = "TEXT"
source = "STATIC"
value = "This value doesnt appear!"
}
}
}
}
}
}
}
Debug Output
This is from my Logger.Printf() code. Some text was replaced but structure is unchanged. https://gist.github.com/N1ark/805c152bc2cea3155189a6dfdf7c411f
Expected Behavior
Although the outputs of Data and Raw are different (one is a map[string]interface{} and the other is a cty.Value, they contain the same data.
Actual Behavior
The Data output seems to be cut - after a certain depth the data output by "Data" isn't present and is instead nil .
Simply search "items":[]interface {}{interface {}(nil)} in the gist to find it.
This data is present in Raw (search for "This value doesnt appear!").
Steps to Reproduce
- Setup a schema that goes deep enough (mine is done through a recursive function)
- Write the configuration that goes deep enough
- Add the given
CustomizeDiffsnippet terraform init && terraform plan --refresh=false