Reputation: 121
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.
Upvotes: 10
Views: 8449
Reputation: 11
That error is pretty specific to service enablement. I might suggest confirming it is actually enabled.
For context, in GCP each of the services you use in a project need to be enabled respectively (see: Enabling and Disabling Services). This is a speed bump, but prevents you from using services your administrators didn't intend to be used.
In this case, if you are using terraform you can use the google_project_service
` resource to accomplish this, if you have suffiecient project permissions.
This is an example based on the error: Compute Engine API has not been used in project
resource "google_project_service" "project" {
project = "your-project-id"
service = "compute.googleapis.com"
}
One suggestion -- unless you have all your GCP project's resources managed in this one terraform project, you might want to manage service activation flags in the same tf project where the GCP project is managed. That way you dont destroy this and disable compute services for someone else's terraform project. Setting disable_on_destroy=false
can help too and is worth considering.
Upvotes: 1
Reputation: 21
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
}
''''
Upvotes: 2
Reputation: 121
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
Upvotes: 2