Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions environment/stage/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ module "stage_stack" {
# 인스턴스 스펙
instance_type = var.server_instance_type

# RDS 미사용 (Docker container로 대체)
enable_rds = false

# 보안 그룹 규칙
api_ingress_rules = var.api_ingress_rules

Expand Down
23 changes: 23 additions & 0 deletions modules/app_stack/db_users.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
resource "mysql_user" "users" {
for_each = var.enable_rds || var.enable_db_ec2 ? var.additional_db_users : {}

user = each.key
host = "%"
plaintext_password = each.value.password

depends_on = [
aws_db_instance.default,
aws_instance.db_server,
]
}

resource "mysql_grant" "user_grants" {
for_each = var.enable_rds || var.enable_db_ec2 ? var.additional_db_users : {}

user = each.key
host = "%"
database = each.value.database
privileges = each.value.privileges

depends_on = [mysql_user.users]
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
27 changes: 0 additions & 27 deletions modules/app_stack/rds.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# 5. RDS
resource "aws_db_instance" "default" {
count = var.enable_rds ? 1 : 0

Expand All @@ -21,29 +20,3 @@ resource "aws_db_instance" "default" {
Name = var.rds_identifier
}
}

# 6. MySQL 추가 유저 생성
resource "mysql_user" "users" {
for_each = var.enable_rds || var.enable_db_ec2 ? var.additional_db_users : {}

user = each.key
host = "%"
plaintext_password = each.value.password

depends_on = [
aws_db_instance.default,
aws_instance.db_server,
]
}

# 7. MySQL 권한 부여
resource "mysql_grant" "user_grants" {
for_each = var.enable_rds || var.enable_db_ec2 ? var.additional_db_users : {}

user = each.key
host = "%"
database = each.value.database
privileges = each.value.privileges

depends_on = [mysql_user.users]
}
2 changes: 1 addition & 1 deletion modules/app_stack/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variable "instance_type" {
variable "enable_rds" {
description = "RDS 사용 여부"
type = bool
default = true
default = false

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 Preserve load-test source before disabling prod RDS

When this default is used by prod, Terraform will destroy the prod RDS instance, but the load-test stack still starts by applying environment/load_test (scripts/load_test/start.sh runs terraform apply) and that configuration looks up var.prod_rds_identifier via data.aws_db_instance.prod and the latest automated RDS snapshot in environment/load_test/main.tf:51-58. After the prod DB instance is gone, the Load Test Start workflow can no longer resolve those data sources, so load-test provisioning fails instead of restoring from the intended source. Please migrate the load-test stack to the new DB EC2/manual snapshot source, or keep a compatible RDS source, before disabling RDS by default.

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.

해당 지적은 맞습니다. 하지만 현재 #61은 prod 앱 전환 완료 후 운영 RDS 삭제가 목적이고, load-test 환경은 기존에도 별도 이슈로 분리하기로 했던 영역이므로 별도 이슈에서 처리하고자 합니다!

}

variable "enable_db_ec2" {
Expand Down
Loading