Security
Cloud IAM — roles, policies, and access-denied across AWS, GCP, Azure
Side-by-side model of identities, policies, and workload identity across AWS, GCP, and Azure, plus a repeatable way to debug any AccessDenied: find the principal, find the missing permission, grant least-privilege, verify.
Quick reference — reach for these first
aws sts get-caller-identityPrints the Account, UserId, and Arn of the caller — shows the real principal (an IAM user, or assumed-role/SESSION_NAME) behind your current credentials.gcloud auth listShows the active account (user or service account). Pair with 'gcloud config list' to confirm the active PROJECT_ID that bindings are evaluated against.az account showShows the signed-in Entra ID identity and the active SUBSCRIPTION_ID — the default RBAC scope for subsequent commands.gcloud projects test-iam-permissions PROJECT_ID --permissions=PERMISSION # AWS: aws iam simulate-principal-policyAnswers 'can this principal do X?' without performing X. Use before granting to confirm exactly which permission is missing.gcloud projects add-iam-policy-binding PROJECT_ID --member=MEMBER --role=ROLE # az role assignment create / aws iam attach-role-policyBind the narrowest role/policy that covers the one missing permission to the exact principal, at the smallest scope. Changes production access.How an API request is authorized: principal -> policy evaluation -> allow or deny
Text equivalent: A left-to-right flow. A Principal (IAM user/role, GCP member/service account, or Entra ID identity) is authenticated, then its request enters policy evaluation. Evaluation runs in order: if any explicit deny matches (SCP, permission boundary, IAM deny policy, or Azure deny assignment) the result is DENY and wins over everything. Otherwise, if a matching allow exists, the result is ALLOW. If neither matches, the default is an implicit DENY. Both deny paths lead to a Denied outcome; the allow path leads to an Allowed outcome.
Common tasks
Concept · AWS / GCP / Azure · How to debug access
| Concept | AWS / GCP / Azure | How to debug access |
|---|---|---|
| Identify the AWS principal behind current credentials | aws sts get-caller-identity | Arn is the identity you expect (watch for assumed-role/ROLE/SESSION, not an IAM user). |
| Identify the active GCP account and project | gcloud auth list && gcloud config list | The active (*) account and the project are the ones you intend to authorize against. |
| Identify the Azure identity and subscription | az account show --query '{user:user.name, sub:id}' -o json | user.name and subscription id match the intended principal and scope. |
| List managed policies attached to an AWS role | aws iam list-attached-role-policies --role-name ROLE_NAME | The policy you expect to grant the action appears in AttachedPolicies. |
| Simulate an AWS action against a principal | aws iam simulate-principal-policy --policy-source-arn PRINCIPAL_ARN --action-names s3:GetObject --resource-arns RESOURCE_ARN | EvalDecision is 'allowed'; if 'explicitDeny' or 'implicitDeny', note MatchedStatements. |
| Test whether the caller has specific GCP permissions | gcloud projects test-iam-permissions PROJECT_ID --permissions=storage.objects.get | The queried permission appears in the returned 'permissions' list (absent = not granted). |
| Read the IAM policy (bindings) on a GCP project | gcloud projects get-iam-policy PROJECT_ID --format=json | A binding ties MEMBER to the role that contains the needed permission. |
| List Azure role assignments for a principal | az role assignment list --assignee PRINCIPAL_ID --all -o table | An assignment grants a role whose actions cover the request at the right scope. |
| [CHANGES PROD] Attach a least-privilege AWS policy to a role | aws iam attach-role-policy --role-name ROLE_NAME --policy-arn POLICY_ARN | Re-run simulate-principal-policy and confirm EvalDecision is 'allowed'. |
| [CHANGES PROD] Add a GCP IAM role binding (predefined, not basic) | gcloud projects add-iam-policy-binding PROJECT_ID --member=MEMBER --role=roles/storage.objectViewer --condition=None | test-iam-permissions now returns the permission; prefer a predefined role over roles/editor|owner. |
| [CHANGES PROD] Create an Azure RBAC assignment at the narrowest scope | az role assignment create --assignee PRINCIPAL_ID --role 'ROLE_NAME' --scope RESOURCE_ID | az role assignment list shows it; scope is the resource/RG, not the whole subscription, unless required. |
| Check for an overriding guardrail (SCP / permission boundary / Org policy) | aws iam get-role --role-name ROLE_NAME --query 'Role.PermissionsBoundary' # GCP: gcloud org-policies list --project=PROJECT_ID | No boundary/SCP/deny-policy explicitly blocks the action you are granting. |
Debug an S3 AccessDenied from least-privilege back to a passing call
AWS
aws sts get-caller-identity
# Arn: arn:aws:sts::1234:assumed-role/app-reader/i-0abc (a role, not your user)aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::1234:role/app-reader --action-names s3:GetObject --resource-arns arn:aws:s3:::reports-prod/2026/q3.csv
# EvalDecision: implicitDeny (no matching allow, and no explicit deny)aws iam get-role --role-name app-reader --query 'Role.PermissionsBoundary'
# null (no permission boundary is capping the role)aws iam put-role-policy --role-name app-reader --policy-name read-reports-q3 --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:GetObject","Resource":"arn:aws:s3:::reports-prod/2026/*"}]}'
# (no output on success)aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::1234:role/app-reader --action-names s3:GetObject --resource-arns arn:aws:s3:::reports-prod/2026/q3.csv
# EvalDecision: allowed -> then: aws s3 cp s3://reports-prod/2026/q3.csv - succeedsTroubleshooting — symptom → first check → next check
| Symptom | First check | Establishes | Next check |
|---|---|---|---|
| AccessDenied even though a policy clearly grants the action | Look for an explicit deny higher up: an AWS SCP or permission boundary, a GCP IAM deny policy or Org Policy constraint, or an Azure deny assignment. | Whether an allow is being overridden — in all three clouds an explicit deny beats any allow, and access is deny-by-default without a matching allow. | Remove/adjust the deny or request an exception at the org level; do not pile on more allows — they cannot override an explicit deny. |
| Policy added to your IAM user but calls still fail | Run sts get-caller-identity / gcloud auth list / az account show — confirm the request runs as that principal, not an assumed role, service account, or managed identity. | That you edited the identity actually making the request (assumed roles and workload identities carry their own permissions, not the human's). | Attach the policy/binding to the role or service account that the workload assumes, then retry. |
| Permission boundary, SCP, or Org Policy blocks the grant | Inspect the boundary/guardrail: get-role PermissionsBoundary, aws organizations list-policies, or gcloud org-policies describe CONSTRAINT. | That the ceiling on effective permissions is lower than the role grants — the intersection, not the union, is what applies. | Widen the boundary or get the org/SCP exception; granting at the account level alone will not help while the guardrail denies it. |
| Access works in one account/project but not cross-account/cross-project | Confirm both sides: a resource policy / trust policy that allows the external principal, and an identity policy on the caller permitting the action. | That cross-boundary access needs allows on BOTH the resource side and the identity side (plus, in GCP, the resource's own project bindings). | Add the trust/resource-based allow for the external principal and verify the caller's identity policy, then re-test. |
| Intermittent 401/ExpiredToken on previously working calls | Check credential freshness: STS session expiry, 'gcloud auth print-access-token' age, or 'az account get-access-token' expiresOn. | That the failure is stale short-lived credentials, not a policy change. | Refresh the session (re-assume the role, gcloud auth login / application-default login, az login) and retry. |
| Granted the role but access only works after a delay | Re-test the exact action after a short wait; IAM changes are eventually consistent across all three providers. | That the binding/assignment is correct and the lag is propagation, not a missing permission. | Wait and retry (seconds to a couple of minutes); if it never resolves, re-inspect for an overriding deny. |
References
- AWS — Policy evaluation logic (deny / allow / default)docs.aws.amazon.com
- Google Cloud — IAM overview (members, roles, bindings)cloud.google.com
- Google Cloud — IAM deny policiescloud.google.com
- Azure — RBAC overview (role assignments and scope)learn.microsoft.com
- Azure — How RBAC determines access (deny assignments)learn.microsoft.com