説明
Azure のネットワークインターフェイスで public_ip_address_id を指定すると、パブリック IP が関連付けられます。
想定される影響
ルート、ネットワークセキュリティグループ (NSG)、ホストのファイアウォールが許可していると、待ち受け中のサービスに外部から接続できます。
対処方法
直接公開する必要がなければ、管理経路を確保してから ip_configuration の public_ip_address_id を削除します。アドレスを残す場合は必要なポートと接続元だけを許可してください。
例
変更前の例にはパブリック 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"
}
}