From 50cee0b5c614b7595eb2cae0d470f071c5f1e9da Mon Sep 17 00:00:00 2001 From: Steph Date: Wed, 1 Oct 2025 15:31:55 +0200 Subject: [PATCH] update code example for list to set identity data --- .../v2.38.x/docs/plugin/sdkv2/resources/list.mdx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/content/terraform-plugin-sdk/v2.38.x/docs/plugin/sdkv2/resources/list.mdx b/content/terraform-plugin-sdk/v2.38.x/docs/plugin/sdkv2/resources/list.mdx index c6e92a840a..030535babf 100644 --- a/content/terraform-plugin-sdk/v2.38.x/docs/plugin/sdkv2/resources/list.mdx +++ b/content/terraform-plugin-sdk/v2.38.x/docs/plugin/sdkv2/resources/list.mdx @@ -96,6 +96,17 @@ func (r *ThingListResource) List(ctx context.Context, req list.ListRequest, stre // Set the ID of the resource for the ResourceData object rd.SetId("a_unique_id_related_to_the_thing") + // Get the existing identity data from ResourceData and set relevant identity attributes + identity, err := rd.Identity() + if err != nil { + result.Diagnostics.AddError( + "Retrieving identity data", + "An error was encountered when retrieving the identity data: "+err.Error(), + ) + } + + identity.Set("an_identity_attribute", thing.IdentityAttribute) + // Set the attributes of interest into the resource state rd.Set("name", thing.Name) rd.Set("attribute_one", thing.AttributeOne)