Task 01: Configure Core Variables
DOCUMENT CATEGORY: Task
SCOPE: Core Terraform variable configuration
PURPOSE: Define customer and CI/CD integration variables
MASTER REFERENCE: azurelocal-toolkit Terraform variables
Status: Active Last Updated: 2026-02-07
Objective
Set the core values that every CI/CD deployment needs (tenant, subscription, location, tags and the CI/CD integration) in infrastructure.yml, then write the Terraform variable files from it.
The Terraform code (src/terraform) does not define the facts of an environment a second time. New-IacVariableFiles.ps1 reads infrastructure.yml and writes terraform.tfvars.json and backend.hcl. The registry says, for every Terraform variable, which key it comes from. Every value comes from infrastructure.yml (a key the file leaves out gets its registry default); terraform.tfvars.example holds comments only. Add no .tfvars file of your own: a later -var-file overrides the generated values. A secret is never written to a file: the generator writes not-written.txt and names the environment variable that Terraform reads at run time.
Prerequisites
-
infrastructure.ymlstarted from a template (see Variable Management) - Azure tenant ID and subscription ID
- The CI/CD infrastructure of Part 1 deployed: the runners, and the
devopssection of the file filled in
Procedure
1. Set the core keys
| Key | What it holds |
|---|---|
azure.tenant_id | The Azure tenant ID |
azure.subscription_id | The target subscription ID |
azure.location | The Azure region |
tags | The resource tags |
site.code | The short site code that the names use |
devops | The CI/CD platform, project, repository, environments, runners and Terraform state |
Every key, with its type, default and example, is in the variables reference.
2. Check the file
./scripts/common/infrastructure/Test-InfrastructureFile.ps1 -Path ./infrastructure.yml
3. Write the Terraform variable files
# Keep the output folder out of the repository.
./config/variables/scripts/New-IacVariableFiles.ps1 -InfrastructureFile ./infrastructure.yml -OutputDirectory D:\work\iac
Validation
After you write the files, verify:
-
Test-InfrastructureFile.ps1reports no error -
terraform.tfvars.jsonandbackend.hclexist for each environment you use - The tenant ID and the subscription ID are the ones of this customer
- No secret is in a file. The reference in
infrastructure.ymlis the only place a secret is named - The output folder is outside the repository
Values from infrastructure.yml
See the table in the procedure above. The older Terraform variables of this page (customer_name, azurelocal_cicd and azurelocal_group_object_id) do not exist in the Terraform code any more.
Troubleshooting
Issue: Invalid customer_name format
Solution: Customer name must be lowercase with hyphens only (e.g., acme, global-tech)
Issue: Invalid environment value
Solution: Environment must be 3 characters or less: prd, dev, stg, qa, etc.
Issue: Azure region not available
Solution: Verify region name with az account list-locations -o table
Issue: Cannot find runner principal ID Solution: Check Part 1 CI/CD Infrastructure deployment outputs or CI/CD pipeline variables
Next Steps
Proceed to Task 02 - Configure Management Mode to define network configuration.
- GitHub
- GitLab
- Azure DevOps
When to use: Use this tab if your CI/CD pipeline runs on GitHub Actions.
See procedure steps above for GitHub-specific guidance.
When to use: Use this tab if your CI/CD pipeline runs on GitLab CI/CD.
See procedure steps for GitLab-specific guidance.
When to use: Use this tab if your CI/CD pipeline runs on Azure DevOps Pipelines.
See procedure steps for Azure DevOps-specific guidance.
Scripts for this task are located in the azurelocal-toolkit repository under scripts/deploy/ in the appropriate task folder.
Alternatives
The procedures in this task use the methods shown in the tabs above. The toolkit is PowerShell 7 only and has no Bash scripts. A few tasks that act on Azure also have an Azure CLI script written in PowerShell. The script status page of the toolkit lists which task has which script.
Navigation
| Previous | Up | Next |
|---|---|---|
| Phase 01 - Configuration | Phase 01 - Configuration | Task 02 - Management Mode |
Version Control
| Version | Date | Author | Changes |
|---|---|---|---|
| 1.0.0 | 2026-03-24 | Azure Local Cloud | Initial release |