diff --git a/apstra/resource_freeform_allocation_group.go b/apstra/resource_freeform_allocation_group.go index e6ad7510..20a3106b 100644 --- a/apstra/resource_freeform_allocation_group.go +++ b/apstra/resource_freeform_allocation_group.go @@ -95,7 +95,7 @@ func (o *resourceFreeformAllocGroup) Read(ctx context.Context, req resource.Read bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString()) if err != nil { if utils.IsApstra404(err) { - resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error()) + resp.State.RemoveResource(ctx) return } resp.Diagnostics.AddError("failed to create blueprint client", err.Error()) diff --git a/apstra/resource_freeform_config_template.go b/apstra/resource_freeform_config_template.go index 6d04e02b..fede0cee 100644 --- a/apstra/resource_freeform_config_template.go +++ b/apstra/resource_freeform_config_template.go @@ -95,7 +95,7 @@ func (o *resourceFreeformConfigTemplate) Read(ctx context.Context, req resource. bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString()) if err != nil { if utils.IsApstra404(err) { - resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error()) + resp.State.RemoveResource(ctx) return } resp.Diagnostics.AddError("failed to create blueprint client", err.Error()) diff --git a/apstra/resource_freeform_link.go b/apstra/resource_freeform_link.go index 17c1d49d..5f27081c 100644 --- a/apstra/resource_freeform_link.go +++ b/apstra/resource_freeform_link.go @@ -102,7 +102,7 @@ func (o *resourceFreeformLink) Read(ctx context.Context, req resource.ReadReques bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString()) if err != nil { if utils.IsApstra404(err) { - resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error()) + resp.State.RemoveResource(ctx) return } resp.Diagnostics.AddError("failed to create blueprint client", err.Error()) diff --git a/apstra/resource_freeform_property_set.go b/apstra/resource_freeform_property_set.go index 7f6d4001..c4f30501 100644 --- a/apstra/resource_freeform_property_set.go +++ b/apstra/resource_freeform_property_set.go @@ -95,7 +95,7 @@ func (o *resourceFreeformPropertySet) Read(ctx context.Context, req resource.Rea bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString()) if err != nil { if utils.IsApstra404(err) { - resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error()) + resp.State.RemoveResource(ctx) return } resp.Diagnostics.AddError("failed to create blueprint client", err.Error()) diff --git a/apstra/resource_freeform_resource.go b/apstra/resource_freeform_resource.go index a0ef9d5f..f1a05a1f 100644 --- a/apstra/resource_freeform_resource.go +++ b/apstra/resource_freeform_resource.go @@ -191,7 +191,7 @@ func (o *resourceFreeformResource) Read(ctx context.Context, req resource.ReadRe bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString()) if err != nil { if utils.IsApstra404(err) { - resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error()) + resp.State.RemoveResource(ctx) return } resp.Diagnostics.AddError("failed to create blueprint client", err.Error()) diff --git a/apstra/resource_freeform_resource_group.go b/apstra/resource_freeform_resource_group.go index 693680f0..6ce53bb9 100644 --- a/apstra/resource_freeform_resource_group.go +++ b/apstra/resource_freeform_resource_group.go @@ -98,7 +98,7 @@ func (o *resourceFreeformResourceGroup) Read(ctx context.Context, req resource.R bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString()) if err != nil { if utils.IsApstra404(err) { - resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error()) + resp.State.RemoveResource(ctx) return } resp.Diagnostics.AddError("failed to create blueprint client", err.Error())