Skip to content

fix: prevent deletion of protected logs index (fixes #3470)#3471

Open
AndrewCharlesHay wants to merge 2 commits intoDataDog:masterfrom
AndrewCharlesHay:fix/issue-3470
Open

fix: prevent deletion of protected logs index (fixes #3470)#3471
AndrewCharlesHay wants to merge 2 commits intoDataDog:masterfrom
AndrewCharlesHay:fix/issue-3470

Conversation

@AndrewCharlesHay
Copy link

@AndrewCharlesHay AndrewCharlesHay commented Jan 29, 2026

Description

This PR adds a new optional argument prevent_deletion to the datadog_logs_index resource.

When set to true, this flag safeguards the index from being deleted by Terraform. Any attempt to destroy the resource will result in a diagnostic error, preventing accidental loss of critical indexes (such as the default main index).

Fixes #3470

Schema Changes

  • prevent_deletion (Boolean, Optional): If true, the logs index cannot be deleted. Defaults to false.

Use Case

To protect the main index:

resource "datadog_logs_index" "main" {
  name             = "main"
  filter           { query = "*" }
  prevent_deletion = true
}

If a user attempts terraform destroy or removes this block, the provider will return:
Deletion of logs index 'main' is prevented by 'prevent_deletion' flag

To allow deletion, the user must explicitly set prevent_deletion = false and apply, before destroying.

@AndrewCharlesHay AndrewCharlesHay requested review from a team as code owners January 29, 2026 00:01
@AndrewCharlesHay AndrewCharlesHay changed the title fix: prevent deletion of main logs index (fixes #3470) fix: prevent deletion of protected logs index (fixes #3470) Jan 29, 2026
Copy link
Member

@fpighi fpighi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Could you write a test and also regenerate docs with make docs please?

"prevent_deletion": {
Description: "If true, the logs index cannot be deleted. Defaults to false.",
Type: schema.TypeBool,
Optional: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having an explicit default here would make it consistent and auto-generated docs would benefit from it too, so the "Defaults to false" description could be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent Deletion of main datadog_logs_index

2 participants