Skip to content

Commit deb153f

Browse files
committed
feat: monitoring ec2에서만 prod/stage의 jvm에 접근 가능하도록 8081 port 허용
1 parent e7760fc commit deb153f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

modules/app_stack/security_groups.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
data "aws_instance" "monitoring_ec2" {
2+
filter {
3+
name = "tag:Name"
4+
values = ["solid-connection-monitoring"]
5+
}
6+
7+
filter {
8+
name = "instance-state-name"
9+
values = ["running"]
10+
}
11+
}
12+
113
# 1. API Server용 보안 그룹 (SSH 연결 허용)
214
resource "aws_security_group" "api_sg" {
315
name = "sc-${var.env_name}-api-sg"
@@ -45,6 +57,15 @@ resource "aws_security_group" "db_sg" {
4557
}
4658
}
4759

60+
ingress {
61+
description = "Allow 8081 from EC2: (${data.aws_instance.monitoring_ec2.tags.Name})"
62+
from_port = 8081
63+
to_port = 8081
64+
protocol = "tcp"
65+
66+
cidr_blocks = ["${data.aws_instance.monitoring_ec2.private_ip}/32"]
67+
}
68+
4869
tags = {
4970
Name = "solid-connection-${var.env_name}-db-sg"
5071
}

0 commit comments

Comments
 (0)