Reputation: 99
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:
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.
Upvotes: 10
Views: 14307
Reputation: 12519
To set your Cloud Platform project using Cloudshell use: gcloud config set project [PROJECT_ID]
replacing [PROJECT_ID] with your project name.
Then your CLI would look like
> admin_@cloudshell:~/underperformance_notifications (PROJECT_ID)$
Upvotes: -2
Reputation: 679
Google cloud collects all projects in the world which related to GCP(google cloud platform)
So you should create a project with a unique ID.
Upvotes: 1
Reputation: 131
Here is another link with more information about creating projects. With detail on how to do it in the console, gcloud, API, and Python.
Another issue that comes up: Verify that you are using the right account when invoking the commands:
gcloud auth list
If you are trying to check the existence of the project by using :
gcloud projects describe project-name
before you try to create it like in this post. The issue is that if you don't have rights to it you get the same sort of error if it exists or not.
User [[email protected]] does not have permission to access project [project-name] (or it may not exist): User is not authorized.
I even tried to create a new project with the same name as a project in a different unrelated org. The key seems to be to add anything alpha or numeric to make it distinct.
Hope that helps.
Upvotes: 0
Reputation: 9731
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.
Upvotes: 18
Reputation: 99
I think I figured it out.
The project ID must be followed by some numbers:
gcloud projects create tf-admin-001 --name tf-admin --organization xxxx --set-as-default
Geez. It does not specifically say so here: gcloud docs
Upvotes: -4