How to Manage Elastic Security Detection Rules with Terraform

· Original article ↗

Summary

Elastic’s Terraform provider adds resources for managing detection rules and exception lists as code. The article demonstrates an ES|QL service-account logon rule and compares Terraform’s deployment workflow with the detection-rules repository.

Key points

  • Elastic Stack Terraform provider versions v0.12.0 and v0.13.0 add resources for managing security detection rules and exception lists.
  • The example ES|QL rule detects interactive Windows logons by service accounts using event code 4624 and the system.security data stream.
  • Terraform exception-list resources can document approved exclusions, such as a legacy SQL backup service account.
  • Terraform plan can surface changes made directly in Kibana before updates are applied.
  • Elastic AI Agent can help translate ES|QL rules and exception logic into Terraform HCL.
  • The article recommends the detection-rules repository for rule authoring and built-in testing; the Terraform provider is aimed at deployment and operations, and relies on Kibana to accept or reject rule definitions.

Article Details

Topic
Managing Elastic Security detection rules and exception lists as Terraform code

MITRE ATT&CK

Vendors

Products

Tools

Related Articles