infrastructure / DevOps
Multi-Cloud Terraform CI/CD: A Governance-First Pipeline for Azure and AWS
A CI/CD pipeline built in Azure DevOps that validates and plans Terraform changes across both Microsoft Azure and Amazon Web Services before anything is ever applied — designed around a simple principle: in a multi-cloud environment, uncontrolled infrastructure change is often a bigger risk than a lack of automation.
The problem
Running infrastructure-as-code across two cloud providers raises the stakes on every change: a Terraform apply that goes wrong doesn't just affect one platform, and there's no single, familiar console to catch a mistake before it ships. Without a shared, enforced process, each provider tends to accumulate its own ad hoc habits for running Terraform — inconsistent state handling, no common review step, and no guarantee that a change was actually inspected by a person before it touched production infrastructure.
The goal was a single pipeline that treats both clouds the same way: every change gets validated and planned automatically, every plan is reviewable by a human before anything happens, and nothing gets applied without that explicit step — enforced by the pipeline itself, not by hoping everyone follows the same manual process.
Architecture
The pipeline is validation-only by design. A single trigger produces independent, reviewable plans for each cloud provider, sharing one common governance model:
┌────────────────────────┐
│ Developer PR │
└───────────┬────────────┘
│
▼
┌────────────────────────┐
│ Azure DevOps CI/CD │
│ (Validation Pipeline) │
└───────────┬────────────┘
│
├────────────► Terraform Validate
│
├────────────► Terraform Plan (Azure)
│ │
│ ▼
│ Azure Blob Storage
│ (Remote State)
│
└────────────► Terraform Plan (AWS)
│
▼
Amazon S3 + DynamoDB
(State & Locking)
Deliberately, there is no terraform apply stage anywhere in this pipeline. Every run produces a plan, published as a pipeline artifact, and a human reviews it before any infrastructure actually changes — the pipeline enforces that review happens, rather than relying on it as an unenforced convention.
What I actually did
Set up remote state for both platforms independently, so state handling, locking, and collaboration work the same predictable way regardless of which cloud a given change targets:
terraform {
backend "azurerm" {
resource_group_name = "rg-terraform-state"
storage_account_name = "tfstatemulticloud"
container_name = "tfstate"
key = "azure/infra-cicd.tfstate"
}
}
terraform {
backend "s3" {
bucket = "tfstate-multi-cloud-infra-cicd"
key = "aws/infra-cicd.tfstate"
region = "us-west-2"
dynamodb_table = "terraform-state-locks"
encrypt = true
}
}
Kept provider configuration deliberately minimal and free of hardcoded credentials — authentication for both clouds is handled entirely through Azure DevOps service connections, not embedded in the Terraform code itself:
provider "azurerm" {
features {}
}
provider "aws" {
region = var.region
}
Built the pipeline around three explicit, independent stages — Terraform Validate to catch syntax and provider errors early, then a separate Terraform Plan stage for each cloud, so an Azure-only change and an AWS-only change are each reviewed on their own terms rather than conflated into one combined output.
Notable issues along the way
- AWS credentials silently not reaching the pipeline
- Terraform failed with a generic
NoCredentialProviderserror inside the pipeline, despite the same credentials working fine locally. Generic shell tasks and variable groups weren't reliably injecting them into the CI environment. Resolved by switching to a proper AWS service connection and the dedicated AWS Toolkit shell task, ensuring credentials were present before Terraform ever tried to initialize. - a clean build agent with no memory of the last run
- The AWS plan stage intermittently failed during backend initialization, traced to Azure DevOps' ephemeral build agents starting with no cached Terraform state or providers between runs. Fixed by explicitly forcing
terraform init -reconfigureon every single execution, rather than assuming any state from a prior run would still be present. - pipeline failures before the pipeline even ran
- Several early runs failed before execution even started, due to YAML structure and indentation issues that Azure DevOps couldn't resolve into a valid pipeline definition. Resolved by restructuring the YAML to strictly follow Azure DevOps' schema rules and validating it directly against the platform's own YAML validator, rather than iterating by trial and error against live runs.
Why this approach matters
In regulated or enterprise environments, the biggest infrastructure risk usually isn't a lack of automation — it's automation that nobody reviewed before it ran. This pipeline is built around that distinction: every change, on either cloud, gets a reviewable, human-readable plan before it's trusted, and the absence of an apply stage means that review step can never be accidentally skipped. The governance model is the same whether the change is three lines in an Azure resource or a new AWS data pipeline, which matters as much for consistency and auditability as it does for catching mistakes.
Skills demonstrated
Terraform · Azure DevOps Pipelines · Multi-cloud infrastructure governance · Azure Blob Storage remote state · AWS S3 + DynamoDB state locking · Service connection-based authentication · YAML pipeline design · CI/CD troubleshooting · Infrastructure-as-Code review processes
Outcome
The result is a single, consistent governance model covering infrastructure changes across two cloud providers: every change is validated and planned automatically, every plan is reviewable before anything happens, and no infrastructure is ever applied without an explicit, visible human decision. The pipeline functions as a guardrail rather than a shortcut — enforcing the exact kind of review discipline that regulated and enterprise environments expect, applied uniformly regardless of which cloud a given change targets.