Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion terraform/db_ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# -----------------------------------------------------------------------------
# DB 박스 Security Group
#
# 3306(MySQL)·6379(Redis) 는 앱 EC2 SG(prod·dev 앱 박스 공용) 에서만 받는다(폐기된 RDS SG 가 지키던 것과 같은 규율) — DB 를
# 3306(MySQL)·6379(Redis) 는 prod 앱 EC2 SG 에서만 받는다(폐기된 RDS SG 가 지키던 것과 같은 규율) — DB 를
# 인터넷에 직접 노출하지 않는다. SSH 는 SSM 경유라 22 번이 없다(#1196).
#
# egress 는 열어 둔다. RDS 와 달리 이 박스는 스스로 바깥에 나가야 한다 — SSM 에서 DB 자격증명을
Expand Down
4 changes: 2 additions & 2 deletions terraform/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ resource "aws_instance" "app" {

# -----------------------------------------------------------------------------
# 개발(dev) EC2 — 신규 인스턴스.
# 동일 VPC/서브넷/SG 를 공유하며, 별도 EIP 와 도메인(dev.*)으로 분리.
# 동일 VPC/서브넷을 쓰고, SG·EIP·도메인(dev.*)은 분리.
# -----------------------------------------------------------------------------
resource "aws_instance" "dev_app" {
ami = var.ec2_ami_id != null ? var.ec2_ami_id : data.aws_ami.ubuntu_2404_arm64[0].id
instance_type = var.ec2_instance_type_dev
subnet_id = aws_subnet.public.id
availability_zone = var.azs[0]
vpc_security_group_ids = [aws_security_group.ec2.id]
vpc_security_group_ids = [aws_security_group.dev_app.id]
# dev 전용 키페어 — prod(team3-SE-1)와 분리해 dev 키 유출이 prod 접근으로 번지지 않게 한다.
# AWS 콘솔에서 미리 생성(.pem 다운로드)해 두고 이름으로 참조. 개인키는 dev env EC2_SSH_KEY 로 주입.
key_name = "team3-dev-SE-1"
Expand Down
42 changes: 41 additions & 1 deletion terraform/security_groups.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -----------------------------------------------------------------------------
# EC2 Security Group — HTTP(80) + HTTPS(443). SSH 는 SSM 경유라 22 번이 없다(#1196).
# prod 앱 EC2 Security Group — HTTP(80) + HTTPS(443). SSH 는 SSM 경유라 22 번이 없다(#1196).
# 이름의 team3-dev 는 옛 이름이다. 바꾸면 SG 가 새로 만들어져 prod DB·extractor·renderer 의 참조가 함께 바뀌어야 한다.
#
# 앱 포트는 외부에 노출하지 않는다. 박스의 nginx 가 TLS 를 종료하고 127.0.0.1 에 바인딩된
# blue·green 슬롯으로 forward 한다(포트 정본: TeamPiKi/infra contracts/ports.json).
Expand Down Expand Up @@ -44,5 +45,44 @@ resource "aws_security_group" "ec2" {
}
}

# -----------------------------------------------------------------------------
# dev 앱 EC2 Security Group — prod 앱 SG 와 같은 입구(80·443)를 갖되 그룹을 나눈다.
# prod DB SG 는 prod 앱 SG 만 참조하므로, 그룹을 나눈 것만으로 dev 박스에서 prod DB 로 가는 길이 닫힌다(#1213).
# dev 는 자기 박스의 MySQL·Redis 를 쓴다. 이 그룹을 참조하는 쪽은 extractor 인바운드뿐이다.
# -----------------------------------------------------------------------------
resource "aws_security_group" "dev_app" {
name = "piki-dev-app-sg"
description = "dev app EC2: HTTP/HTTPS in, all out"
vpc_id = aws_vpc.main.id

ingress {
description = "HTTP (redirect to HTTPS at reverse proxy layer)"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

ingress {
description = "HTTPS"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

egress {
description = "Allow all outbound"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}

tags = {
Name = "piki-dev-app-sg"
}
}

# RDS Security Group 은 #898 로 RDS 자체를 폐기하면서 함께 제거했다.
# 그 자리를 대신하는 것은 db_ec2.tf 의 aws_security_group.db_ec2 다.
Loading