Prompt
How do I move from manual cloud changes to infrastructure as code?
Latest observation
Moving from manual cloud changes to Infrastructure as Code (IaC) is mostly a process change, not just a tooling change. The goal is to make your cloud setup repeatable, reviewable, and version-controlled instead of edited by hand in a console.
Here’s a practical path:
1) Start by inventorying what exists
Before writing code, document your current cloud resources:
- Networks/VPCs, subnets, firewalls/security groups
- Compute instances, containers, autoscaling
- Databases, storage buckets, IAM roles/policies
- DNS, load balancers, certificates
- Monitoring/alerts
This gives you a baseline and helps identify what should be managed by IaC first.
2) Pick one IaC tool
Common choices:
- Terraform: cloud-agnostic, popular, strong ecosystem
- AWS CloudFormation / Azure Bicep / GCP Deployment Manager: cloud-native
- Pulumi: use general-purpose languages like Python/TypeScript
If you want broad adoption and multi-cloud flexibility, Terraform is often the default choice.
3) Choose a small, low-risk starting point
Don’t try to convert everything at once. Start with:
- A dev environment
- A single service
- A non-critical network or storage component
This lets you learn the workflow without risking production outages.
4) Define a clean repo structure
Use version control from day one. A typical structure:
modules/for reusable building blocksenvironments/dev/,environments/staging/,environments/prod/- Separate state/config per environment
Keep changes in Git so every infrastructure change has a history and review.
5) Recreate, don’t “copy” manually
Manually built resources often contain drift, inconsistencies, or one-off settings. As you convert them:
- Write code for the desired state
- Import existing resources if needed
- Compare actual vs desired
- Fix any drift rather than encoding bad habits
6) Add a review and deployment workflow
Treat infrastructure like software:
- Open pull requests for changes
- Run formatting/linting/validation in CI
- Require review before apply
- Separate plan and apply steps
- Restrict who can apply to prod
A good workflow is:
- Edit IaC in a branch
- Run
planin CI - Review diff
- Merge
- Apply via pipeline or approved process
7) Automate state and secrets carefully
Important implementation details:
- Use remote state storage with locking
- Never store secrets directly in code
- Integrate with secret managers or encrypted variables
- Control access to state files, since they may contain sensitive data
8) Reduce manual changes
Once IaC is in place:
- Make the console read-only for most users
- Establish a policy that cloud changes must go through IaC
- Use alerts or drift detection to catch out-of-band changes
If people still make manual changes, your IaC will quickly become inaccurate.
9) Build modules and standards
As adoption grows, standardize:
- Naming conventions
- Tagging policies
- Network/security patterns
- Logging/monitoring defaults
Then package these as reusable modules so teams don’t reinvent them.
10) Migrate incrementally
A sensible migration order is:
- Shared foundational resources
- Dev/test environments
- Application infrastructure
- Production
- Legacy or edge-case resources last
Avoid “big bang” migrations unless the environment is small.
11) Expect a short learning curve
Teams often hit these issues:
- Drift between code and real resources
- Unclear ownership
- Slow approvals
- State conflicts
- Overly large initial modules
These are normal. Start simple, iterate, and tighten process over time.
A good target operating model
Eventually, you want:
- All infrastructure changes in Git
- Automated validation and plan generation
- Controlled applies
- Minimal console edits
- Drift detection and audits
- Reusable modules and environment templates
A simple first milestone
A strong first milestone is:
- One service deployed via IaC
- CI validates it
- A PR is required for changes
- Manual edits are no longer used for that service
If you want, I can also give you:
- a step-by-step migration plan,
- a Terraform example repo structure, or
- a 90-day rollout plan for a team.