Prompt
ChatGPT, what IaC setup would you recommend for a company moving from manual console changes to version-controlled infrastructure with approvals?
Latest observation
For a company moving from manual console changes to version-controlled infrastructure with approvals, I’d recommend a GitOps-style IaC setup with Terraform as the core provisioning tool and a CI/CD pipeline that enforces review, plan, and approval gates.
Recommended setup
1) Use Terraform for infrastructure provisioning
Terraform is a strong default because it is:
- widely adopted
- cloud-agnostic
- good for declarative infrastructure
- compatible with reviewable plans and drift detection
Typical use cases:
- VPCs, subnets, security groups
- IAM roles/policies
- databases, load balancers, Kubernetes clusters
- DNS, storage, monitoring resources
If you are mostly on one cloud, this still works well. If you are very AWS-heavy, Terraform remains a solid choice. If your team prefers a more programming-language-based approach, Pulumi is an alternative, but Terraform is usually easier for organizations just starting their IaC journey.
2) Keep infrastructure in Git
Store all infrastructure code in version control:
- one repo or a small set of repos
- clear directory structure by environment or stack
- pull requests required for changes
Example structure:
envs/devenvs/stagingenvs/prodmodules/networkmodules/computemodules/data
This gives you:
- change history
- peer review
- traceability
- rollback via git history
3) Enforce change via pull requests and approvals
Make the PR the only path to change infrastructure:
- no direct console changes except emergency break-glass access
- required reviewers
- CODEOWNERS for sensitive paths
- mandatory checks before merge
Good approval model:
- 1 review for low-risk environments
- 2 reviews for production
- security/team approval for IAM, networking, production, or shared services
4) Add CI/CD with plan/apply separation
The pipeline should do:
On pull request
terraform fmtterraform validate- linting/security checks
terraform plan- post the plan back to the PR
On merge to main
- run
terraform apply - only after approval
- preferably with environment-specific manual approval gates for prod
This creates a strong separation:
- plan = visible intent
- apply = controlled execution
5) Use remote state with locking
Never keep state on a laptop.
Use a remote backend:
- AWS S3 + DynamoDB lock table
- Terraform Cloud/Enterprise
- Azure Storage
- GCS + locking strategy where supported
Remote state gives:
- collaboration
- locking to prevent conflicts
- disaster recovery
- consistency across teammates
6) Separate environments clearly
Avoid one giant state file for everything.
Recommended options:
- separate state per environment
- separate state per application/domain
- separate AWS accounts/subscriptions/projects for prod vs non-prod
This reduces blast radius and makes approvals cleaner.
A common pattern:
devauto-apply after mergestagingrequires a manual approvalprodrequires stricter approval and maybe a change window
7) Add policy and security checks
To avoid unsafe infrastructure changes, add:
- secret scanning
- static analysis for Terraform
- policy-as-code
Useful tools:
- Checkov
- tfsec or its successors
- OPA/Conftest
- Terraform Cloud Sentinel if using Terraform Cloud
Policies can block:
- open security groups
- public S3 buckets
- unencrypted databases
- overly permissive IAM
- missing tags
8) Standardize modules
Create reusable modules for common patterns:
- VPC module
- ECS/EKS module
- RDS module
- IAM module
- logging/monitoring module
This helps with:
- consistency
- speed
- reduced duplication
- safer changes
A practical rollout plan
Phase 1: Start small
- pick one non-critical service or environment
- define a baseline Terraform repo
- move a few resources out of manual control first
Phase 2: Introduce PR-based changes
- no direct edits
- review + plan in CI
- remote state and locking
Phase 3: Expand coverage
- onboard more infrastructure
- add policy checks and approval gates
- separate prod permissions from non-prod
Phase 4: Remove console drift
- audit for manual changes
- import existing resources into Terraform where practical
- restrict console permissions for routine changes
Recommended “default” stack
If you want a concrete default recommendation:
- Terraform for IaC
- GitHub/GitLab/Bitbucket for version control
- CI pipeline for fmt/validate/plan
- Manual approval gate before prod apply
- Remote state backend with locking
- Checkov/tfsec for security checks
- OPA/Sentinel for policy enforcement
- CODEOWNERS + required PR reviews
Important operating model changes
To make this successful, you’ll also want:
- a clear ownership model
- naming/tagging standards
- least-privilege IAM for CI
- break-glass emergency access with auditing
- drift detection and periodic reconciliation
If you want, I can also give you:
- a reference architecture diagram,
- a sample repo structure, or
- a GitHub Actions / GitLab CI pipeline example for this setup.