본문으로 건너뛰기

Day 1 - Terraform 입문

설치 · 기본 구조 · init / plan / apply / destroy

목차


학습 목표

  • IaC와 Terraform 역할 설명
  • initplanapply 순서 실행
  • state 파일이 무엇인지 이해

설치

# macOS
brew install terraform
terraform version

프로젝트 구조

terraform-lab/
├── main.tf
├── variables.tf # (Day 2)
├── outputs.tf # (Day 2)
└── terraform.tfstate # apply 후 생성 (gitignore 권장)

첫 실습 local_file

main.tf:

terraform {
required_version = ">= 1.5.0"
}

resource "local_file" "hello" {
content = "hello terraform"
filename = "${path.module}/hello.txt"
}
cd terraform-lab
terraform init
terraform plan
terraform apply # yes
cat hello.txt
terraform destroy # 정리

명령 흐름

명령역할
terraform init프로바이더 다운로드
terraform fmt코드 포맷
terraform validate문법 검증
terraform plan실행 계획
terraform apply실제 생성/변경
terraform destroy리소스 삭제

관련 문서

그래프 뷰

그래프 데이터 로딩 중…
현재: Day 1 - Terraform 입문
노드 클릭 → 이동 · 드래그 → 위치 조정