Prompt
How do I version-control cloud infrastructure changes?
Latest observation
Oct 25, 2026
OpenAI APIWeb search: off
The standard way to version-control cloud infrastructure is Infrastructure as Code (IaC) plus Git.
Core idea
Treat infrastructure like software:
- Write cloud resources in code/config files
- Store them in a Git repo
- Review changes via pull requests
- Apply changes through CI/CD
- Keep an audit trail of every change
Common tools
Depending on your cloud/provider and preferences:
- Terraform — very common, cloud-agnostic
- AWS CloudFormation / CDK — AWS-native
- Azure Bicep / ARM templates — Azure-native
- Google Cloud Deployment Manager / Terraform — GCP
- Pulumi — use general-purpose languages like TypeScript, Python, Go
Typical workflow
-
Define infrastructure in code
- VMs, networks, databases, IAM, load balancers, buckets, etc.
-
Commit to Git
- One repo or multiple repos, depending on team structure
-
Use pull requests
- Review diffs like application code
- Require approvals for production changes
-
Run validation in CI
- Linting
- Static checks
plan/dry-run step to show what will change
-
Apply through pipeline
- Merge to main triggers deployment
- Use separate environments: dev, staging, prod
-
Track state carefully
- For tools like Terraform, store state in a remote backend with locking
Best practices
- Avoid manual console changes if possible; they create drift
- Use separate environments
- Keep secrets out of Git
- Use secret managers, environment variables, or encrypted files
- Modularize
- Reusable modules for networking, compute, databases
- Tag and branch releases
- Useful for rollback and auditability
- Enable drift detection
- Compare actual cloud state with desired state regularly
A simple example with Terraform
You might have files like:
main.tfvariables.tfoutputs.tfterraform.tfstatestored remotely, not locally
Your workflow:
- edit
main.tf - run
terraform plan - open PR with the plan output
- merge after review
- run
terraform applyvia CI/CD
What to version
Version-control:
- infrastructure definitions
- modules/components
- policy-as-code
- pipeline definitions
- environment-specific overlays/config
Don’t version-control:
- raw secrets
- ephemeral runtime state
- generated artifacts unless needed for compliance
If you want a practical setup
A good default for most teams is:
- Git + Terraform
- remote state in S3 + DynamoDB (AWS) or equivalent backend
- CI pipeline that runs
fmt,validate,plan - PR approvals required for
apply - separate workspaces or folders for dev/staging/prod
If you want, I can also show:
- a sample Git workflow,
- a Terraform repo structure, or
- a CI/CD pipeline example for GitHub Actions/GitLab/Azure DevOps.