Skip to content

refactor: DB EC2 전환을 위한 DB 유저 관리 대상 변경#62

Merged
Hexeong merged 1 commit into
mainfrom
refactor/52-rds-termination-and-db-migrate-complete
Jul 10, 2026
Merged

refactor: DB EC2 전환을 위한 DB 유저 관리 대상 변경#62
Hexeong merged 1 commit into
mainfrom
refactor/52-rds-termination-and-db-migrate-complete

Conversation

@Hexeong

@Hexeong Hexeong commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

관련 이슈

작업 내용

  • prod Terraform plan/apply workflow의 MySQL provider 터널 대상을 RDS에서 DB EC2로 변경했습니다.
  • additional_db_users가 DB EC2 사용 시에도 mysql_user, mysql_grant로 관리되도록 수정했습니다.
  • DB EC2 user_data 변경이 인스턴스 재생성을 유발하지 않도록 user_data_replace_on_changeignore_changes를 정리했습니다.

특이 사항

  • 이번 PR에서는 RDS를 삭제하지 않습니다.
  • RDS 삭제는 앱 전환과 smoke test 이후 #61에서 별도로 진행합니다. 수동 스냅샷을 이미 생성해둔 상태에서, 삭제 작업은 후속 PR로 분리해 더 안전하게 처리합니다.
  • 현재 prod plan 기준으로 RDS/DB EC2 삭제 없이 scapp_user, scapp_flyway 유저와 권한 생성만 잡히는 것을 확인했습니다.

리뷰 요구사항 (선택)

  • workflow가 API server를 경유해 DB EC2 private IP로 터널링하는 방식이 기존 협업 워크플로우와 맞는지 확인 부탁드립니다.
  • additional_db_usersenable_rds || enable_db_ec2 조건으로 관리하는 방향이 적절한지 확인 부탁드립니다.
  • 검증: terraform fmt -check -recursive environment/prod modules/app_stack, git diff --check, DB EC2 터널 기준 prod terraform plan 확인 완료 (Plan: 4 to add, 0 to change, 0 to destroy).

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Hexeong, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fdf8be32-460d-46f7-9ec2-d9564a9d581a

📥 Commits

Reviewing files that changed from the base of the PR and between c13a928 and 2373267.

📒 Files selected for processing (4)
  • .github/workflows/terraform-apply.yml
  • .github/workflows/terraform-plan.yml
  • modules/app_stack/db_ec2.tf
  • modules/app_stack/rds.tf
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/52-rds-termination-and-db-migrate-complete

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.

@github-actions

Copy link
Copy Markdown

Terraform Plan: stage

No changes. Your infrastructure matches the configuration.

전체 plan 결과는 보안을 위해 댓글에 포함되지 않습니다. 워크플로우 실행 아티팩트를 확인하세요.

@github-actions

Copy link
Copy Markdown

Terraform Plan: prod

Plan: 4 to add, 0 to change, 0 to destroy.

전체 plan 결과는 보안을 위해 댓글에 포함되지 않습니다. 워크플로우 실행 아티팩트를 확인하세요.

@Hexeong Hexeong self-assigned this Jul 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2373267cc2

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread modules/app_stack/rds.tf
# 6. MySQL 추가 유저 생성
resource "mysql_user" "users" {
for_each = var.enable_rds ? var.additional_db_users : {}
for_each = var.enable_rds || var.enable_db_ec2 ? var.additional_db_users : {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wait for DB EC2 bootstrap before managing users

When enable_db_ec2 is used while the DB instance is being created or replaced, this now schedules mysql_user/mysql_grant in the same apply, but the only added dependency is the EC2 resource itself; Terraform considers the instance created before mysql_setup.sh has finished starting Docker/MySQL and creating the remote root user. In that first-create/replacement path the MySQL provider can connect through the tunnel before the database is ready, making applies fail or become flaky; add an explicit cloud-init/SSM readiness check resource and depend on that before creating users.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 지적 감사합니다! 말씀하신 것처럼 DB EC2를 최초 생성하거나 교체하는 apply에서는 aws_instance 생성 완료가 cloud-init 및 MySQL 준비 완료를 보장하지 않기 때문에, 별도의 readiness check가 필요할 수 있다고 생각합니다.

다만 이번 PR에서는 DB EC2를 생성/교체하지 않고, 이미 부트스트랩과 MySQL 기동 및 scadmin 인증까지 확인된 기존 DB EC2에 scapp_user, scapp_flyway 유저/권한만 추가하는 범위입니다. 실제 prod plan도 Plan: 4 to add, 0 to change, 0 to destroy로 DB EC2 변경 없이 MySQL user/grant 생성만 잡히는 것을 확인했습니다.

또한 DB EC2 생성/부트스트랩 안정화는 앞선 hotfix PR들에서 swap 추가와 root 인증 기반 readiness check로 보강했고, 이번 PR에서는 RDS 삭제도 제외하여 #61 후속 이슈에서 별도로 안전하게 처리할 예정입니다.

따라서 이번 PR에서는 추가 Terraform readiness 리소스는 넣지 않고, 향후 DB EC2 교체 자동화가 필요해지는 시점에 별도 작업으로 다루는 것이 적절하다고 판단했습니다.

@Hexeong Hexeong merged commit 47edaff into main Jul 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: DB 유저 생성 및 앱 datasource 변경

2 participants