docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거

Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
Antigravity Agent
2026-07-05 00:33:48 +09:00
parent 1cfd3bbb56
commit 9148c358d0
6455 changed files with 1 additions and 86875 deletions
@@ -0,0 +1,150 @@
---
id: devops-iac-drift-detection
title: IaC Drift Detection — 수동 변경 감지
category: Coding
status: draft
source_trust_level: B
verification_status: conceptual
created_at: 2026-05-09
updated_at: 2026-05-09
tags: [devops, iac, terraform, drift, vibe-coding]
tech_stack: { language: "Terraform / AWS", applicable_to: ["DevOps"] }
applied_in: []
aliases: [drift, manual change, terraform plan exit code, driftctl, AWS Config]
---
# IaC Drift Detection
> Console 에서 누가 손댐 = drift. 다음 apply 가 모르는 사이 덮음. **정기 plan + 알람** 으로 검출. driftctl / AWS Config / Terraform Cloud Health Assessment.
## 📖 핵심 개념
- Drift: state 와 실제 인프라 차이.
- 원인: 콘솔 변경, 다른 도구 (kubectl), 만료 / 오토 변경.
- Prevention: SCP / IAM 으로 console write 차단.
- Detection: 자동 plan + diff 알림.
## 💻 코드 패턴
### Terraform plan exit code
```bash
terraform plan -detailed-exitcode -lock=false -refresh-only
# 0 = no change
# 1 = error
# 2 = drift / changes pending
```
### CI cron (GitHub Actions)
```yaml
name: drift-check
on:
schedule: [{ cron: '0 6 * * *' }] # 매일 오전 6시
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
- run: terraform init
- id: plan
run: terraform plan -detailed-exitcode -refresh-only -no-color | tee plan.txt
continue-on-error: true
- if: steps.plan.outcome == 'failure'
run: |
curl -X POST $SLACK_WEBHOOK \
-d "{\"text\":\"Drift detected in prod: $(head -200 plan.txt)\"}"
```
### Terraform Cloud Health Assessment
- TFC enterprise: 자동 drift detection daily.
- UI 에서 check + Slack notification.
### driftctl
```bash
# 모든 리소스 (TF state 안 / 밖 무관) 비교
driftctl scan --from tfstate+s3://tf-state/main.tfstate
# unmanaged 리소스 (TF 외부 생성) 도 발견
```
### AWS Config (cloud native)
```hcl
resource "aws_config_configuration_recorder" "main" {
name = "main"
role_arn = aws_iam_role.config.arn
recording_group { all_supported = true }
}
resource "aws_config_config_rule" "no_unencrypted_volumes" {
name = "encrypted-volumes"
source { owner = "AWS"; source_identifier = "ENCRYPTED_VOLUMES" }
}
```
위반 시 EventBridge 로 알림 / 자동 remediation.
### Lifecycle ignore_changes (의도적 drift 허용)
```hcl
resource "aws_autoscaling_group" "app" {
desired_capacity = 3
lifecycle {
ignore_changes = [desired_capacity] # HPA 가 관리, TF 가 안 덮음
}
}
```
### Prevent destroy (중요한 자원)
```hcl
resource "aws_db_instance" "main" {
lifecycle {
prevent_destroy = true
}
}
```
`terraform destroy` 시 에러.
### 콘솔 write 차단 (IAM / SCP)
```json
// 모든 사람 read-only, terraform IAM role 만 write
{
"Effect": "Deny",
"Action": ["ec2:*", "rds:*", "s3:CreateBucket"],
"Resource": "*",
"Condition": {
"StringNotEquals": { "aws:PrincipalArn": "arn:aws:iam::123:role/terraform" }
}
}
```
### Drift 발견 → 흡수 vs 회복
- **흡수**: 의도했으면 TF code 에 반영, `terraform apply` 가 안 바꿈.
- **회복**: 의도 X, `terraform apply` 가 다시 원래대로.
## 🤔 의사결정 기준
| 도구 | 사용 |
|---|---|
| Open-source | driftctl + cron |
| Terraform Cloud | Health Assessment |
| AWS only + 자동 fix | AWS Config + remediation |
| Multi-cloud | driftctl |
| 변경 감사 | CloudTrail / GCP Audit |
| 사용자 수 적음 | SCP 로 prevent |
## ❌ 안티패턴
- **Plan / drift 검사 안 함**: 다음 apply 가 무릎 꿇림.
- **변경 알림 없음**: 콘솔 변경 모름.
- **모든 변경 무조건 회복**: HPA / autoscaling 영구 충돌. ignore_changes.
- **TF state 와 실제 차이 무시**: refresh.
- **콘솔 access 누구나**: IAM 분리.
- **Production destroy 가능**: prevent_destroy.
- **Drift 만 검사 — 외부 생성 리소스 모름**: driftctl 가 unmanaged 도 발견.
## 🤖 LLM 활용 힌트
- Daily plan + slack on exit 2.
- driftctl 또는 TFC Health Assessment.
- ignore_changes 로 의도적 drift 허용.
## 🔗 관련 문서
- [[DevOps_Terraform_Patterns]]
- [[DevOps_Observability_Stack]]