Infra2024년 11월 8일1분 읽기

Terraform 상태 관리 — Remote State와 워크스페이스

YS
YoungSam
조회 550

왜 Remote State인가

로컬 상태 파일은 팀 협업과 CI/CD에서 문제를 일으킵니다. S3 + DynamoDB로 안전한 Remote State를 구성합니다.

S3 Backend 설정

terraform {
  backend "s3" {
    bucket         = "my-terraform-state"
    key            = "prod/terraform.tfstate"
    region         = "ap-northeast-2"
    dynamodb_table = "terraform-lock"
    encrypt        = true
  }
}

워크스페이스

terraform workspace new staging
terraform workspace select production
# 같은 코드로 여러 환경 관리
TerraformIaCDevOps

댓글 0

아직 댓글이 없습니다.