@@ -4,8 +4,10 @@ import (
44 "context"
55
66 "github.com/elastic/terraform-provider-elasticstack/generated/kbapi"
7+ "github.com/elastic/terraform-provider-elasticstack/internal/clients"
78 "github.com/elastic/terraform-provider-elasticstack/internal/clients/kibana_oapi"
89 "github.com/hashicorp/terraform-plugin-framework/resource"
10+ "github.com/hashicorp/terraform-plugin-framework/types"
911)
1012
1113func (r * securityListResource ) Read (ctx context.Context , req resource.ReadRequest , resp * resource.ReadResponse ) {
@@ -21,10 +23,20 @@ func (r *securityListResource) Read(ctx context.Context, req resource.ReadReques
2123 return
2224 }
2325
26+ // Parse composite ID to get space_id and list_id
2427 spaceID := state .SpaceID .ValueString ()
28+ listID := state .ListID .ValueString ()
29+
30+ // Try to parse as composite ID from state.ID
31+ if compId , diags := clients .CompositeIdFromStrFw (state .ID .ValueString ()); ! diags .HasError () {
32+ spaceID = compId .ClusterId
33+ listID = compId .ResourceId
34+ // Update space_id in state if it was parsed from composite ID
35+ state .SpaceID = types .StringValue (spaceID )
36+ }
2537
2638 params := & kbapi.ReadListParams {
27- Id : kbapi .SecurityListsAPIListId (state . ID . ValueString () ),
39+ Id : kbapi .SecurityListsAPIListId (listID ),
2840 }
2941
3042 readResp , diags := kibana_oapi .GetList (ctx , client , spaceID , params )
0 commit comments