# Naming Validation

This document provides validation rules and examples for the naming convention.

## Validation Rules

### Resource Group Names
- **Pattern**: `az-{region}-rg-{env}-{purpose}`
- **Example**: `az-we-rg-dev-main`
- **Validation**: `^az-[a-z]{2}-rg-(dev|stg|prd|mgmt)-[a-z]{3,15}$`

### Storage Account Names
- **Pattern**: `az{region}sa{env}{purpose}`
- **Example**: `azwesadevdata`
- **Max Length**: 24 characters
- **Validation**: `^az[a-z]{2}sa(dev|stg|prd|mgmt)[a-z]{3,10}$`

### Key Vault Names
- **Pattern**: `az-{region}-kv-{env}-{purpose}`
- **Example**: `az-we-kv-dev-main`
- **Max Length**: 24 characters
- **Validation**: `^az-[a-z]{2}-kv-(dev|stg|prd|mgmt)-[a-z]{3,10}$`

### AKS Cluster Names
- **Pattern**: `az-{region}-aks-{env}-{purpose}`
- **Example**: `az-we-aks-dev-main`
- **Max Length**: 63 characters
- **Validation**: `^az-[a-z]{2}-aks-(dev|stg|prd|mgmt)-[a-z]{3,15}$`

### Container Registry Names
- **Pattern**: `az{region}acr{env}`
- **Example**: `azweacrdev`
- **Max Length**: 50 characters
- **Validation**: `^az[a-z]{2}acr(dev|stg|prd|mgmt)$`

## Testing

Run Terraform validation:

```bash
cd infra/terraform
terraform validate
terraform plan
```

Check name lengths:

```bash
# Storage accounts must be <= 24 chars
echo "azwesadevdata" | wc -c  # Should be <= 24

# Key Vaults must be <= 24 chars
echo "az-we-kv-dev-main" | wc -c  # Should be <= 24
```

