Terraform Associate — Maintain Infrastructure with Terraform 개념 정리

개념(한글) + 시험용 영어 표현 매칭 대응 objective: Objective 7 (Maintain Infrastructure with Terraform)


7a. 기존 인프라 import (Import existing infrastructure)

terraform import

  • Terraform으로 만들지 않은 기존 인프라를 state로 가져오는 기능
  • import는 state에만 등록할 뿐, 구성 파일(.tf)은 자동 생성하지 않음 (직접 작성 필요)
  • 절차: 리소스 블록 작성 → terraform import <ADDRESS> <ID> → plan으로 일치 확인
개념영어 표현
기존 자원 가져오기terraform import
state에만 등록imports into state only
구성은 수동 작성configuration must be written manually
import 대상 지정terraform import <RESOURCE_ADDRESS>

import 블록 (신버전)

  • import 블록으로 구성에 선언적으로 import 정의 가능
  • terraform plan -generate-config-out으로 구성 초안 생성 지원
개념영어 표현
선언적 importimport block
구성 초안 생성-generate-config-out

7b. CLI로 state 조회 (Use the CLI to inspect state)

State 조회 명령

명령역할
terraform state liststate에 있는 모든 리소스 주소 나열
terraform state show 특정 리소스의 속성 상세 조회
terraform show전체 state 또는 plan 파일 내용 출력
terraform output정의된 output 값 조회
terraform refresh실제 인프라와 state 동기화 (구식, -refresh-only 권장)
개념영어 표현
리소스 목록 조회terraform state list
리소스 상세 조회terraform state show
전체 state/plan 출력terraform show
output 값 조회terraform output

7c. verbose 로깅 (Describe when and how to use verbose logging)

로그 활성화 (TF_LOG)

  • 환경 변수 **TF_LOG**로 상세(verbose) 로그를 켬 → 디버깅에 사용
  • 예상치 못한 동작, 오류, provider 통신 문제 등을 추적할 때 사용

로그 레벨 (Log levels)

레벨의미
TRACE가장 상세 (기본값, 최대 정보)
DEBUG디버그 수준
INFO일반 정보
WARN경고
ERROR오류만

로그 파일 저장

  • TF_LOG_PATH 환경 변수로 로그를 특정 파일에 저장
  • provider 전용 로그는 TF_LOG_PROVIDER, core 로그는 TF_LOG_CORE로 분리 가능
개념영어 표현
로그 활성화 변수TF_LOG
가장 상세한 레벨TRACE
로그 파일 경로TF_LOG_PATH
언제 사용for debugging / troubleshooting

요약

주제내용
importterraform import — state에만 등록, 구성은 수동 작성
신버전 importimport 블록 + -generate-config-out
state 조회state list / state show / show / output
verbose 로깅환경 변수 TF_LOG (TRACE~ERROR), 파일 저장은 TF_LOG_PATH
로깅 목적디버깅·트러블슈팅