Skip to content

feat: 관측 인프라 Terraform 모듈 골격 구성 (1/5) - #234

Merged
PHJ2000 merged 6 commits into
mainfrom
feat/observability-iac-pr1
Aug 7, 2026
Merged

PHJ2000 merged 6 commits into
mainfrom
feat/observability-iac-pr1

Conversation

@geonusp

@geonusp geonusp commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator

🔗 이슈 링크 (필수)


🧩 이 PR의 변경사항 (필수)

전체 중 위치 (Stacked PR 시)

  • 전체 이슈 #233의 1/5 단계
  • 선행 PR: 없음
  • 후속 PR: PR2 cloud-init 및 EBS 마운트 자동화

이 PR에서 변경한 것

  • dev 관측 환경용 Terraform root module 구성
  • 재사용 가능한 observability_ec2 module 추가
  • EC2, Security Group, EBS, IAM Role 및 Instance Profile 정의
  • Security Group의 VPC를 입력한 subnet_id에서 자동 조회하도록 구성
  • TCP 22/3100/4317/4318 인바운드를 앱 서버 Security Group에서만 허용
  • Grafana 3000, Prometheus 9090, Node Exporter 9100 인바운드는 생성하지 않도록 제한
  • 환경별 입력값 예제와 output, provider lock 파일 추가
  • state, 실제 tfvars 및 .terraform/ 제외 규칙 추가
  • 인스턴스 식별자를 node-01로 구성
  • cloud-init과 관측 스택 실행은 후속 PR 범위로 분리

✅ AC (이 PR 범위만) (필수)

  • AC1: dev root module에서 Terraform init/fmt -check -recursive/validate/plan이 가능하다.
  • AC2: terraform plan 결과에서 EC2 인스턴스가 1대 생성되고, Security Group 인바운드는 TCP 22/3100/4317/4318만 앱 서버 Security Group에서 허용하며, TCP 3000/9090/9100 및 인터넷 전체(0.0.0.0/0)에 공개되는 인바운드 규칙은 생성하지 않는다.
  • AC3: 관측 서버 Security Group은 subnet_id로 조회한 VPC에 생성되며 별도 vpc_id 또는 allowed_vpc_cidr 입력을 요구하지 않는다.
  • AC4: state와 실제 tfvars는 제외하고 lock 파일은 버전 관리한다.

🧪 테스트 결과 (필수)

로컬

terraform -chdir=deploy/observability/terraform fmt -check -recursive
terraform -chdir=deploy/observability/terraform/environments/dev init -backend=false
terraform -chdir=deploy/observability/terraform/environments/dev validate
terraform -chdir=deploy/observability/terraform/environments/dev plan
terraform -chdir=deploy/observability/terraform/environments/dev apply
  • ✅ init 성공
  • ✅ fmt -check -recursive 성공
  • ✅ validate 성공
  • ✅ plan에서 의도한 인바운드 규칙 교체 및 제거 확인
  • ✅ dev 환경 apply 완료

CI

  • ✅ Backend Build & Test (Unit + Integration) 통과
  • ✅ CodeRabbit 체크 통과 (자동 리뷰 비활성화로 리뷰 생략)

Smoke 테스트

  • 관측 스택 기동 검증은 cloud-init과 Docker Compose가 추가되는 후속 PR에서 수행

🧭 영향 범위 체크 (필수)

  • API 변경
  • DB 변경
  • 설정 변경 (AWS dev 관측 인프라 Terraform 입력값 및 Security Group 정책)
  • Breaking change

💬 리뷰 포인트 (필수)

  • 집중해서 볼 파일/라인: modules/observability_ec2/main.tf, environments/dev/main.tf
  • 네트워크 정책: 22/3100/4317/4318은 앱 서버 SG만 소스로 허용하고 3000/9090/9100은 인바운드를 생성하지 않음
  • VPC 결정 방식: 관측 서버가 속한 VPC는 subnet_id로 조회하며 별도 vpc_id를 입력하지 않음
  • 관리 접근: Grafana와 Prometheus UI는 후속 PR에서 Docker 내부 통신 및 SSH 터널 사용
  • 트레이드오프/대안: PR1은 local state 범위이며 S3 remote backend는 전체 계획의 PR5에서 전환
  • 후속 범위: cloud-init은 PR2, Docker Compose 관측 스택은 PR3, Alloy 로그 수집은 PR4

@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ec8de196-3f8c-42d6-92ae-b599146e9cfd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@geonusp geonusp self-assigned this Aug 4, 2026
@PHJ2000

PHJ2000 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

이번 PR 범위에는 포함하지 않아도 괜찮지만, 후속 작업으로 terraform fmt -check와 validate를 자동 실행하는 CI도 추가하면 좋을 것 같습니다.

@geonusp

geonusp commented Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator Author

이번 PR 범위에는 포함하지 않아도 괜찮지만, 후속 작업으로 terraform fmt -check와 validate를 자동 실행하는 CI도 추가하면 좋을 것 같습니다.

이번 PR범위에는 넣기 애매해 보여서 추후에 후속 이슈로 생각을 해봐야 할듯합니다.

@geonusp geonusp added the feat label Aug 5, 2026
geonusp added 2 commits August 7, 2026 21:19
- SSH 인바운드 소스를 VPC CIDR에서 앱 서버 Security Group ID로 변경
- 환경과 모듈에 app_server_security_group_id 입력 및 형식 검증 추가
- tfvars 예제를 동기화하고 관측 서비스 CIDR 설명 정리
- 검증: terraform apply 완료 및 git diff --cached --check 통과
- Loki와 OTLP 인바운드 소스를 앱 서버 Security Group으로 제한
- 내부 통신 및 SSH 터널로 대체되는 Grafana, Prometheus, Node Exporter 인바운드 제거
- 미사용 allowed_vpc_cidr 입력과 예제 설정 정리
- 검증: git diff --cached --check 통과, Terraform apply 완료
@PHJ2000

PHJ2000 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

수고하셨습니다.

@PHJ2000
PHJ2000 merged commit 85f9711 into main Aug 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants