Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcloud cli cannot create project - The project ID you specified is already in use by another project

I'm trying to set up Terraform for use with GCP and I'm having trouble creating a new project from the gcloud cli: Terraform Lab

The command I'm using is

gcloud projects create testproject

The error I get over and over is:

ERROR: (gcloud.projects.create) Project creation failed. The project ID you specified is already in use by another project. Please try an alternative ID.

Here's what I did so far:

  1. I created an "organization" and a user in Cloud Identity
  2. Logged into GCP console in the browser with the user I created
  3. The user has "Organization Administrator" role
  4. Using the Cloud Shell or gcloud configured on my home computer, I am not able to create a new project. I am able to do things like "gcloud projects list" and "gcloud organizations list" successfully in both cases (cloud shell & local gcloud install)
  5. I have tried this with different project ID names that are within the format requirements (eg 6-30 chars, lowercase, etc). I can also confirm that the project IDs do not exist.
  6. However, I am able to successfully create projects via GCP web console (https://console.cloud.google.com) (using the same IAM account configured in gcloud cli)
  7. I have tried "gcloud init" several times making sure I am using the right IAM account, just in case.

Here's the error I get when I try to create a new project from the "gcloud init" command:

Enter a Project ID. Note that a Project ID CANNOT be changed later.
Project IDs must be 6-30 characters (lowercase ASCII, digits, or
hyphens) in length and start with a lowercase letter. vincetest
WARNING: Project creation failed: HttpError accessing 
<https://cloudresourcemanager.googleapis.com/v1/projects?alt=json>: 
response: <{'status': '409', 'content-length': '268', 'x-xss
-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 
'transfer-encoding': 'chunked', 'vary': 'Origin, X-Origin, Referer', 
'server': 'ESF', '-content-encoding': 'gzip',
 'cache-control': 'private', 'date': 'Fri, 28 Sep 2018 18:38:11 GMT', 
 'x-frame-options': 'SAMEORIGIN', 'content-type': 'application/json; 
 charset=UTF-8'}>, content <{
  "error": {
    "code": 409,
    "message": "Requested entity already exists",
    "status": "ALREADY_EXISTS",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ResourceInfo",
        "resourceName": "projects/vincetest"
      }
    ]
  }
}
>

Creating the project from the web page console worked fine.

like image 487
Shark Avatar asked Sep 28 '18 19:09

Shark


1 Answers

Project IDs are unique across all projects. That means if any user ever had a project with that ID, you cannot use it. testproject is pretty common, so it's not surprising it's already taken.

Try a more unique ID. One common technique is to user your organization's name as a prefix.

like image 132
David Avatar answered Sep 18 '22 16:09

David