Skip to content

Instantly share code, notes, and snippets.

@b0noI
Last active December 18, 2018 02:32
Show Gist options
  • Save b0noI/18454d66feedbf99ae42d24cf974f13b to your computer and use it in GitHub Desktop.
Save b0noI/18454d66feedbf99ae42d24cf974f13b to your computer and use it in GitHub Desktop.
PROJECT_ID="" # PUT YOUR PROJECT ID
SERVICE_ACCOUNT_NAME="" # Service account name
GOOGLE_ACCOUNT_MAIL="" # user mail
gcloud iam service-accounts add-iam-policy-binding \
"${SERVICE_ACCOUNT_NAME}@${PROJECT_ID}.iam.gserviceaccount.com" \
--member="user:${GOOGLE_ACCOUNT_MAIL}" --role="roles/iam.serviceAccountUser"
# Replace osAdminLogin with osLogin if you do NOT want the user to have an
# ability to act as root.
gcloud projects add-iam-policy-binding ${PROJECT_ID} \
--member="serviceAccount:${SERVICE_ACCOUNT_NAME}@${PROJECT_ID}.iam.gserviceaccount.com" \
--role="roles/compute.osAdminLogin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment