@@ -16,7 +16,6 @@ import (
1616 "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
1717 "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
1818
19- "github.com/hashicorp/terraform-plugin-framework/path"
2019 "github.com/hashicorp/terraform-plugin-framework/resource"
2120 "github.com/hashicorp/terraform-plugin-framework/resource/schema"
2221 "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
@@ -191,7 +190,11 @@ func (r *userResource) Create(ctx context.Context, req resource.CreateRequest, r
191190 return
192191 }
193192 userId := * userResp .Id
194- ctx = tflog .SetField (ctx , "user_id" , userId )
193+ ctx = utils .SetAndLogStateFields (ctx , & resp .Diagnostics , & resp .State , map [string ]any {
194+ "project_id" : projectId ,
195+ "instance_id" : instanceId ,
196+ "user_id" : userId ,
197+ })
195198
196199 // Map response body to schema
197200 err = mapFields (userResp , & model )
@@ -354,10 +357,11 @@ func (r *userResource) ImportState(ctx context.Context, req resource.ImportState
354357 )
355358 return
356359 }
357-
358- resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("project_id" ), idParts [0 ])... )
359- resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("instance_id" ), idParts [1 ])... )
360- resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("user_id" ), idParts [2 ])... )
360+ ctx = utils .SetAndLogStateFields (ctx , & resp .Diagnostics , & resp .State , map [string ]any {
361+ "project_id" : idParts [0 ],
362+ "instance_id" : idParts [1 ],
363+ "user_id" : idParts [2 ],
364+ })
361365 core .LogAndAddWarning (ctx , & resp .Diagnostics ,
362366 "Secrets Manager user imported with empty password" ,
363367 "The user password is not imported as it is only available upon creation of a new user. The password field will be empty." ,
0 commit comments