Below is the schema for the resource.
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Optional: true,
Computed: true,
Validators: []validator.String{
stringvalidator.LengthAtLeast(1),
},
},
"name": schema.StringAttribute{
Optional: true,
Computed: true,
Validators: []validator.String{
stringvalidator.LengthAtLeast(1),
stringvalidator.ExactlyOneOf(path.MatchRoot("id")),
},
},
"demo_list": schema.SetNestedAttribute{
Computed: true,
Optional: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"demo_id": schema.StringAttribute{
Optional: true,
Computed: true,
Validators: []validator.String{
stringvalidator.LengthAtLeast(1),
},
},
"demo_name": schema.StringAttribute{
Computed: true,
Optional: true,
Validators: []validator.String{
stringvalidator.LengthAtLeast(1),
stringvalidator.ExactlyOneOf(path.MatchRelative().AtParent().AtName("demo_id")),
},
},
"demo_iops": schema.Int64Attribute{
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.Int64{
int64planmodifier.UseStateForUnknown(),
},
},
"demo_bw_in_mbps": schema.Int64Attribute{
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.Int64{
int64planmodifier.UseStateForUnknown(),
},
},
"demo_mode": schema.StringAttribute{
Computed: true,
Optional: true,
Validators: []validator.String{stringvalidator.OneOf(
"ReadOnly",
"ReadWrite",
"NoAccess",
)},
PlanModifiers: []planmodifier.String{
stringDefault("ReadOnly"),
stringplanmodifier.UseStateForUnknown(),
},
},
},
},
},
},
}
The above schema is working fine for both create/update operations in Terraform 1.3.2.
Ran the same config in 1.4.6. Create operation is working fine but the update is not working as expected.
In create operation, there are 2 objects in the demo_list. Both objects got added.
In the update operation, changed one of the demo_name. The expected behavior is it should remove one entity and add a new one.
In 1.4.6 for the plan, the newly added entity is showing correctly but for the other for which there is no change, its showing demo_id and demo_name as known after apply.
Terraform-Plugin_Framework Version: 1.1.1
Terraform-Plugin-Framework-Validators Version: v0.9.0