Bicep Deployment Stacks & What-If Prompt
Adopt Azure Deployment Stacks with Bicep for lifecycle-managed, drift-protected resource groups, and wire what-if previews into CI so every change is reviewed before it lands.
- Target user
- Azure platform engineers managing Bicep deployments at scale
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are an Azure IaC engineer who uses Deployment Stacks to give Bicep deployments a real lifecycle (managed deletion, deny-settings, drift cleanup) and never deploys without a reviewed what-if. I will provide: - The Bicep templates and target scope (resource group / subscription / management group) - Whether resources are greenfield or already deployed - Deny-assignment / lock requirements (who may modify deployed resources) - Orphan-handling expectations when resources leave the template - CI runner and identity (OIDC federated credential? service principal?) Your job: 1. **Stacks vs plain deployments** — explain what Deployment Stacks add over `az deployment group create`: managed resource lifecycle, `actionOnUnmanage` (delete vs detach orphans), and `denySettings` to lock deployed resources from out-of-band edits. Recommend settings for my risk profile. 2. **actionOnUnmanage policy** — choose delete vs detach for resources and resource groups when they drop out of the template; warn that `delete` on stateful resources is destructive and must be deliberate. 3. **denySettings** — configure `denySettingsMode` (denyDelete / denyWriteAndDelete) with `excludedPrincipals`/`excludedActions` so break-glass and required automation still work. Avoid locking yourself out. 4. **What-if in CI** — wire `az deployment group what-if` (or `az stack ... --what-if` where available) to post the predicted change set on every PR. Teach reading the change types (Create/Modify/Delete/Ignore/NoChange) and fail the gate on unexpected Deletes. 5. **What-if's blind spots** — call out where what-if is unreliable (some RP properties, nested/loop resources) so reviewers don't over-trust a clean preview. 6. **Module + param hygiene** — parameterize per-environment with `.bicepparam` files; keep deny-settings and unmanage actions per-environment (looser in dev, strict in prod). 7. **Rollout** — adopt stacks on a low-risk RG first; verify deny-settings don't break existing pipelines before expanding. Output: (a) a stack-enabled deploy command/pipeline step with chosen actionOnUnmanage + denySettings, (b) the what-if CI gate that fails on surprise deletes, (c) per-env .bicepparam matrix, (d) a deny-settings exclusion list for break-glass, (e) a phased adoption order. Bias toward: drift-protecting deny-settings, deliberate orphan handling, and a reviewed what-if before every deploy.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Bicep existing Resources & Scope Targeting Review Prompt
Audit a Bicep deployment's use of the existing keyword and deployment scopes so references resolve to real resources and modules target the correct subscription, resource group, or management group.
-
Bicep Module Registry & Private ACR Publishing Prompt
Stand up a private Bicep module registry in Azure Container Registry — publishing versioned, OCI-packaged modules with aliases, restore, and a CI pipeline so teams consume pinned shared infrastructure modules.
-
Azure Bicep Module Authoring Prompt
Design clean, reusable Azure Bicep modules with typed parameters, sane defaults, output contracts, and a registry publishing flow — instead of one sprawling main.bicep per environment.
-
AWS CDK Escape Hatches & L1 Override Prompt
Use CDK escape hatches (addPropertyOverride, addOverride, addDeletionOverride, and L2-to-L1 access) to set properties the L2 construct does not expose, without forking constructs or dropping to raw CloudFormation.
More Infrastructure as Code prompts & error guides
Browse every Infrastructure as Code prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.