IAM Operations: Users, Roles, Policies, Permission Boundaries, Access Analyzer and Credential Hygiene

AWS SysOps Associate 60 min min read Updated: Nov 17, 2026 Intermediate
IAM Operations: Users, Roles, Policies, Permission Boundaries, Access Analyzer and Credential Hygiene
Intermediate Topic 1 of 4

IAM Building Blocks

ItemMeaning
Root userAccount owner with unlimited power. Enable MFA, no access keys, use only for the few tasks that need it, store credentials safely
IAM userLong-term identity with password and/or access keys. Prefer Identity Center for humans
GroupCollection of users to attach policies to. Cannot contain groups and cannot be a principal
RoleIdentity assumed temporarily by users, services, or other accounts. Has a trust policy (who can assume) and permission policies (what it can do). Gives short-term credentials through STS
Instance profileContainer that passes a role to an EC2 instance
PolicyJSON document of permissions

Policy Types

Policy typeAttached toPurpose
Identity-basedUsers, groups, rolesGrant permissions. Managed (AWS or customer) or inline
Resource-basedResource (S3 bucket, KMS key, SQS queue, Lambda, role trust policy)Grant access to principals, including cross-account
Permission boundaryUser or roleMaximum permissions the identity can have (does not grant by itself)
Service control policy (SCP)Organization root, OU or accountGuardrail for accounts. Does not grant. Does not affect the management account or service-linked roles
Session policyPassed during AssumeRoleFurther restricts that session
Resource control policy (RCP)OrganizationGuardrail on resources in member accounts
VPC endpoint policyEndpointRestricts what can be used through the endpoint

Policy Structure

json { "Version": "2012-10-17", "Statement": [ {"Sid": "ReadOpsBucket", "Effect": "Allow", "Action": ["s3:GetObject", "s3:ListBucket"], "Resource": ["arn:aws:s3:::ops-reports", "arn:aws:s3:::ops-reports/*"], "Condition": {"IpAddress": {"aws:SourceIp": "203.0.113.0/24"}, "Bool": {"aws:MultiFactorAuthPresent": "true"}}}, {"Sid": "DenyDeleteProd", "Effect": "Deny", "Action": "ec2:TerminateInstances", "Resource": "*", "Condition": {"StringEquals": {"aws:ResourceTag/env": "prod"}}} ]}
  • Elements: Effect, Action/NotAction, Resource/NotResource, Principal (resource policies), Condition
  • Useful condition keys: aws:SourceIp, aws:RequestedRegion, aws:PrincipalOrgID, aws:MultiFactorAuthPresent, aws:SecureTransport, aws:ResourceTag/<k>, aws:PrincipalTag/<k>, aws:SourceVpce
  • Attribute-based access control (ABAC): allow actions when the principal tag matches the resource tag, so permissions scale with tags

Policy Evaluation Logic

  1. By default everything is implicitly denied
  2. An explicit Deny anywhere (identity, resource, SCP, boundary, session) always wins
  3. Otherwise there must be an Allow in identity or resource policy and it must pass the guardrails (SCP, permission boundary, session policy)
  4. Same account: identity policy or resource policy allow is enough (unless a guardrail blocks)
  5. Cross-account: both the identity policy in the caller account and the resource policy in the owning account must allow (for roles: the role's trust policy plus the caller's permission to call sts:AssumeRole)
Remember Explicit Deny > Allow > implicit Deny. SCPs and permission boundaries only limit. They never grant permissions on their own.

Roles and STS

bash aws sts get-caller-identity aws sts assume-role --role-arn arn:aws:iam::222222222222:role/OpsAdmin --role-session-name alice-ops --serial-number arn:aws:iam::111111111111:mfa/alice --token-code 123456 --duration-seconds 3600 aws iam create-role --role-name AppRole --assume-role-policy-document file://trust.json aws iam attach-role-policy --role-name AppRole --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::111111111111:role/AppRole --action-names s3:GetObject --resource-arns arn:aws:s3:::ops-reports/a.csv
json {"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Principal": {"Service": "ec2.amazonaws.com"}, "Action": "sts:AssumeRole"}]}
  • Service roles (EC2, Lambda, ECS tasks) provide credentials automatically. Service-linked roles are created by services and cannot be edited
  • Cross-account role: trust policy names the other account (add ExternalId for third parties, aws:PrincipalOrgID for your org)
  • Role chaining limits the session to 1 hour. Session duration is 1 hour by default, up to the role's maximum (up to 12 hours)
  • **iam:PassRole** is needed to give a role to a service. Restrict it to the specific roles and services

Human Access: IAM Identity Center

  • IAM Identity Center (successor to AWS SSO) gives workforce users single sign-on to many accounts using permission sets (policies applied as roles in each account), with a built-in directory or an external IdP (Entra ID, Okta) via SAML/SCIM
  • Short-lived credentials, central MFA, aws sso login
  • Prefer it to creating IAM users in every account

Credential Hygiene

PracticeDetail
MFA for root and all humansVirtual, FIDO2/passkeys or hardware. Require in policies for sensitive actions
Rotate or remove access keysaws iam list-access-keys, get-access-key-last-used. Delete unused keys
Credential reportaws iam generate-credential-report then get-credential-report lists users with password age, MFA, key age
Password policyLength, rotation, reuse prevention
No credentials in codeUse roles, Secrets Manager, environment injection. Scan repositories (git-secrets, GuardDuty/CodeGuru)
Leaked key responseDeactivate the key, review CloudTrail for use, rotate, check for new users/roles/resources, apply the AWS-opened support case guidance
Least privilegeStart from AWS managed job-function policies, then narrow using Access Analyzer policy generation from CloudTrail activity
bash aws iam generate-credential-report && aws iam get-credential-report --query Content --output text | base64 -d | head aws iam list-users --query 'Users[].UserName' aws iam get-account-summary --query 'SummaryMap.[AccountMFAEnabled,AccountAccessKeysPresent]' aws iam update-access-key --user-name bob --access-key-id AKIA... --status Inactive

IAM Access Analyzer and Advisor

  • External access analyzer: finds resources shared outside your account or organization (S3, IAM roles, KMS, Lambda, SQS, Secrets Manager...)
  • Unused access analyzer: finds unused roles, users, keys and permissions
  • Policy validation and custom policy checks for CI pipelines. Policy generation from CloudTrail
  • IAM last accessed information (Access Advisor) shows which services a principal used, to trim permissions

Troubleshooting AccessDenied

  1. Read the error: it names the principal, action and resource and often the kind of policy that denied it
  2. Check identity policies attached to the principal and groups, then resource policy
  3. Look for explicit Deny, SCP, permission boundary, session policy, VPC endpoint policy
  4. Check conditions: MFA, source IP, region, tags, time, aws:SourceVpce
  5. For KMS: both the key policy (or grants) and IAM must allow
  6. Use the IAM policy simulator and CloudTrail (errorCode, errorMessage) to confirm
  7. For UnauthorizedOperation, decode the message with aws sts decode-authorization-message
ErrorMeaning
AccessDenied on AssumeRoleTrust policy does not include the caller, or caller lacks sts:AssumeRole, or MFA/ExternalId condition fails
not authorized to perform iam:PassRoleAdd iam:PassRole for that role ARN
ExpiredTokenSession credentials expired, refresh
InvalidClientTokenId / SignatureDoesNotMatchWrong, deleted or mistyped keys, or clock skew
explicit deny in a service control policySCP blocks. Ask the organization admin

Practice Tasks

  1. Create a role for EC2 with S3 read access and use it from an instance without keys
  2. Write a cross-account role and assume it from the CLI with MFA
  3. Add a permission boundary and prove it blocks iam:CreateUser
  4. Run the credential report and list keys older than 90 days
  5. Generate a least-privilege policy using Access Analyzer from CloudTrail

Conclusion

Use roles and Identity Center instead of long-lived keys, understand policy types and the evaluation rule (explicit deny wins, guardrails only limit, cross-account needs both sides), protect root and humans with MFA, review credentials and external access regularly, and troubleshoot AccessDenied with the error text, simulator and CloudTrail.

Quick Summary: building blocks; policy types; structure; evaluation; roles; Identity Center; hygiene; Access Analyzer; troubleshooting.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators