설명
내부 클라이언트만 쓰는 Azure Container Instances(ACI) 그룹에는 Private IP를 선택하세요. Public은 외부에 서비스를 제공할 때, None은 그룹에 IP 주소가 필요 없을 때 사용합니다.
잠재적 영향
공용 IP에서는 열린 포트와 접근 규칙에 따라 서비스에 외부에서 연결할 수 있습니다. 사설 IP로 옮길 때 경로나 DNS가 빠지면 기존 클라이언트의 연결이 끊길 수 있습니다.
해결 방법
ip_address_type = "Private"와 subnet_ids로 ACI에 위임된 전용 서브넷을 지정하세요. 필요한 출발지와 포트만 NSG에서 허용하고 DNS, 라우팅, 애플리케이션 인증과 TLS를 확인하세요. 인터넷으로 나가는 연결이 필요하면 해당 서브넷에 NAT 게이트웨이를 구성하세요.
예시
예제는 수신 포트와 통신 경로를 생략합니다. IP 유형을 변경하면 그룹이 교체되므로 Terraform 계획을 확인하고 배포 후 내부 클라이언트에서 연결을 시험하세요.
변경 전
hcl
resource "azurerm_container_group" "example" {
name = "example-container-group"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
os_type = "Linux"
ip_address_type = "Public"
container {
name = "app"
image = "nginx:stable"
cpu = 1
memory = 1
}
}
변경 후
hcl
resource "azurerm_container_group" "example" {
name = "example-container-group"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
os_type = "Linux"
ip_address_type = "Private"
subnet_ids = [azurerm_subnet.aci.id]
container {
name = "app"
image = "nginx:stable"
cpu = 1
memory = 1
}
}