Skip to content

Commit c54fb4c

Browse files
authored
[datadog_tag_pipeline_ruleset] Ensure terraform handles tag pipeline rulesets deleted via the UI that are managed in tfstate - should see they don't exist and recreate them (#3313)
[datadog_tag_pipeline_ruleset] Ensure terraform handles tag pipeline rulesets deleted via the UI that are managed in tfstate - should see they don't exist and recreate them Co-authored-by: alex.meyer <alex.meyer@datadoghq.com>
1 parent 8a169d0 commit c54fb4c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

datadog/fwprovider/resource_datadog_tag_pipeline_ruleset.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ func (r *tagPipelineRulesetResource) Read(ctx context.Context, req resource.Read
303303

304304
apiResp, response, err := r.Api.GetTagPipelinesRuleset(r.Auth, state.ID.ValueString())
305305
if err != nil {
306+
if response != nil && response.StatusCode == 404 {
307+
// Resource was deleted outside of Terraform - remove from state
308+
resp.State.RemoveResource(ctx)
309+
return
310+
}
306311
resp.Diagnostics.AddError("Error reading ruleset", utils.TranslateClientError(err, response, "").Error())
307312
return
308313
}
@@ -358,8 +363,12 @@ func (r *tagPipelineRulesetResource) Delete(ctx context.Context, req resource.De
358363
return
359364
}
360365

361-
_, err := r.Api.DeleteTagPipelinesRuleset(r.Auth, state.ID.ValueString())
366+
httpResp, err := r.Api.DeleteTagPipelinesRuleset(r.Auth, state.ID.ValueString())
362367
if err != nil {
368+
if httpResp != nil && httpResp.StatusCode == 404 {
369+
// Resource already deleted - this is fine
370+
return
371+
}
363372
resp.Diagnostics.AddError("Error deleting ruleset", err.Error())
364373
return
365374
}

0 commit comments

Comments
 (0)