GitHub Actions workflow
Theterraform-apply.yml workflow automates infrastructure deployment.
Workflow steps
- Terraform Init - Initialize with environment-specific backend
- tfsec Scan - Security scanning (fails on HIGH severity)
- Format Check - Validate code formatting
- Generate tfvars - Pull secrets from Key Vault
- Terraform Plan - Show proposed changes
- Terraform Apply - Apply changes (only on merge)
Triggers
Manual deployment
For exceptional cases, use the workflow_dispatch trigger:1
Navigate to Actions
Go to Actions → Terraform Apply
2
Run workflow
Click Run workflow
3
Configure
- Select branch
- Select environment
- Choose whether to apply after plan
4
Monitor
Watch the workflow execution
Sandbox environment
Use sandbox for testing infrastructure changes before committing.Step 1: connect to Azure
Step 2: create sandbox.tfvars
sandbox.tfvars:
env→"sbx"(or similar unique prefix)subscription_id→ your subscription ID
Step 3: provision base resources
Step 4: add secrets
Populate Key Vault with secrets via Azure Portal or CLI.Step 5: provision remaining resources
Environment commands
Dev environment
QA environment
Production environment
Quick reference
State management
Troubleshooting
Empty Variables in Generated tfvars
Empty Variables in Generated tfvars
You likely don’t have Key Vault Secrets Officer access. Request access and repopulate the tfvars file.
State Lock Errors
State Lock Errors
Break the blob lease:
Permission Errors
Permission Errors
Verify login and subscription:
Module Changes Not Reflected
Module Changes Not Reflected
Upgrade modules:
Review requirements
The branch-enforcement action prevents unauthorized merges.