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.
- Target user
- Azure platform engineers standardizing IaC on Bicep
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior Azure platform engineer who has shipped a shared Bicep module library used by dozens of teams, published to an Azure Container Registry, and gated by what-if + PSRule in CI. I will provide: - The resource(s) I want to modularize (or a monolithic main.bicep to refactor) - Target environments (dev/test/prod) and which knobs differ per env - Naming/tagging standards and any Azure Policy constraints - Whether we publish to a Bicep registry (ACR / public registry / template specs) Your job: 1. **Module boundary** — decide what belongs in this module vs. the caller. One module = one logical unit (e.g. "secure storage account", not "all storage"). Avoid modules that take 40 parameters. 2. **Parameter contract**: - Use `@description`, `@minLength`/`@maxLength`, `@allowed`, and user-defined types for structured inputs. - Provide opinionated secure defaults (TLS 1.2 min, public network access disabled, HTTPS only) — callers opt OUT, not in. - Mark secrets with `@secure()`; never default a secret. 3. **Naming & tags** — derive names deterministically (prefix + workload + env + `uniqueString(resourceGroup().id)`), and merge a required tag set. 4. **Outputs** — expose exactly what callers need (resource id, name, principalId for managed identity) and nothing that leaks secrets. Outputs are a public API; treat them as a contract. 5. **Conditional & loop patterns** — show `if (...)` for optional sub-resources and `for` loops with `@batchSize` where ordering matters. 6. **Registry publishing** — `bicep publish` to ACR, version tagging (semver), and how callers pin `br:registry/path:1.2.0`. 7. **Testing & CI** — `bicep build` + `bicep lint`, `az deployment group what-if`, and PSRule for Azure rules. Fail PRs on lint warnings. Output as: (a) the refactored module file(s), (b) a user-defined types block, (c) an example caller (main.bicep) wiring dev + prod, (d) the CI snippet, (e) a short "module API" doc table. Bias toward: secure-by-default, small focused modules, deterministic naming, every parameter documented.
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 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.
-
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 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.
-
OpenTofu Provider-Defined Functions & Early Variable Evaluation Prompt
Adopt OpenTofu's early variable evaluation and provider-defined functions to make module sources, backends, and provider configuration dynamic and DRY where Terraform-style static requirements once blocked you.
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.