Manage Sentinel Detection-as-Code with Terraform
Manage Sentinel analytics rules, an automation rule, and a watchlist as version-controlled Terraform, then make a drift-free change and re-apply.

Lab overview
Security operations teams used to click through the Microsoft Sentinel portal to create and edit analytics rules, automation rules, and watchlists - an approach that quietly drifts out of sync, leaves no review trail, and cannot be promoted reliably from a test workspace to production. Detection-as-Code treats detection content as software: every analytics rule, automation rule, and watchlist is declared in version-controlled Terraform, reviewed in a pull request, and rolled out by terraform plan/apply so the deployed state always matches what is committed. The payoff is fleet-scale consistency - one parameterized definition can manage many rules - and controlled, auditable change, because Terraform shows you the exact diff before anything touches the live workspace.
In this lab, you will start from a baseline Sentinel workspace and manage its detection content entirely through Terraform. You will collapse multiple scheduled analytics rules into a single for_each block driven by a locals map, add a Sentinel automation rule and a watchlist as code, then change one rule's severity and threshold and re-apply - watching terraform plan produce a clean, targeted diff that updates only the intended rule.
Objectives
Upon completion of this advanced level lab, you will be able to:
- Apply a provided Terraform baseline (workspace plus Sentinel onboarding) to get a managed workspace
- Manage two to three scheduled analytics rules from a single
for_eachblock driven by alocalsmap - Deploy a Sentinel automation rule and a watchlist as code so triage logic and reference data live in the same repo as the detections
- Make a controlled change to one rule's severity and threshold, then run
terraform planfor a clean targeted diff - Re-apply and verify the live rule reflects the update with no unintended drift
Who is this lab for?
This lab is designed for:
- Detection engineers operating Sentinel content at scale
- SOC platform engineers managing detections as code
- Cloud security engineers comfortable with Sentinel rule types and basic
terraform plan/apply
Verified against your live environment
An automated validation engine inspects your actual resources and configurations as you work. Completion means the task was performed, not multiple choice, real-world proficiency.
More labs like this
Implement Network Security Groups (NSGs) and Application Security Groups (ASGs) in Azure
Secure Azure VMs using Network Security Groups and Application Security Groups. Create rules, control traffic flow, and implement least privilege access.
Deploy a Full Azure Environment Using Bicep Infrastructure as Code
Write modular Bicep templates to deploy a VNet, App Service, SQL Database, and Key Vault, then deploy the full environment using Azure CLI.
Introduction to Infrastructure as Code with Terraform on AWS
Write your first HCL configuration and deploy a DynamoDB table to AWS using Terraform's init, plan, and apply workflow.
Environment
Every lab includes
- Real environment, pre-credentialed
- Automated checks on every step
- Isolated sandbox, auto cleanup
- AI-recommended next steps
Lab curriculum
- 01
Logging into Azure CLI
- 02
Apply the Provided Sentinel Baseline Workspace and Onboarding
1 automated check
- 03
Manage Multiple Scheduled Rules with a for_each Locals Map
1 automated check
- 04
Deploy a Sentinel Automation Rule and Watchlist as Code
1 automated check
- 05
Change a Rule Severity and Threshold and Plan a Clean Diff
1 automated check
- 06
Re-Apply the Change and Verify the Drift-Free Rule Update
1 automated check
Not the lab you were looking for?
Browse 200+ hands-on labs across AWS, Azure, Kubernetes, Docker, and cloud security.