Google could do better in making these resources (e.g. Projects) more clear.
Actually (to my knowledge) all Google Projects represent the same underlying project resource and you can e.g. view DialogFlow projects from Google Cloud Console and vice versa.
I suspect (!) that you created 2 different projects: one using (Google Cloud Platform) Console and one using DialogFlow Console
If you have the Cloud SDK (aka gcloud
) installed, you should be able to list all your projects (Cloud, DialogFlow etc.) using:
gcloud projects list
Now, to answer your question. Users of Google (!) Projects are Google accounts users and groups and also include service accounts. You may list the users for a given project with:
gcloud projects get-iam-policy ${PROJECT}
Ideally, what you want to do is ensure that this policy is reflected across both projects. I'm reluctant to provide a script because service accounts complicate this sharing. Service accounts work across projects but they are created automatically in projects. A simple copy-and-paste of accounts may break something for you.
That said, here's a gcloud
command to enumerate the list of ${ROLE}
(roles/owner
) from one project ${SRC}
:
PSRC=...
ROLE="roles/owner"
MEMBERS=$(gcloud projects get-iam-policy ${PSRC} \
--flatten=bindings \
--filter=bindings.role:${ROLE} \
--format="value(bindings.members)") && echo ${MEMBERS}
NB There's probably a way to split user:some@email.com
if you need to
You could then iterate over this list and add (!) these accounts to ${PDST}
for MEMBER in ${MEMBERS}
do
gcloud projects add-iam-policy-binding ${DST} \
--member=${MEMBER} \
--role=${ROLE}
done
Lastly, when you create a DialogFlow project you are provided with the option to use an existing Google (Cloud) Project. Next time, you follow this flow, please look for the "create new or use existing project" prompt. You would be able to select the Project you'd created previously to reuse your users.