I want to create a Folder and within the newly cre...
# google-cloud
c
I want to create a Folder and within the newly created Folder add new Project. Therefore I do
Copy code
const prodFolder = new Folder(name,
        {
          displayName: name,
          parent: "organizations/<org_id>",
        }
)}

const googleCloudProject = new gcp.organizations.Project(name,
        {
          name: "some-name",
          projectId: "some-id",
          folderId: folder.id,
        });
I receive this error
Copy code
error: error creating project unicorn (Funke Infrastructure): googleapi: Error 409: Requested entity already exists, alreadyExists. If you received a 403 error, make sure you have the `roles/resourcemanager.projectCreator` permission
If I leave out the
folderId
in the Project creation above, the stuff works. What do I miss? I use an account having the requested permission, just in case, even if it does not look like this kind of error.
g
If you leave out the
folderId
the project will be created as a personal project, which you can always do (almost). Do you have the Project Creator role across the whole organization?
c
Yes. The project is created underneath the organization without the folderId. But I want it to be underneath the folder. From docs side it looks like setting the arg and be fine with it 🤷‍♂️
g
c
makes no difference - error still the same
g
Here we just give the
folder_id
as in the api on the config file. The
id
output might not be it exactly, since the provider can change to add some prefix, and the
name
output is
folder/{folder_id}
, which is what is used to create a nested folder, but not a project.
There is the "simple" way, which is to get the folder_id from
name
, but that seems like a hack
c
Nested Folder works. The folder -> project nesting results in „already exists“. But there is no such project. That’s why I assume no permission failure
e
You might be reusing a project id. Have you created a "some-id" project in the past and deleted it? In that case, you will need a new id.
c
My issue was changing from an organization level project to a project underneath a folder. This did not work due to an error „cannot set both org_id and folder_id“. By creating a new folder and a new project from scratch I was able to build the structure.