Perform the migration

If you have the appropriate IAM permissions and the required organization policies are enforced, you can use the Resource Manager API to migrate a project resource between organization resources.

gcloud

To migrate a project to another organization resource, run the following command:

gcloud beta projects move PROJECT_ID \
    --organization ORGANIZATION_ID

You can also specify a folder as the target resource, with the following command:

gcloud beta projects move PROJECT_ID \
    --folder FOLDER_ID

Replace the following fields:

  • PROJECT_ID is the ID or number of the project you wish to migrate.
  • ORGANIZATION_ID is the ID of the organization resource to which you want to move the project. You can only specify one target, either an organization resource or a folder.
  • FOLDER_ID is the ID of the folder to which you want to move the project. You can only specify one target, either a folder or an organization resource.

API

Using the v1 Resource Manager API, you can migrate a project between organization resources by setting its parent field to the ID of the destination resource.

To migrate a project, do the following:

  • Get the project object using projects.get() method.
  • Set its parent field to the organization resource ID of the organization resource, or the folder ID of the folder to which you are moving it.
  • Update the project object using projects.update() method.

The following code snippet demonstrates the steps above:

    project = crm.projects().get(projectId=flags.projectId).execute()
    project['parent'] = {
        'type': 'organization',
        'id': flags.organizationId
    }

    project = crm.projects().update(
    projectId=flags.projectId, body=project).execute()

Roll back a migration

If you have mistakenly migrated a project, you can roll back the operation by performing the migration again, with the old source as the new destination, and the old destination as the new source. You must have the necessary IAM permissions and organization policies enforced to allow this as if this were an entirely new migration.

To roll back a migration where a project was migrated from No organization to an Organization resource, contact Google Cloud Customer Care.