diff --git a/internal/provider/environment_resource.go b/internal/provider/environment_resource.go index 3e018067..d2adbdbf 100644 --- a/internal/provider/environment_resource.go +++ b/internal/provider/environment_resource.go @@ -26,6 +26,7 @@ import ( var ( _ resource.Resource = &environmentResource{} _ resource.ResourceWithConfigure = &environmentResource{} + _ resource.ResourceWithModifyPlan = &environmentResource{} _ resource.ResourceWithImportState = &environmentResource{} ) @@ -128,6 +129,17 @@ func (r *environmentResource) ImportState(ctx context.Context, req resource.Impo })...) } +func (r *environmentResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if req.Plan.Raw.IsNull() { + // If the entire plan is null, the resource is planned for destruction -- let's add a warning + resp.Diagnostics.AddWarning( + "Resource Destruction Warning", + "Appling this plan will delete the Environment and all of its contents. "+ + "This is an irreversible operation.", + ) + } +} + func (r *environmentResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var plan models.EnvironmentResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)