Microsoft Azure Terraform Module v1.0

terraform-azure-key-vault

Executive Summary

Terraform module for deploying Azure Key Vault with RBAC authorization, private endpoint integration, purge protection, HSM-backed keys with automatic rotation policies, secret and certificate management, network ACLs, and diagnostic settings. Designed for enterprise secrets management with zero-trust networking by default.

Overview

7

Resources

Key Vault, Keys, Secrets, Certs, RBAC, Private Endpoint, Diagnostics

18

Variables

Configurable input parameters

13

Outputs

IDs, URIs, versions, private endpoint info

3

Examples

Basic, Advanced, Complete

Architecture Diagram

Azure Key Vault
Standard / Premium SKU
|
Stored Items
Keys
RSA / EC / HSM
Secrets
Certificates
Self-Signed / CA
Security
RBAC Roles
Key Rotation
Policy
Purge Protection
90-day Soft Delete
Networking
Private Endpoint
Private DNS Zone
Network ACLs
IP + VNet Rules
Diagnostic Settings → Log Analytics

Component Breakdown

ResourcePurpose
azurerm_key_vaultCore vault with SKU, RBAC, purge protection, soft delete, network ACLs
azurerm_key_vault_keyCryptographic keys (RSA/EC/HSM) with automatic rotation policies
azurerm_key_vault_secretSecrets with content types and expiration dates
azurerm_key_vault_certificateX.509 certificates with auto-renewal lifecycle actions
azurerm_role_assignmentRBAC role assignments scoped to the Key Vault
azurerm_private_endpointPrivate endpoint with DNS zone group for vault subresource
azurerm_monitor_diagnostic_settingLog and metric export to Log Analytics workspace

Data Flow

Application / Service
Private Endpoint
Key Vault
Keys / Secrets / Certs

1. Applications authenticate via Azure AD (Managed Identity / Service Principal). 2. Traffic flows through private endpoint within the VNet. 3. RBAC authorization validates permissions on the vault scope. 4. Key Vault returns secrets/keys/certificates. 5. All operations logged to Log Analytics via diagnostic settings.

Security Controls

Access Control

- RBAC authorization enabled by default
- Role assignments scoped to vault
- Azure AD authentication required
- Public network access disabled by default

Data Protection

- Purge protection enabled (default)
- 90-day soft delete retention
- HSM-backed keys (Premium SKU)
- Automatic key rotation policies
- Certificate auto-renewal (30-day trigger)

Network Security

- Private endpoint for VNet-isolated access
- Private DNS zone integration
- Network ACLs with IP and VNet rules
- Azure Services bypass option

Monitoring

- Diagnostic logs (AuditEvent, AllMetrics)
- Log Analytics workspace integration
- Key access and modification tracking

Industry Adaptation

Financial Services

Premium SKU with HSM-backed keys, strict RBAC, private endpoint only, 90-day soft delete retention

Healthcare

HIPAA-compliant secrets management, key rotation policies, full audit logging, no public network access

SaaS Platforms

Per-environment vaults, certificate management for custom domains, managed identity integration

Government

Purge protection mandatory, HSM key storage, network ACL enforcement, diagnostic logging to SIEM

Production Readiness Checklist

Configuration Reference

VariableTypeDefaultDescription
namestring--Key Vault name
sku_namestringstandardstandard or premium
enable_rbac_authorizationbooltrueUse RBAC instead of access policies
purge_protection_enabledbooltruePrevent permanent deletion
soft_delete_retention_daysnumber90Retention period (7-90 days)
public_network_access_enabledboolfalsePublic access toggle
keysmap(object){}Keys with rotation policies
secretsmap(object){}Secrets with content types
certificatesmap(object){}Certificates with auto-renewal
enable_private_endpointbooltrueCreate private endpoint
enable_diagnosticsbooltrueEnable diagnostic settings

Deployment

terraform init
terraform plan -var-file="keyvault.tfvars"
terraform apply -var-file="keyvault.tfvars"

# Verify vault
az keyvault show --name kv-myapp-prod

Links

Azure Key Vault Documentation | Terraform Registry | Basic Example | Complete Example