Skip to content

Commit a923afd

Browse files
committed
chore(edgecloud): directly use API response ID
1 parent 1d978f9 commit a923afd

File tree

1 file changed

+2
-7
lines changed
  • stackit/internal/services/edgecloud/instance

1 file changed

+2
-7
lines changed

stackit/internal/services/edgecloud/instance/resource.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,23 +276,18 @@ func (i *instanceResource) Create(ctx context.Context, req resource.CreateReques
276276
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "API returned nil response")
277277
return
278278
}
279-
if createResp.Id == "" {
280-
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "API returned empty Instance ID")
281-
return
282-
}
283279

284-
edgeCloudInstanceId := createResp.Id
285280
// Write id attributes to state before polling via the wait handler - just in case anything goes wrong during the wait handler
286281
ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{
287282
"project_id": projectId,
288-
"instance_id": edgeCloudInstanceId,
283+
"instance_id": createResp.Id,
289284
"region": region,
290285
})
291286
if resp.Diagnostics.HasError() {
292287
return
293288
}
294289

295-
waitResp, err := edgewait.CreateOrUpdateInstanceWaitHandler(ctx, i.client.DefaultAPI, projectId, region, edgeCloudInstanceId).WaitWithContext(ctx)
290+
waitResp, err := edgewait.CreateOrUpdateInstanceWaitHandler(ctx, i.client.DefaultAPI, projectId, region, createResp.Id).WaitWithContext(ctx)
296291
if err != nil {
297292
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Instance waiting: %v", err))
298293
return

0 commit comments

Comments
 (0)