Terraform plugin framework nested itself

Hi Team,

I have below resource model, actually BackupDatacenter is also the type of DatacenterResourceModel, but BackupDatacenter don’t have property Location , I don’t want to define another BackupDatacenterResourceModel which excluded location

type DatacenterResourceModel struct {
        Id                        types.Int64  `tfsdk:"id"`
        Date                     types.Int64  `tfsdk:"date"`
        Location               types.String `tfsdk:"location"`
	BackupDatacenter    types.Object `tfsdk:"backup_ datacenter"`

However when I tried to use below code to convert the input d.BackupDatacenter to DatacenterResourceModel, it doesn’t work and give me error.

var backup DatacenterResourceModel
diags = append(diags, tfsdk.ValueAs(ctx, d.BackupDatacenter, &backup)...)


Looks return reflect.Into(ctx, val.Type(ctx), raw, target, reflect.Options{}, path.Empty())

there is reflect.Options{} to skip the non-exist property, but how can do it ? is there solution to help me fix this issue ?

Hi @shufanhao
Sorry that you are running into trouble here. Unfortunately, the Framework currently doesn’t support unmarshalling with nested structs, so the BackupDatacenter struct would need to be a separate struct that excludes the location field

There is an open issue regarding this that you can follow on Github: "Follow" Embedded Structs · Issue #242 · hashicorp/terraform-plugin-framework · GitHub. However, we already have other features queued up for the Framework, so we might not get to this issue in the near future.

Please let me know if you have any other questions/issues,

thanks. May I know when this feature can be supported ?

We currently don’t have this issue in our planned work for the Framework so we probably won’t look at this until at least late April. Following the Github issue will be the best way of getting progress updates.

thanks, please keep me update once this feature is release.