Principals & Roles

Who Can Do What on Which Resource

IAM answers one question: who (principal) can do what (role = set of permissions) on which resource. An IAM policy attached to a resource (project, bucket, ...) lists these bindings.

PrincipalExample
Google accountuser:[email protected]
Google groupgroup:[email protected] (recommended for teams)
Service accountserviceAccount:[email protected]
Domaindomain:example.com

Types of Roles

TypeExamplesAdvice
BasicOwner, Editor, Viewervery broad: avoid in production
Predefinedroles/storage.objectViewer, roles/run.developeruse these
Customyour own list of permissionswhen no predefined role fits

Granting a Role

Example

gcloud projects add-iam-policy-binding shop-dev-1234 \
  --member="group:[email protected]" \
  --role="roles/run.developer"

Example output

Updated IAM policy for project [shop-dev-1234].
bindings:
- members:
  - group:[email protected]
  role: roles/run.developer