Skip to content
nexovia

DevOps and cloud

Infrastructure as code

With infrastructure as code, servers, networks, databases and permissions are described in Terraform files and reviewed like any other code. A new environment is created from the same files as production, and every change leaves a trace in Git. Nobody has to remember what was clicked in a console.

Infrastructure as code: an overview

Infrastructure built by clicking in a console works until the person who clicked leaves, or until you need a second environment that matches the first. Infrastructure as code with Terraform replaces that memory with files: every network, database, bucket, DNS record and IAM role is declared, versioned in Git and changed through a pull request.

The pull request is where the value is. When someone edits a Terraform file, the pipeline runs terraform plan and posts the result on the pull request, so the reviewer sees exactly what will be created, changed or destroyed. Apply runs after approval, from the pipeline, with credentials that no developer keeps on a laptop. State is stored remotely with locking, so two people cannot apply at the same time.

We keep the code plain: a few modules for what you repeat, such as a service with its database and its secrets, and one directory per environment that calls them. Deep module hierarchies and clever abstractions make a plan harder to read, and a plan nobody can read gets approved without being checked.

What the service covers

  • Cloud resources in Terraform

    Networks, compute, databases, storage, DNS records and IAM roles on AWS or Google Cloud, described in Terraform. Settings in services such as your DNS or monitoring provider can live in the same code.

  • Import of existing infrastructure

    Hand-built resources are imported into Terraform state without being recreated. The plan is brought to zero changes before any new code is written.

  • Modules and environments

    A small set of modules for what you repeat, and one directory per environment that calls them. Staging and production differ only in their values.

  • Remote state and locking

    State lives in a versioned, encrypted bucket with locking, separate for each environment. Only the pipeline and a small group of people can read it.

  • Plan and apply in CI

    Each pull request gets its plan posted as a comment, and apply runs after approval from the main branch. The apply role belongs to the pipeline and is not used by people.

  • Policy checks and drift detection

    Rules such as no public buckets and no database reachable from the internet are checked on every plan. A scheduled plan reports anything changed by hand in the console.

When it is the right call

  • 01

    Your production environment was built by hand, and you could not rebuild it from scratch if you had to.

  • 02

    Staging and production have drifted apart, and some bugs depend on which one you test in.

  • 03

    Several people have admin access to the cloud console, and nobody reviews a change before it is made.

  • 04

    You need a new environment for a customer, a region or a load test, and building it by hand would pull someone off product work.

What you get

  • Servers, networks and managed services described in Terraform

  • Environments rebuilt on demand from the same modules

  • Terraform plan reviewed in a pull request before every change

  • Import of existing, hand-built infrastructure into code

How we work on it

  1. Step 1

    Take inventory

    We list what exists in your cloud accounts, who created it and what depends on it. Resources that look unused are flagged, and nothing is removed until you confirm.

  2. Step 2

    Design the layout

    We decide how the code is split into modules, environments and state files, and who can apply what. The layout and the reasons for it go into an ADR.

  3. Step 3

    Import or recreate

    Resources worth keeping are imported into Terraform, and the plan is brought to zero changes before anything new is written. Some pieces are simpler to recreate cleanly, and we say which ones.

  4. Step 4

    Plans in pull requests

    The pipeline runs format, validation and plan on each pull request and posts the plan for review. Apply runs from the main branch with a dedicated role that can do nothing else.

  5. Step 5

    Prove it with staging

    We create a staging environment from the same modules. Anything missing from the code shows up here, before you ever need to rebuild production.

Reviewing terraform plan in pull requests

A plan is a diff of your infrastructure, and a reviewer reads it for three things: resources being destroyed, changes that force a replacement, such as a renamed database instance that Terraform would recreate, and anything touching IAM or network rules. Policy checks in the pipeline cover the rules that should never be broken, such as a public storage bucket or a firewall rule open to the whole internet, so the build fails before a person has to notice.

Changes in the console still happen during an emergency. A scheduled plan against production reports drift, and the fix is either to bring the code in line or to revert the manual change. Either way, the code ends up describing what really runs.

Terraform state, modules and separate environments

State is the file in which Terraform records what it manages, and it often contains secrets. We keep it in a remote backend, such as a cloud storage bucket with versioning and locking, encrypted and readable only by the pipeline and a small group of people. Each environment has its own state, so a mistake in staging cannot reach production.

Environments are separate directories calling the same modules with different values, rather than one configuration switched by workspaces. It means a little more text, and it lets anyone see what differs between staging and production by comparing two files.

Handling secrets and access in Terraform code

Terraform code should never contain a password or an API key, and it is easy to get this wrong. Secrets are either created in a secret manager and referenced by name, or generated by Terraform and written straight into the secret manager. Values generated this way still end up in state, which is one more reason state is encrypted and tightly restricted, and sensitive outputs are marked so they never appear in pipeline logs.

Access follows the same logic as the code. Developers open pull requests and read plans, the pipeline role applies, and very few people keep console admin rights for emergencies, with each use logged. When someone leaves, removing their access is a change to one file, reviewed like the rest.

Technologies

  • Docker
  • Kubernetes
  • Helm
  • Argo CD
  • Terraform
  • GitHub Actions
  • AWS
  • Google Cloud
  • Grafana

How you can work with us

  • Fixed-scope project

    The scope of the first version is written down, split into milestones and priced per milestone. It suits a product or a feature with a clear outline.

  • Dedicated team

    A team works on your product over the long run, with its own planning and release cadence. It suits a product that keeps changing.

  • Team extension

    One or more of our engineers join your team and work with your tools and routines. It suits a company that knows where it is going but lacks people or a specific skill.

  • Monthly support

    A monthly retainer covers maintenance, updates and small changes, with an agreed response time. It suits a product in production that needs upkeep more than new features.

Questions about Infrastructure as code

Can you move our existing infrastructure into Terraform without downtime?

In most cases, yes. Importing a resource only records it in Terraform's state without recreating it, and nothing is applied until the plan shows no unexpected changes. The exceptions are resources whose settings cannot be matched in code, which we flag and plan separately with you.

Why Terraform rather than Pulumi, CloudFormation or OpenTofu?

Terraform covers AWS, Google Cloud, DNS providers and many SaaS tools in one language, and it is widely known, which matters when you hire. OpenTofu is an open source fork that runs most Terraform code unchanged. We would not move a team off a Pulumi or CloudFormation setup that works just to change tools.

Who maintains the Terraform code after the project?

Ideally your own team, with us available if you want. The code is in your repository, the pipeline posts a plan for anyone who opens a pull request, and the README explains how to add a resource. Provider and module versions are pinned, and we can take on regular upgrades if nobody on your side has time for them.

What drives the effort of moving to infrastructure as code?

The number of resources and accounts, how consistent they are and how much was built by hand. A tidy account with one environment imports quickly. Several environments that drifted apart take longer, because each difference has to be understood and either kept as a value or removed. Resources created by other tools, such as load balancers created by a Kubernetes controller, also have to be identified so Terraform does not fight over them.

Do our developers need to learn Terraform?

Enough to read a plan and make a small change, which is not much. The modules hide the repeated detail, so adding a database or a bucket is usually a few lines calling an existing module. The README shows the common changes with examples, and reviewers catch the rest in the pull request.

Can Terraform manage Kubernetes resources too?

It can, but we draw a line between the two. Terraform creates the cluster, the node pools, the networking and the cloud resources around it, while the workloads inside the cluster are deployed by Helm and Argo CD from Git. Mixing them tends to create two sources of truth for the same object and plans that change on every run.

In the same service area

Design, build and ship your project

Describe it in three lines. We reply with specific questions and a first take on how to proceed.