Prompt
How do I use IaC to provision AWS and Azure consistently?
Latest observation
To provision AWS and Azure consistently with Infrastructure as Code (IaC), the key is to standardize how you describe infrastructure, how you deploy it, and how you govern it across both clouds.
1) Pick an IaC tool that supports both clouds
The most common options are:
- Terraform: best-known multi-cloud IaC tool; strong AWS/Azure support
- Pulumi: use general-purpose languages like TypeScript, Python, Go
- Crossplane: Kubernetes-native control plane for multi-cloud resources
- AWS CDK + Azure Bicep: useful individually, but less consistent across both clouds
If your goal is one consistent workflow across AWS and Azure, Terraform is usually the simplest choice.
2) Define shared patterns, not cloud-specific one-offs
Instead of writing separate ad hoc configs, create reusable modules/components for common patterns like:
- Virtual networks / subnets
- IAM / RBAC
- Compute instances or containers
- Storage
- Load balancers
- Logging and monitoring
- Tags/labels
- Network security rules
Design these modules with a common interface, e.g.:
environmentregionnametagscidrinstance_type/skuavailability_zones
Then map those abstractions to AWS or Azure internally.
3) Use a consistent repo structure
Example:
infra/
modules/
network/
compute/
storage/
observability/
envs/
dev/
aws/
azure/
prod/
aws/
azure/
Or, if you prefer fewer directories, keep:
infra/
modules/
stacks/
dev-aws/
dev-azure/
prod-aws/
prod-azure/
The point is to keep:
- Reusable modules in one place
- Environment-specific config separate
- Cloud-specific implementation details isolated
4) Standardize naming, tags, and metadata
Use a shared convention across both clouds.
Example:
app = paymentsenv = devowner = platform-teamcost_center = 1234managed_by = terraform
In AWS these become tags; in Azure they become tags as well.
That lets you unify:
- cost tracking
- inventory
- ownership
- policy enforcement
- automation
5) Use remote state and locking
For Terraform, store state centrally:
- AWS: S3 + DynamoDB lock table
- Azure: Azure Blob Storage with state locking support
- Or use Terraform Cloud / HCP Terraform for both
This helps with:
- collaboration
- drift control
- safe concurrent changes
- auditability
6) Manage credentials and secrets centrally
Avoid embedding cloud creds in code.
Use:
- OIDC / federated identity from CI/CD to both clouds
- AWS IAM roles
- Azure managed identity / service principal
- Secret managers:
- AWS Secrets Manager / SSM Parameter Store
- Azure Key Vault
Prefer ephemeral auth from your CI/CD pipeline rather than long-lived keys.
7) Build policy and guardrails into the pipeline
To keep AWS and Azure consistent, enforce rules before deployment.
Examples:
- all resources must have tags
- only approved regions
- encryption enabled
- public IPs restricted
- approved instance sizes only
Tools:
- Terraform validation
- tflint
- Checkov
- OPA/Conftest
- Azure Policy
- AWS Organizations SCPs / Service Control Policies
Use both:
- IaC validation
- cloud-native policy enforcement
8) Create a deployment pipeline that is cloud-agnostic
A good workflow is:
terraform fmtterraform validate- security scan
- plan
- manual approval for prod
- apply
Do this for both clouds using the same CI/CD system:
- GitHub Actions
- GitLab CI
- Azure DevOps
- Jenkins
- Terraform Cloud run tasks
Your pipeline should parameterize:
- cloud provider
- environment
- region
- module version
9) Abstract differences carefully
AWS and Azure are similar at a high level, but many details differ:
- networking model
- IAM vs RBAC
- storage semantics
- load balancer behavior
- identity integration
- naming constraints
Don’t force a fake “universal” model where it doesn’t fit.
Instead:
- expose a common interface to teams
- handle provider-specific mapping in modules
- document cloud-specific differences
Example:
- “private subnet” maps to AWS VPC subnet and Azure VNet subnet
- “identity” maps to AWS IAM role and Azure managed identity/RBAC
10) Favor golden modules and templates
Create approved building blocks such as:
vpc-vnetecs-aksrds-azure-sqls3-blob-storagealb-application-gateway
This gives teams a safe default and reduces drift between clouds.
Example Terraform strategy
A simple approach:
Root configuration
module "network" {
source = "../../modules/network/${var.cloud}"
name = var.name
cidr = var.cidr
tags = var.tags
}
Provider selection
provider "aws" {
region = var.region
}
provider "azurerm" {
features {}
}
Environment variables
cloud = "aws" # or "azure"
region = "eastus"
name = "payments-dev"
tags = {
env = "dev"
owner = "platform"
}
You can use the same process, with provider-specific modules underneath.
Recommended operating model
If you want consistency across AWS and Azure, use this model:
- One IaC tool
- One repo structure
- One pipeline
- One tagging standard
- One policy framework
- Cloud-specific modules behind common interfaces
Practical recommendation
If you’re starting from scratch:
- Choose Terraform
- Define a standard module catalog
- Use OIDC for CI/CD auth
- Use remote state with locking
- Enforce policy as code
- Keep AWS and Azure differences inside modules, not in application teams’ workflows
If you want, I can also give you:
- a reference Terraform repo structure
- a sample multi-cloud module
- or a step-by-step CI/CD pipeline for AWS + Azure
Brands