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.