1

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.```
5
  • I have tried self_link as well as ID but same result... the udemytestdel network does exist.. Commented Aug 13, 2021 at 18:20
  • Try without data. in data.google_comp........ eg Commented Aug 13, 2021 at 18:25
  • that would work if the google_compute_network was a resource... no? │ on vm.tf line 22, in resource "google_compute_firewall" "webserverrule": │ 22: network = google_compute_network.udemynetwork.name │ │ A managed resource "google_compute_network" "udemynetwork" has not been declared in the root module. Commented Aug 13, 2021 at 19:03
  • Perhaps try network = google_compute_network.my-network.name Commented Aug 13, 2021 at 20:10
  • I am an idiot, was creating in a project where the network did not exist. Commented Aug 13, 2021 at 20:55

1 Answer 1

1

Try adding project name as well.

data "google_compute_network" "my-network" {
    name = "udemytestdel"
    project = "yourprojectname"
Sign up to request clarification or add additional context in comments.

1 Comment

Also, you need to use self_link for network if it is shared (and in other project). Reference docs registry.terraform.io/providers/hashicorp/google/latest/docs/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.