# Cloud Infrastructure Provisioning: Bringing What You Already Have Under Code

URL: https://donedeploy.com/cloud-infrastructure-provisioning/
Published: 2026-11-30

Most guides to cloud infrastructure provisioning start from an empty account. Write a module, run `terraform apply`, watch a network and a cluster appear. That is the easy case, and it is not the one most teams are in.

The usual case looks different. The cloud account is three or four years old. The production database was created in the console during a launch week. The VPC came from a tutorial. Someone added a security group rule at midnight during an incident and nobody wrote down why. Some of it is in Terraform, some of it was in Terraform once, and the rest only exists in the cloud itself.

This post is about provisioning in that situation: how to get infrastructure you already run under code, without rebuilding it and without an outage, and how to keep it there. It is the work behind our [infrastructure as code service](https://donedeploy.com/devops-services/infrastructure-provisioning/), and the steps are the same whether you do it yourself or with us.

## What provisioning should mean

Provisioning is creating and changing the cloud resources your systems run on: networks, compute, databases, buckets, load balancers, DNS and the permissions between them. Done well, it has three properties:

- **Repeatable.** The same code builds staging and production, so they differ only where you decided they should.
- **Reviewable.** Every change is a diff someone read before it happened, with a record of who approved it and why.
- **Recoverable.** If an environment is lost, you rebuild it from Git, not from memory and screenshots.

Console clicks fail all three. A Terraform repository that covers half the account fails them too, just more quietly, because people trust it for the half it does not cover.

## Why “start fresh” is usually the wrong plan

When a team decides to adopt infrastructure as code, the tempting plan is to write everything new in a clean repository and migrate onto it. For a stateless service that can be fine. For the rest it usually is not:

- Databases, buckets and queues hold data. Recreating them means a migration, a cutover and a risk window.
- DNS records, IP addresses and certificates are referenced from outside your control.
- IAM roles are trusted by other accounts, CI systems and third parties by their exact names and identifiers.
- Two parallel environments double the bill for the length of the project, and the project always takes longer than planned.

The alternative is to **import**: tell the tool that a resource it would create already exists, so it takes ownership of the real thing instead of building a copy. Terraform supports this with `import` blocks, and Pulumi has an equivalent. The resource does not move, restart or change. It simply becomes managed by code.

## The order we bring an account under code

### 1. Inventory what actually exists

Start from the cloud, not from the repository. List every resource in every region and account you use, with its dependencies: which subnet a database sits in, which role a service uses, which security groups reference each other. Cloud providers can export most of this, and tools can generate a first draft.

This is where AI earns its place for us. A model is good at turning a long export into a readable list grouped by system, flagging resources that look abandoned and spotting dependencies a person would miss on a first pass. An engineer then checks the result, because an inventory that is confidently wrong is worse than none.

### 2. Decide what to import, what to replace and what to delete

Not everything deserves to be imported as it is. We sort each resource into one of three groups:

Group Typical examples What happens Import as is Databases, buckets, DNS zones, IAM roles others trust Brought under code with no change to the resource Rebuild in code Stateless compute, tutorial-era networks with no traffic, load balancers that are easy to swap Written fresh, switched over, the old one removed Delete Forgotten test instances, unattached volumes, keys nobody uses Confirmed with the owner, then removed

The delete column is often a pleasant surprise for the cloud bill, but the real benefit is that there is less left to understand.

### 3. Import, then make the plan empty

After importing a resource, write the code that describes it and run a plan. The goal of this step is precise: **the plan must show no changes.** An empty plan proves that the code matches reality. Any difference is a decision to make, not a fix to apply blindly. Maybe the real setting is right and the code is wrong. Maybe the real setting is the midnight incident change that should be reverted, on purpose, in its own reviewed change later.

Do this one system at a time, smallest blast radius first: a single service’s bucket and role before the shared network, the shared network before the production database.

### 4. Move applies into a pipeline

Once the code describes reality, nobody applies from a laptop again. A change is a pull request. CI runs the plan and attaches it to the pull request. A person reads it and approves, and the pipeline applies with its own short-lived credentials. State lives in a remote backend, encrypted and locked, readable by as few people as the secrets it may contain. Our post on [secrets management](https://donedeploy.com/secrets-management-best-practices/) covers why Terraform state deserves that care, and [the CI process](https://donedeploy.com/ci-process/) post covers where infrastructure checks sit among the other stages.

### 5. Watch for drift

Code and reality start drifting the day you finish. Someone will make an emergency change in the console again, and that is fine as long as it is noticed. A scheduled plan against each environment, with any non-empty result reported to the team, turns drift from a surprise during the next change into a short conversation the next morning.

## Where plan review goes wrong

The plan is the most important document in provisioning, and it is often the least read. A plan that says “1 to change” looks harmless. If that change is a database setting that forces a replacement, it is anything but.

Things worth a second look in every plan:

- **Replacements.** Anything marked to be destroyed and recreated, especially resources that hold data.
- **Permissions.** New wildcard actions, broader trust policies, security group rules open to the internet.
- **Deletions you did not intend.** Often the result of a renamed resource or a moved module.
- **Changes outside the scope of the pull request.** A sign of drift or of someone else’s unmerged work.

In our service, AI reads every plan before an engineer does and points at exactly these: what will be replaced, what gains access, what disappears. It does not approve anything. The engineer approves, with the risky lines already highlighted instead of buried on page four of the output. That is the same rule we described in [what we let AI agents touch](https://donedeploy.com/ai-agents-in-production-infrastructure/): read and propose freely, apply only through a person.

## A concrete case

Here is the shape of a typical engagement, without inventing a customer.

A team runs one product on AWS. There is a Terraform repository from an earlier contractor that covers the VPC and an old cluster. Production’s database, its buckets, the DNS zone and most of the IAM roles were created by hand. Staging was built separately and looks similar but is not.

Through the [infrastructure as code service](https://donedeploy.com/devops-services/infrastructure-provisioning/) the work would go:

1. A free first consultation to agree what matters most to get under code.
2. An inventory of the account, drafted with AI and checked by an engineer, with each resource sorted into import, rebuild or delete.
3. A fixed-price proposal for that scope and order.
4. Imports system by system, each finished when its plan is empty, then modules shared between staging and production so the two stop differing by accident.
5. A pipeline that plans on every pull request and applies after approval, with state stored safely and locked, and a scheduled drift check.

What the team owns at the end is in their own Git: the code and modules, the pipeline, documentation of the state layout and conventions, and a runbook for rebuilding an environment from code. Nothing was recreated that did not need to be, and because an import does not touch the resource itself, most of the move happens without downtime.

## Where to start this week

You do not need a project to begin. Three small steps already change how provisioning feels:

- **Run a plan against what you have.** If the existing Terraform shows changes nobody expected, you have found your drift.
- **Pick one hand-made resource and import it.** A bucket or a role is a good first one. Stop when the plan is empty.
- **Make the console read-only for one environment.** Changes to staging go through a pull request from now on, and you will learn quickly what was missing.

Cloud infrastructure provisioning is not about the first `apply`. It is about the hundredth change, a year from now, being as boring and as well understood as the first. If you would like help bringing an existing cloud under code, [book a free call](https://donedeploy.com/lets-talk/) and we will look at it with you.
