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.

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

More Terraform prompts & error guides

Browse every Terraform prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.