RousselTMLEARNING

Cloud computing

IAM on Google Cloud: roles, service accounts and organization policies

Manage access on Google Cloud: principals, basic, predefined and custom roles, IAM bindings, service accounts and their keys, Workload Identity Federation, IAM conditions and organization policies.

1. Roles and bindings #

Who has which rights, where.

Principles #

IAM binding
Rights add up along the hierarchy; deny policies make it possible to remove some.
Role typeExampleUsage
Basicroles/editorTo avoid in production (too broad)
Predefinedroles/storage.objectViewerBy default
Customroles/monRoleLectureA specific need not covered
gcloud projects add-iam-policy-binding mon-projet --member=group:devs@exemple.fr --role=roles/run.developer
gcloud projects get-iam-policy mon-projet --format='table(bindings.role, bindings.members)'

2. Service accounts #

Application identities.

Best practices #

  • One service account per application, with only the roles it needs.
  • No downloaded JSON keys: identity attached to the resource (VM, Cloud Run) or Workload Identity Federation from GitHub Actions or another cloud.
  • On GKE, Workload Identity links a Kubernetes service account to a Google service account.
gcloud iam service-accounts create api-commandes --display-name="API commandes"
gcloud projects add-iam-policy-binding mon-projet --member=serviceAccount:api-commandes@mon-projet.iam.gserviceaccount.com --role=roles/datastore.user
gcloud run deploy api --image=europe-west9-docker.pkg.dev/mon-projet/app/api:1.0 --service-account=api-commandes@mon-projet.iam.gserviceaccount.com

3. Guardrails #

Organization policies and audit.

Controls #

  • Organization Policy: allowed regions (gcp.resourceLocations), forbidding service account keys and public IPs on VMs.
  • Cloud Audit Logs: admin activity always logged, data access to be enabled.
  • VPC Service Controls: a perimeter around services to limit data exfiltration.
Good practice: Use Google groups for IAM bindings: people are then managed in the groups, not in each project.

Related articles

Observability on Google Cloud: Cloud Monitoring, Logging, Trace, Profiler and Managed Prometheus

A complete overview of Google Cloud Observability: Cloud Monitoring, Cloud Logging (router, sinks, Log Analyt…

Understanding Google Cloud: regions, projects, hierarchy, tools and pricing

Google Cloud basics: regions and zones, the organization, folders and projects hierarchy, APIs to enable, con…

Google Cloud networking: global VPC, subnets, firewall and load balancing

Design networking on Google Cloud: global VPC and regional subnets, firewall rules based on tags and service …

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!