Skip to content

Commit 9faeee9

Browse files
committed
fix: failed BB also stores state
1 parent 0fb3762 commit 9faeee9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

internal/provider/building_block_v2_resource.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,13 @@ func (r *buildingBlockV2Resource) Create(ctx context.Context, req resource.Creat
378378
uuid := created.Metadata.Uuid
379379
polled, err := r.client.PollBuildingBlockV2UntilCompletion(ctx, uuid)
380380
if err != nil {
381+
// Always store the initial state, even if the building block was created in a failed state
382+
// This allows Terraform to track the resource and handle recreates appropriately
383+
resp.Diagnostics.Append(setStateFromResponseV2(&ctx, &resp.State, created)...)
384+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("status").AtName("status"), "FAILED")...)
385+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("spec").AtName("inputs"), plan.Spec.Inputs)...)
386+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("wait_for_completion"), plan.WaitForCompletion)...)
387+
381388
resp.Diagnostics.AddError(
382389
"Error waiting for building block completion",
383390
err.Error(),

0 commit comments

Comments
 (0)