Skip to content

Terraform 원격 state와 학기별 배포 이름 규칙 추가 - #42

Merged
pwh9882 merged 3 commits into
mainfrom
infra/remote-state
Aug 31, 2026
Merged

Terraform 원격 state와 학기별 배포 이름 규칙 추가#42
pwh9882 merged 3 commits into
mainfrom
infra/remote-state

Conversation

@pwh9882

@pwh9882 pwh9882 commented Aug 31, 2026

Copy link
Copy Markdown

개요

  • Terraform CLI 1.16.x를 사용하도록 버전 조건을 추가했습니다.
  • S3 remote backend를 partial configuration으로 선언했습니다.
  • 학기별 배포 식별자인 prefix 하나에서 배포 자원 이름을 파생하도록 정리했습니다.
  • 이번 배포 식별자는 sql-2026-s2, 서비스 주소는 sql.ddps.cloud입니다.
  • 모든 AWS provider 관리 자원에 Project, Deployment, ManagedBy tag를 공통으로 적용했습니다.

이름 규칙

다음 학기에는 IaC/var.tfprefix 한 곳만 변경합니다.

variable "prefix" {
  default = "sql-2026-s2"
}

현재 값에서 다음 이름이 파생됩니다.

자원 이름
VPC sql-2026-s2-vpc
Aurora cluster sql-2026-s2-rds-aurora-serverless-cluster
Valkey sql-2026-s2-elasticache-serverless
AMI sql-2026-s2-ctfd-arm
CTFd ECR sql-2026-s2-ctfd
SQL judge ECR sql-2026-s2-sql-judge
애플리케이션 log group /aws/ec2/sql-2026-s2
행동 log group /aws/ec2/sql-2026-s2-behavior
행동 log stream sql-2026-s2-sql-challenge
로그 S3 bucket sql-2026-s2-logs-786382940258-ap-northeast-2

로그 S3 bucket은 Terraform에서 생성하며 public access 차단, BucketOwnerEnforced, SSE-S3를 적용합니다. 서비스 domain은 학기별 자원 이름과 분리하여 sql.ddps.cloud로 유지합니다.

Remote state

root module에는 backend "s3" {} 선언만 포함합니다. 실제 bucket, key, region, lock, 암호화 및 profile 설정은 private terraform init 인자로 전달합니다.

기존의 ignored private_var.tf 입력 방식은 유지합니다.

검증

  • Terraform CLI 1.16.0
  • terraform init -reconfigure 통과
  • terraform validate 통과
  • AMI builder와 EC2 user-data script의 bash -n 통과
  • Terraform console에서 전체 파생 이름 확인
  • AWS에서 sql-2026-s2 VPC, Aurora, Valkey, AMI, ECR, 로그 S3 및 CloudWatch 이름이 사용되지 않았음을 확인
  • VPC·CloudWatch·로그 S3 targeted plan: 19 to add, 0 to change, 0 to destroy

전체 plan은 AMI 존재 여부를 계산하는 기존 count 표현식 때문에 Invalid count argument에서 중단됩니다. 현재 코드 주석에 기재된 운영 방식에 따라 기반 인프라, AMI, 나머지 인프라를 단계별로 apply해야 합니다.

현재 remote state에는 관리 자원이 없습니다. 실제 배포 전에는 CTFd 3.8.7 변경을 검토하여 main에 반영하고 단계별 plan을 다시 확인해야 합니다.

@pwh9882
pwh9882 force-pushed the infra/remote-state branch from cb3330f to 262a519 Compare August 31, 2026 05:46
@pwh9882
pwh9882 force-pushed the infra/remote-state branch from 262a519 to 18ef9ab Compare August 31, 2026 06:08
@pwh9882 pwh9882 changed the title Add durable Terraform remote state backend Terraform 원격 state와 학기별 배포 이름 규칙 추가 Aug 31, 2026
@pwh9882
pwh9882 marked this pull request as ready for review August 31, 2026 12:21
@pwh9882
pwh9882 merged commit 6055c4e into main Aug 31, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T12:22:14.783082Z f7e0ca1 Draft marked ready
🔒 Security Review Completed 2026-08-31T12:24:48.981272Z f7e0ca1 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant