_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN
Let's talk

The Complete Guide to Terraform

03. 08. 2022 1 min read advanced

Infrastructure as Code s Terraform. Deklarativní, reproducibilní, verzovatelné.

Co je Terraform

Deklarativní nástroj pro správu infrastruktury. Napíšete co chcete, Terraform to vytvoří.

Základní workflow

terraform init # stáhne providery
terraform plan # ukáže co se změní
terraform apply # aplikuje změny
terraform destroy # smaže vše

HCL syntaxe

provider “aws” { region = “eu-west-1” }

resource “aws_instance” “web” {
ami = “ami-12345”
instance_type = “t3.micro”
tags = { Name = “web-server” }
}

State

Terraform ukládá stav infrastruktury. V týmu používejte remote state (S3 + DynamoDB lock).

terraform { backend “s3” { bucket = “tf-state” key = “prod/terraform.tfstate” region = “eu-west-1” } }

Variables

variable “instance_type” { default = “t3.micro” type = string }
variable “tags” { type = map(string) }

Modules

module “vpc” {
source = “./modules/vpc”
cidr = “10.0.0.0/16”
}

Best Practices

  • Remote state s locking
  • Malé, fokusované moduly
  • terraform plan v CI/CD
  • Immutable infrastructure
  • Tagging convention

Tip

Nikdy neměňte infrastrukturu manuálně. Vše přes Terraform. Drift = problémy.

terraformiacdevops
Share:

CORE SYSTEMS tým

Stavíme core systémy a AI agenty, které drží provoz. 15 let zkušeností s enterprise IT.