[EN] Infrastructure as Code mit Terraform: Warum es für DevOps unerlässlich ist

Julian | Aug 8, 2025 min read

Hello everyone,

In the world of software development, we have become accustomed to versioning, testing, and managing our code in automated pipelines. But what about our infrastructure? Traditionally, the infrastructure – servers, databases, networks – was provisioned and configured manually. It’s tedious, error-prone and doesn’t scale. This is where Infrastructure as Code (IaC) comes into play, and Terraform is the tool of choice.

In this article, we delve into the world of IaC and explore why Terraform is essential for every modern DevOps team.

Was ist Infrastructure as Code?

Imagine your entire infrastructure is no longer a collection of manual clicks in a cloud console, but a collection of simple, readable code files. This is the basic idea of ​​IaC.

Instead of creating infrastructure manually, you describe it in a configuration language. An IaC tool like Terraform reads these files, understands the desired state and provisions the infrastructure accordingly. This takes us from “how” (manual steps) to “what” (desired end state).

Why Terraform is the right choice

There are various IaC tools, but Terraform has become the standard for good reasons.

1. Cloud provider independent

Terraform is cloud agnostic. It supports a variety of cloud providers (AWS, Azure, Google Cloud), SaaS providers (e.g. GitHub, Cloudflare) and even on-premise solutions. With Terraform you don’t have to learn a new tool for every provider. The basic syntax always remains the same.

2. Declarative approach

Terraform works declaratively. This means you describe the end state of your infrastructure. Terraform then finds out for itself which steps are necessary to achieve this state.

An example: You define that you want an EC2 instance and an S3 bucket. Terraform takes care of creating both resources in the correct order. If you later change the machine type of the EC2 instance, Terraform knows to only adjust that one resource without rebuilding everything. This makes updates safe and efficient.

3. Plan-and-Apply-Workflow

Terraform’s workflow is simple and secure:

  1. terraform plan: Terraform analyzes your configuration and creates an execution plan. This plan shows you exactly which resources will be created, changed or deleted. This way you can see the effects of your changes before you apply them.
  2. terraform apply: If you confirm the plan, Terraform carries out the necessary actions and provisions the infrastructure.

This plan-and-apply workflow is a critical security factor that minimizes unexpected changes and errors.

4. Consistency and reusability

Once your infrastructure is available as code, you can version it - just like your application code - with Git. This has massive advantages:

  • Consistency: Each environment (Dev, Staging, Prod) can be provisioned from the same code files. This avoids configuration drifts.
  • Reusability: You can create infrastructure modules (e.g. a module for a VPC) and reuse them in different projects. This saves time and ensures standardized setups.

Terraform in the DevOps world

IaC with Terraform is a cornerstone of DevOps. It builds a bridge between the development and business worlds.

  • Developer Self-Service: Developers can deploy their own infrastructure for testing or new features without having to wait for the operations team.
  • Automation: Terraform commands can be seamlessly integrated into CI/CD pipelines. When merging to the main branch, the pipeline can automatically run terraform plan and terraform apply to provision changes to the infrastructure.
  • Collaboration: Infrastructure code can be versioned in Git repositories. Changes are managed through pull requests and code reviews - just like in application development. This makes the work transparent and team-oriented.

A code example

Here is a simple example provisioning an S3 bucket in AWS using Terraform:

main.tf

# Definiert den AWS Provider und die Region
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

provider "aws" {
  region = "eu-central-1" # Frankfurt
}

# Definiert die Ressource 'aws_s3_bucket'
resource "aws_s3_bucket" "my_bucket" {
  bucket = "mein-erster-bucket-mit-terraform-12345" # Bucket-Namen muessen global einzigartig sein

  # Optional: Aktiviert die Versionierung des Buckets
  versioning {
    enabled = true
  }

  tags = {
    Name        = "Mein erster Terraform Bucket"
    Environment = "Dev"
  }
}

With this short, declarative code snippet you can create, version, and tag an S3 bucket.

Conclusion

Terraform is more than just a tool; it is a paradigm shift. It allows you to treat your infrastructure as code and thus benefit from the best practices of software development. It is the bridge that enables close, efficient collaboration between development and operations and makes your IaC setup scalable, secure and consistent.

How did you manage your infrastructure in your projects before using IaC? And what experiences have you had with Terraform? Let us know!