This project demonstrates how to provision Azure resources with environment-specific tagging using Terraform and Azure Pipelines.
Resources are tagged differently based on the environment (dev, staging, prod) to enable:
- Cost allocation and tracking
- Resource governance
- Environment identification
- Operational requirements
environment
: The deployment environment (dev, staging, prod)project
: Project nameowner
: Team responsible for the resourcesprovisioner
: Tool used for provisioning (Terraform)
Development Environment
criticality
: lowcost_center
: dev-cc-123tier
: development
Staging Environment
criticality
: mediumcost_center
: staging-cc-456tier
: pre-production
Production Environment
criticality
: highcost_center
: prod-cc-789tier
: productionbackup
: daily
- Environment-specific variables are defined in
environments/<env>/terraform.tfvars
- The Azure Pipeline dynamically generates additional tags based on the selected environment
- Tags are merged in Terraform using the
local.resource_tags
variable - All resources inherit these tags through module parameters
To deploy resources with environment-specific tags:
# For development environment
terraform init -backend-config=environments/dev/backend.tfvars
terraform apply -var-file=environments/dev/terraform.tfvars
# For staging environment
terraform init -backend-config=environments/staging/backend.tfvars
terraform apply -var-file=environments/staging/terraform.tfvars
# For production environment
terraform init -backend-config=environments/prod/backend.tfvars
terraform apply -var-file=environments/prod/terraform.tfvars
Or use the Azure Pipeline by selecting the desired environment parameter.