_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

Terraform from Scratch

19. 10. 2022 1 min read advanced

Cloud Intermediate

Terraform from Scratch

TerraformIaCInfrastructure 3 min read

Infrastructure as Code with Terraform. Providers, resources, state, and first deployment.

Basics

# main.tf
terraform {
  required_providers {
    aws = { source = "hashicorp/aws", version = "~> 5.0" }
  }
}

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

resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t3.micro"
  tags = { Name = "web-server" }
}

output "public_ip" { value = aws_instance.web.public_ip }

Workflow

terraform init     # Download providers
terraform plan     # Show what will change
terraform apply    # Apply changes
terraform destroy  # Destroy everything

State

Terraform stores state in terraform.tfstate. In a team, always use remote state (S3, Azure Blob, Terraform Cloud).

Summary

Terraform is the de facto standard for IaC. Start with the plan/apply workflow and remote state.

Need Help with Implementation?

Our team has experience designing and implementing modern architectures. We’re happy to help.

Free Consultation

Share:

CORE SYSTEMS tým

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