GCP says "Compute Engine API has not been used in project" but it is enabled already

Viewed 4301

Using GCP with terraform to create VPC's and global IP addresses, I keep getting this error.

Error creating Network: googleapi: Error 403: Access Not Configured. Compute Engine API has not been used in project XXX before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/compute.googleapis.com/overview?project=XXXthen retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured

The Compute API has been enabled for at least a month.

I am also using a service account with owner permissions on the project.

I don't understand how to make this work. This has been going on for 3 days now.

Does anyone have any insight, because I'm completely stumped now.

2 Answers

Do you have billing enabled for this project? Double check the Project ID in the error message with the project that you enabled the Compute Engine API. – John Hanley 3 mins ago

Enabling the billing API fixed this for me thank you

Specify the project id else it might not work, example

''''

data "google_project" "project-name" {
  project_id = "kubernetes-labs-354807"
}

resource "google_compute_network" "vpc-name" {
  project                 = data.google_project.project-name.project_id
  name                    = "vpc-name"
  auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "subnet" {
  project = data.google_project.project-name.project_id
  name          = "subnet"
  ip_cidr_range = "10.1.0.0/16"
  region        = "europe-west1"
  network       = google_compute_network.vpc-name.id
  
}

''''

Related