설명
Azure 네트워크 인터페이스에서 public_ip_address_id를 지정하면 퍼블릭 IP가 연결됩니다.
잠재적 영향
라우팅, 네트워크 보안 그룹(NSG), 호스트 방화벽이 허용하면 외부에서 해당 인터페이스의 서비스에 접속할 수 있습니다.
해결 방법
외부에서 직접 접속할 필요가 없으면 관리 경로를 먼저 확보한 뒤 ip_configuration에서 public_ip_address_id를 제거하세요. 퍼블릭 IP를 유지한다면 필요한 포트와 접속 원본만 허용하세요.
예시
변경 전 예시의 변수에는 퍼블릭 IP 리소스 ID를 지정합니다. 두 예시 모두 프라이빗 IP를 동적으로 할당합니다.
변경 전
hcl
resource "azurerm_network_interface" "example" {
name = "example-nic"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.example.id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = var.public_ip_address_id
}
}
변경 후
hcl
resource "azurerm_network_interface" "example" {
name = "example-nic"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.example.id
private_ip_address_allocation = "Dynamic"
}
}