Skip to main content

Task 01: Configure Core Variables

Implementation Terraform

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 variables come from infrastructure.yml

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.yml started from a template (see Variable Management)
  • Azure tenant ID and subscription ID
  • The CI/CD infrastructure of Part 1 deployed: the runners, and the devops section of the file filled in

Procedure​

1. Set the core keys​

KeyWhat it holds
azure.tenant_idThe Azure tenant ID
azure.subscription_idThe target subscription ID
azure.locationThe Azure region
tagsThe resource tags
site.codeThe short site code that the names use
devopsThe 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.ps1 reports no error
  • terraform.tfvars.json and backend.hcl exist 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.yml is 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.



When to use: Use this tab if your CI/CD pipeline runs on GitHub Actions.

See procedure steps above for GitHub-specific guidance.

Toolkit Reference

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.

PreviousUpNext
Phase 01 - ConfigurationPhase 01 - ConfigurationTask 02 - Management Mode

Version Control​

VersionDateAuthorChanges
1.0.02026-03-24Azure Local CloudInitial release