I am Lame
I am Lame

Reputation: 11

Terraform data.google_compute_network not working

This is the code block I am trying to execute... terraform 1.0

data "google_compute_network" "my-network" {
  name = "udemytestdel"
}

resource "google_compute_firewall" "firewall" {
  name    = "gritfy-firewall-externalssh"
  network = data.google_compute_network.my-network.name
  allow {
    protocol = "tcp"
    ports    = ["22"]
  }
  source_ranges = ["0.0.0.0/0"] # Not So Secure. Limit the Source Range
  target_tags   = ["externalssh"]
}

And I keep getting this

│ Error: Missing required argument
│
│   with google_compute_firewall.firewall,
│   on vm.tf line 16, in resource "google_compute_firewall" "firewall":
│   16:   network = data.google_compute_network.my-network.name
│
│ The argument "network" is required, but no definition was found.```

Upvotes: 1

Views: 1634

Answers (1)

Amarpreet Singh
Amarpreet Singh

Reputation: 11

Try adding project name as well.

data "google_compute_network" "my-network" {
    name = "udemytestdel"
    project = "yourprojectname"

Upvotes: 1

Related Questions