Infrastructure as Code
Lernen Sie, wie Infrastructure as Code Cloud-Ressourcen deklarativ definiert und dadurch wiederholbare, versionskontrollierte und automatisierte Bereitstellung ermöglicht.
Infrastructure as Code ist eine kostenlose System Design Basics for Backend Developers-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des System Design Basics for Backend Developers-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der System Design Basics for Backend Developers-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
From Clicking to Code
Manually clicking through a cloud console to create servers and networks is slow, error-prone, and impossible to reproduce. Infrastructure as Code (IaC) defines your infrastructure in files you can version, review, and re-run.
Why IaC Matters
IaC brings software engineering discipline to infrastructure:
- Version control and code review for changes
- Reproducible environments (dev, staging, prod identical)
- Automated, fast provisioning and teardown
- Self-documenting infrastructure
Declarative vs Imperative
IaC tools are usually declarative: you describe the desired end state and the tool figures out how to get there. Imperative scripts instead list the exact steps. Declarative is easier to reason about and converge to.
A Declarative Resource
Here is a declarative definition of a virtual machine. You state what should exist; the tool creates or updates it to match.
resource "aws_instance" "web" {
ami = "ami-123456"
instance_type = "t3.micro"
tags = {
Name = "web-server"
}
}Idempotency
A core IaC property is idempotency: applying the same definition repeatedly yields the same result. If the resource already matches, nothing changes. This makes re-runs safe.
State and Drift
Many tools track a state of what they manage. When reality diverges — someone changes a resource by hand — that is drift. The tool detects drift and can reconcile infrastructure back to the declared definition.
Plan Before Apply
Good IaC workflows preview changes before applying them. A plan step shows exactly what will be created, changed, or destroyed, so you catch a destructive change in review rather than in production.
$ terraform plan
+ aws_instance.web will be created
~ aws_security_group.sg will be updated
- aws_instance.old will be destroyedProvisioning vs Configuration
Two related but distinct jobs:
- Provisioning creates infrastructure (Terraform, CloudFormation, Pulumi)
- Configuration management sets up software on existing machines (Ansible, Chef, Puppet)
Containers and immutable images blur this line.
Modules and Reuse
Avoid copy-paste by packaging infrastructure into reusable modules with input variables. One well-tested module can stamp out identical, parameterized environments for many teams.
module "web" {
source = "./modules/app"
instance_type = "t3.small"
env = "production"
}IaC and Cloud-Native CI/CD
IaC fits naturally into pipelines: a commit triggers a plan, review approves it, and the pipeline applies it. Combined with containers and Kubernetes manifests, the entire stack — network, cluster, and apps — becomes reproducible from code.
Best Practices
Keep IaC healthy: store state remotely and locked, never hardcode secrets, review every plan, keep modules small, and treat infrastructure code exactly like application code — tested and reviewed.
Quick Check
Test your understanding of Infrastructure as Code.
Recap
You learned the foundations of Infrastructure as Code:
- Declarative definitions describe desired state idempotently
- State tracking detects and reconciles drift
- Plan before apply to preview changes safely
- Modules enable reuse; IaC integrates into CI/CD pipelines
Häufig gestellte Fragen
Ist die Lektion „Infrastructure as Code“ kostenlos?
Ja — der vollständige Text von „Infrastructure as Code“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des System Design Basics for Backend Developers-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der System Design Basics for Backend Developers-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Infrastructure as Code“?
Lernen Sie, wie Infrastructure as Code Cloud-Ressourcen deklarativ definiert und dadurch wiederholbare, versionskontrollierte und automatisierte Bereitstellung ermöglicht. Du übst System Design Basics for Backend Developers mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um System Design Basics for Backend Developers zu starten?
Keine Vorkenntnisse erforderlich. System Design Basics for Backend Developers auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Infrastructure as Code“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser System Design Basics for Backend Developers-Lektion Code schreiben und ausführen?
Ja. Jede System Design Basics for Backend Developers-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Serverlose Architekturen
- Containerisierung mit Docker und K8s
- Observability und verteiltes Tracing
- Infrastructure as Code