How do Azure DevOps pipelines run Terraform safely?
AdvancedConceptAzure DevOps, Bicep and Terraform
Answer
- PR pipeline:
terraform fmt -check,validate,tflint, Checkov/Trivy, thenplan -out=tfplanposted to the PR. - Publish the plan as a pipeline artifact.
- Apply stage on
maintargeting an environment with approval, applying the same saved plan (terraform apply tfplan), so what was approved is what runs. - Authenticate with a WIF service connection; separate identities for plan (Reader + state access) and apply (Contributor on scope).
- State in a storage account with RBAC, versioning and soft delete, private endpoint if agents are private.
More on Azure DevOps, Bicep and Terraform
What services make up Azure DevOps?BeginnerWhat are branch policies in Azure Repos?BeginnerExplain the YAML pipeline structure in Azure Pipelines.BeginnerWhat are service connections and how should they authenticate?IntermediateWhat are environments in Azure Pipelines?IntermediateWhat deployment strategies do deployment jobs support?Intermediate