Careeroza
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.
| Principal | Example |
|---|---|
| Google account | user:[email protected] |
| Google group | group:[email protected] (recommended for teams) |
| Service account | serviceAccount:[email protected] |
| Domain | domain:example.com |
Types of Roles
| Type | Examples | Advice |
|---|---|---|
| Basic | Owner, Editor, Viewer | very broad: avoid in production |
| Predefined | roles/storage.objectViewer, roles/run.developer | use these |
| Custom | your own list of permissions | when 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