Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FAILED_PRECONDITION when trying to create a new Google API project

I am getting an error when attempting to create a new project for Google API at https://code.google.com/apis/console

I was hoping the error was temporary, but I have been unable to create a new project for a couple weeks now.

The error seems to have changed, as it used to include server ip information and a lot of other data. An example with some potentially private information removed:

APPLICATION_ERROR;google.cloudresourcemanager.projects.v1beta1/DeveloperProjects.CreateProject;com.google.apps.framework.request.StatusException: generic::FAILED_PRECONDITION: ;AppErrorCode=9;StartTimeMs=1489595147198;tcp;Deadline(sec)=50.0;ResFormat=UNCOMPRESSED;ServerTimeSec=0.027545452117919922;LogBytes=256;FailFast;EffSecLevel=none;ReqFormat=UNCOMPRESSED;ReqID=removed;GlobalID=removed;Server=ip:port

Now the error is a lot shorter, although still seems to be related to the same cause:

com.google.apps.framework.request.StatusException: generic::FAILED_PRECONDITION:

The spinner in the dashboard appears to spin forever, while the error appears underneath alerts after a few seconds. I have tried numerous project names and all fail with the same error.

Is there some type of quota I am missing that is preventing this? The quota menu item requires me to select a project, which I don't have any.

Clicking on the error brings me to a page with the following message:

You don't have permissions to perform the action on the selected resource.

like image 608
Nabren Avatar asked Apr 04 '17 18:04

Nabren


People also ask

Where is my Google project API?

To locate your project ID: Go to the API Console. From the projects list, select Manage all projects. The names and IDs for all the projects you're a member of are displayed.

What is a project in Google API?

In the API Console, a project is a collection of settings, credentials, and metadata about the application or applications you're working on that make use of Google APIs and Google Cloud Platform resources.


2 Answers

Make sure that the Google Developers Console is on for the user that is trying to create the project.

Admin.google.com > Apps > Additional Google services > Google Developers Console and turn on for any org or user that needs it.

like image 127
Andrew L Avatar answered Sep 30 '22 15:09

Andrew L


Looks like there's another possible cause, in addition to the one that @AndrewL provided in his solution.

Short answer:
I ran into the same error when I attempted to associate a new GCP project with our billing account via Terraform. Our billing account has a default limit of 5 projects (which we had already met), and this blocked the association of new accounts and generated the Error 400: Precondition check failed., failedPreconditionerror message. To fix, I had to remove/delete one of the already associated projects before I could add a new one.

Long answser:
Here is the error message I encountered in Terraform (sensitive data and IDs redacted):

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  ~ module.<MY MODULE PATH>.project
      billing_account: "" => "<MY BILLING ACCOUNT ID>"


Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.<MY MODULE PATH>.project: Modifying... (ID: <MY PROJECT ID>)
  billing_account: "" => "<MY BILLING ACCOUNT ID>"

Error: Error applying plan:

1 error(s) occurred:

* module.<MY MODULE PATH>.project: 1 error(s) occurred:

* google_project.project: Error setting billing account "<MY BILLING ACCOUNT ID>" for project "projects/<MY PROJECT ID>": googleapi: Error 400: Precondition check failed., failedPrecondition

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

My billing account was at its maximum of 5 projects. As a test, I removed one of the projects and then ran Terraform again. It then successfully added the new project to the billing account. To double check, I attempted to add yet another new project to the billing account (to push the amount to 6) and then received the same error message again.

Straight up deleting one of the associated projects also works.

It stands to reason that requesting a limit increase for your billing account's associated projects will also fix this issue.

like image 43
Himal Avatar answered Sep 30 '22 15:09

Himal