Open jaylong255 opened 2 months ago
Authenticate with gcloud as the new user
gcloud auth login
You will probably need to update your password.
Create the System Root Folder
gcloud resource-manager folders create \
--display-name="MyName System Root" \
--organization="ORG_ID"
Grant Your User Folder Create Permissions The new user has essentially no permissions. I gave it basic "browser" just because you have to grant principles something. This is intentional since what i'm trying to do here is document all of the necessary permissions for the system root setup instructions for bootstrapping a tf agent that is sandboxed in its own folder.
You will need to be authenticated as a user with the permissions to escalate permissions
gcloud organizations add-iam-policy-binding ORG_ID \ --member=user:GCP_USER_EMAIL \ --role=roles/resourcemanager.folderCreator
As a privileged user, grant the new user project create permissions
gcloud organizations add-iam-policy-binding ORG_ID \
--member=user:GCP_USER_EMAIL \
--role=roles/resourcemanager.projectCreator
Create the System Root Project
For a new user, you probably need to log into the GCP console to accept the terms of service.
gcloud projects create myname-system-root \ --name="MyName System Root" \ --organization=ORG_ID \ --set-as-default
Create the System Root Service Account
Now that your user had Project and Folder Creator on the Organization level, you should be able to perform these with no problems.
gcloud iam service-accounts create myname-system-root \ --display-name="MyName System Root" \ --project=myname-system-root
Generate an IAM key JSON
gcloud iam service-accounts keys create myname-system-root-key.json \
--iam-account=myname-system-root@myname-system-root.iam.gserviceaccount.com \
--project=myname-system-root
Enable Cloud Billing API for the System Root Project
gcloud services enable cloudbilling.googleapis.com --project=myname-system-root
Grant the new user the ability to grant organization admin to the system root service account
gcloud organizations add-iam-policy-binding ORG_ID \
--member=user:GCP_USER_EMAIL \
--role=roles/resourcemanager.organizationAdmin
Grant Folder Admin to your System Root Service Account
gcloud organizations add-iam-policy-binding ORG_ID \
--member="serviceAccount:myname-system-root@myname-system-root.iam.gserviceaccount.com" \
--role="roles/resourcemanager.folderAdmin"
Grant the new user permission to access billing accounts
gcloud beta billing accounts add-iam-policy-binding BILLING_ACCOUNT_ID \
--member=user:gcp-tnclient-system-root@cyberworldbuilders.com \
--role=roles/billing.user
Grant the new user permission to set IAM Policy
gcloud beta billing accounts add-iam-policy-binding BILLING_ACCOUNT_ID \
--member=user:gcp-tnclient-system-root@cyberworldbuilders.com \
--role=roles/iam.securityAdmin
Grant roles/billing.user to your System Root Service Account
gcloud beta billing accounts add-iam-policy-binding BILLING_ACCOUNT_ID \
--member="serviceAccount:SERVICE_ACCOUNT_EMAIL" \
--role="roles/billing.user"
Grant roles/resourcemanager.projectCreator to your System Root Service Account
gcloud organizations add-iam-policy-binding ORGANIZATION_ID \
--member="serviceAccount:SERVICE_ACCOUNT_EMAIL" \
--role="roles/resourcemanager.projectCreator"
Enable the Cloud KMS API for the System Root Project
gcloud services enable cloudkms.googleapis.com --project my-project-id
Make sure billing is enabled for the System Root Project
gcloud beta billing projects link myname-system-root --billing-account=BILLING_ACCOUNT_ID
Create a KMS Key Ring
gcloud kms keyrings create my-keyring \
--location us-central1 \
--project your-project-id
Create a KMS Key
gcloud kms keys create my-key \
--keyring my-keyring \
--location us-central1 \
--project your-project-id \
--purpose encryption
Adding a user to your Google Cloud Organization involves a few steps, and it's important to ensure you have the necessary permissions to do so. Here's a general guide on how to add a user:
Sign in to Google Cloud Console: Ensure you're logged into the Google Cloud Console with an account that has the appropriate permissions (typically an Organization Administrator or a user with IAM permissions).
Navigate to IAM & Admin:
Select Your Organization:
Add a Member:
Select Role:
roles/viewer
,roles/editor
, to more specific roles likeroles/compute.admin
. You can also create custom roles if needed.Set Conditions (Optional):
Review and Add:
Verification:
Important Considerations:
If you encounter any issues or need more specific guidance, you might want to refer to the Google Cloud documentation or contact Google Cloud Support. If this process has changed recently or if there are new features, you might want to check the latest Google Cloud documentation or ask if you need me to look up more current information.