문서 목차
이 페이지에서목차

terraform-plan

Terraform으로 인프라를 바꾸기 전에 변경 내용을 검토할 때 사용합니다. 추가·수정·삭제될 자원을 확인하고 예상하지 못한 변경을 찾아냅니다.

한마디로#

추가·수정·삭제될 자원을 확인하고 예상하지 못한 변경을 찾아냅니다.

무엇을·언제#

  • 무엇을 해 주나요?
    • 클라우드 인프라(서버, 네트워크 등) 설정을 실제로 적용하기 전에 무엇이 추가·변경·삭제되는지 목록으로 보여 줍니다.
    • 일부 구성 요소가 빠져 있어 미리보기가 실패하는 흔한 문제(Lambda ZIP 파일 누락)를 자동으로 해결해 줍니다.
    • 특정 부분만 골라서 미리보기하거나, 작업 환경(운영/스테이징 등)을 바꿔 가며 확인할 수 있습니다.
  • 언제 작동하나요?
    • 설정 코드를 바꾼 뒤 잘 바뀌는지 확인하고 싶을 때
    • 어떤 변경이 어디까지 영향을 주는지 파악하고 싶을 때
    • 전체가 아닌 일부 자원만 골라 미리보기하고 싶을 때

핵심 용어#

용어쉬운 설명
Terraform클라우드 인프라(서버, 네트워크 등)를 코드로 정의하고 관리하는 도구
Plan실제로 바꾸기 전에 "무엇이 바뀔지" 미리 보여 주는 미리보기 단계
Apply미리보기에서 확인한 변경을 실제로 적용하는 단계
Lambda서버를 직접 두지 않고 필요할 때만 실행되는 작은 클라우드 프로그램
ZIP (placeholder)프로그램 파일을 압축한 묶음. 진짜 파일이 없을 때 임시로 채워 넣는 빈 묶음을 placeholder라고 함
-target 옵션전체가 아니라 지정한 일부만 골라서 미리보기하는 설정
destroy자원을 삭제한다는 뜻. 예상에 없던 삭제가 있으면 위험 신호
workspace운영·스테이징 등 서로 다른 작업 환경을 구분해 두는 공간
module여러 설정을 묶어 재사용할 수 있게 만든 설정 꾸러미

Runs Terraform plan to preview infrastructure changes. Automatically resolves Lambda ZIP file missing issues.

Triggers#

  • Plan verification after Terraform code changes
  • Infrastructure change impact analysis
  • Plan specific resources with -target option

Lambda ZIP Placeholder Auto-Handling#

Problem#

The filebase64sha256() function evaluates expressions for all resources regardless of -target option. Since Lambda ZIP files are only built in CI, running plan locally causes file missing errors.

Solution#

Analyzes ${path.module}/../../../lambda/ paths within modules and creates placeholder ZIPs at the correct locations.

# Module-relative path resolution
# modules/pdf_processing/../../../lambda/python/ → deploy/aws/lambda/python/
# Resolved relative to module file location, NOT the terraform execution directory

See "Local Placeholder Generation" in lambda-management/SKILL.md for the placeholder ZIP generation script

ZIP File Path Mapping#

ModulePath (from module)Actual Path (from deploy/aws/)
pdf_processing ${path.module}/../../../lambda/python/pdf_router/build/pdf-router.zip lambda/python/pdf_router/build/pdf-router.zip
pdf_processing ${path.module}/../../../lambda/python/pdf_processor/build/pdf-processor.zip lambda/python/pdf_processor/build/pdf-processor.zip
pdf_processing ${path.module}/../../../lambda/python/pdf_page_processor/build/pdf-page-processor.zip lambda/python/pdf_page_processor/build/pdf-page-processor.zip
pdf_processing ${path.module}/../../../lambda/python/pdf_aggregator/build/pdf-aggregator.zip lambda/python/pdf_aggregator/build/pdf-aggregator.zip
pdf_processing ${path.module}/../../../lambda/python/pdf_prepare_batches/build/pdf-prepare-batches.zip lambda/python/pdf_prepare_batches/build/pdf-prepare-batches.zip
pdf_processing ${path.module}/../../../lambda/python/layers/pymupdf/build/x86_64/pymupdf-layer.zip lambda/python/layers/pymupdf/build/x86_64/pymupdf-layer.zip
batch_processing ${path.module}/../../../lambda/python/book_batch_processor/build/book-batch-processor.zip lambda/python/book_batch_processor/build/book-batch-processor.zip
message abspath(var.push_forwarder_lambda_path) lambda/dart/sqs_to_sns/build/x86_64/sqs_to_sns.zip
message abspath(var.fcm_topic_manager_lambda_path) lambda/go/fcm_topic_manager/build/x86_64/fcm_topic_manager.zip

fileexists() Check Status#

Modulefileexists()Notes
message✅source_code_hash = null if file missing
batch_processing✅batch_processor_zip_exists local variable
pdf_processing ❌ (called directly in lambda.tf) File always required

Plan Execution Patterns#

Plan Specific Resources Only#

# Check module names (module block names in main.tf)
# production_env, staging_env, development_env (NOT production, staging, etc.)

terraform plan \
  -target='module.production_env[0].aws_route53_record.deeplink' \
  -target='module.staging_env[0].aws_route53_record.deeplink'

Workspace Switch#

# Check current workspace
terraform workspace list

# Switch workspace (production, staging, default)
terraform workspace select production

Note: This project manages environments with a workspace + enable_*_server flag combination. Within each workspace, feature flags conditionally create per-environment resources.

Checklist#

  • Lambda ZIP placeholders created (under deploy/aws/lambda/)
  • terraform init success verified
  • Impact scope limited with -target option
  • Verify no destroy resources in plan results
  • Verify expected resource change count

검색어를 입력하면 문서를 찾습니다.

↑ ↓ 이동 · Enter 열기Esc 닫기