Public IP is assigned to compute instance Affecting Compute Engine service in Google


Severity

0.0
medium
0
10
    Severity Framework
    Snyk CCSS
    Rule category
    Network / Public Access

Is your enviroment 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
    CIS-Controls CIS-Google CSA-CCM ISO-27001 NIST-800-53 SOC-2
  • Snyk ID SNYK-CC-00382
  • credit Snyk Research Team

Description

Compute Engine instances should not have public IP addresses to reduce potential attack surfaces, as public IPs enable direct access via the internet. Instances serving internet traffic should be configured behind load balancers, which provide an additional layer of security.

How to fix?

Remove the access_config attribute from the google_compute_instance.

Example Configuration

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

  boot_disk {
    initialize_params {
      image = "debian-11-bullseye-v20221102"
    }
  }

  network_interface {
  }
}

References