I have solved it by my selft.
schema changed to like this
"subusers": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"username": schema.StringAttribute{
Description: "The subuser username to be associate with the domain",
Computed: true,
},
"user_id": schema.Int64Attribute{
Description: "The subuser id to be associate with the domain",
Computed: true,
},
},
},
},
and Create/Read section used like this
elements := []attr.Value{}
for _, subuser := range domainsubuser.Subusers {
elements = append(elements, types.ObjectValueMust(
map[string]attr.Type{
"username": types.StringType,
"user_id": types.Int64Type,
},
map[string]attr.Value{
"username": types.StringValue(subuser.Username),
"user_id": types.Int64Value(subuser.UserID),
},
))
}
domainsubuserstate.Subusers = types.ListValueMust(
types.ObjectType{
AttrTypes: map[string]attr.Type{
"username": types.StringType,
"user_id": types.Int64Type,
},
}, elements,
)
A big thank you to @bendbennett you reference helped me to achieve this.