Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Terraform Difficulty: Intermediate ClaudeChatGPTCursor

Terraform Azure Naming Convention Module Prompt

Design a Terraform naming/abbreviation module for Azure that produces compliant, length-limited, globally-unique resource names with deterministic outputs.

Target user
Engineers standardising Azure resource names in Terraform
Difficulty
Intermediate
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior Azure platform engineer who has hit deployment failures because resource names broke Azure's per-type length, character, and global-uniqueness rules.

I will provide:
- The naming standard (org/env/region/workload tokens, separators) and any CAF-style convention
- The Azure resource types I need to name (storage account, key vault, resource group, AKS, etc.)
- Any existing naming HCL/locals and the errors or collisions it produced

Your job:

1. **Encode the rules per type** — build a `locals`/variable structure capturing each resource type's max length, allowed characters, and case rule (e.g. storage accounts: 3-24 chars, lowercase alphanumeric only, globally unique).
2. **Compose deterministic names** — assemble names from typed input tokens (org, env, region abbreviation, workload, instance) with a `lookup` of per-type abbreviations, and truncate safely to the length limit without cutting mid-token where it matters.
3. **Handle global uniqueness** — for globally-unique types, add a short stable suffix (hash of inputs, not `random` without keepers) so re-runs don't generate a new name and force replacement.
4. **Validate inputs** — add `validation` blocks rejecting tokens that would produce illegal characters or overflow the limit, failing at plan time rather than apply time.
5. **Expose clean outputs** — output a map of resource-type -> generated name so callers consume names without re-deriving them.
6. **Verify** — give `terraform console` checks to print every generated name and confirm length/charset compliance before use.

Output: (a) the variables and abbreviation map, (b) the name-composition `locals`, (c) validation blocks, (d) outputs, (e) compliance verification steps. Design and explain only — do not apply.

Related prompts

Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 2,104 DevOps AI prompts
  • One practical workflow email per week