Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

allow ssh with terraform

I am trying to allow gcloud ssh or use ssh from the console but seems like even when i allow the ssh on my vpc its not working and I have to allow all on the internal network. any idea why?

 

allow ssh:

 

 

# Create firewall rule for allow ssh
resource "google_compute_firewall" "allow_all" {
  name    = "allow-ssh"
  network = google_compute_network.vpc_network.name

  allow {
    protocol = "22"
  }

  source_ranges = var.allow_ssh_source_ranges
}

 

 

 

Allow all:

resource "google_compute_firewall" "allow-internal" {
  name    = "default-allow-internal-1"
  network = google_compute_network.vpc_network.name  # Replace 'default' with your network if different

  allow {
    protocol = "all"
  }

  source_ranges = var.allow_ssh_source_ranges
}

 

any idea why?

3 2 885