Instance IP assignment is not set to private Affecting Compute Engine service in Google


Severity

0.0
low
0
10
Severity Framework
Snyk CCSS
Rule category
Network/ Access Control

Is your environment affected by this misconfiguration?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
Frameworks
  • Snyk IDSNYK-CC-00716
  • creditSnyk Research Team

Description

Setting the instance IP assignment to private ensures that the instance is assigned a private IP address, which improves network security by preventing direct access from the internet. This reduces the risk of unauthorized access and potential attacks on the instance. By configuring the instance IP assignment to private, the instance will only be accessible within the private network, providing an additional layer of protection.

How to fix?

Create a google_compute_instance resource with a network_interface block (optionally configure the attribute network_ip within it). However, do not create a access_config block within the network_interface block.

Example Configuration


resource "google_compute_instance" "default" {
  name         = "default"
  machine_type = "e2-medium"
  zone         = "us-central1-a"

  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-11"
    }
  }

  network_interface {
    network = "default"
  }
}