refactor: DB EC2 전환을 위한 DB 유저 관리 대상 변경#62
Conversation
|
Warning Review limit reached
Next review available in: 4 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Terraform Plan:
|
Terraform Plan:
|
There was a problem hiding this comment.
💡 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".
| # 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 : {} |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
좋은 지적 감사합니다! 말씀하신 것처럼 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 교체 자동화가 필요해지는 시점에 별도 작업으로 다루는 것이 적절하다고 판단했습니다.
관련 이슈
작업 내용
additional_db_users가 DB EC2 사용 시에도mysql_user,mysql_grant로 관리되도록 수정했습니다.user_data변경이 인스턴스 재생성을 유발하지 않도록user_data_replace_on_change와ignore_changes를 정리했습니다.특이 사항
scapp_user,scapp_flyway유저와 권한 생성만 잡히는 것을 확인했습니다.리뷰 요구사항 (선택)
additional_db_users를enable_rds || enable_db_ec2조건으로 관리하는 방향이 적절한지 확인 부탁드립니다.terraform fmt -check -recursive environment/prod modules/app_stack,git diff --check, DB EC2 터널 기준 prodterraform plan확인 완료 (Plan: 4 to add, 0 to change, 0 to destroy).