Skip to content
RED SAGSkills

IAM interview questions and answers

IAM (identity and access management) questions check how you give people and services exactly the access they need.

Below are 46 IAM questions with the correct answer and a short explanation, grouped from fresher to experienced level. Try each one before you open the answer.

What IAM interviews usually check

  • ✓Users, roles and policies
  • ✓Least privilege
  • ✓Temporary credentials and role assumption
  • ✓Policy evaluation and deny rules
  • ✓Auditing access

IAM interview questions for freshers easy

1. IAM user vs IAM role

A new reporting service running on EC2 needs to read from S3. What is the main security advantage of giving it an IAM role instead of creating an IAM user with access keys?

  1. A.The role can be shared by human users to log in to the console
  2. B.The role skips policy evaluation, so requests are faster
  3. C.The role hands out short-lived credentials that rotate automatically
  4. D.The role cannot be given any permissions beyond read-only
Show answer

Answer: C. The role hands out short-lived credentials that rotate automatically

An IAM role has no long-term password or access key. Whoever assumes it gets temporary credentials from STS that expire and are refreshed automatically, so there is no static secret to leak or forget to rotate. Roles still go through normal policy evaluation and can hold any permissions you attach.

2. Explicit deny always wins

A user has one policy that allows s3:DeleteObject on a bucket and another policy that explicitly denies s3:DeleteObject on the same bucket. What happens when they try to delete an object?

  1. A.The request is denied because an explicit deny overrides any allow
  2. B.The request is allowed because allows are evaluated first
  3. C.The policy attached most recently decides the result
  4. D.The request is allowed only if the user has MFA enabled
Show answer

Answer: A. The request is denied because an explicit deny overrides any allow

In AWS policy evaluation an explicit Deny in any applicable policy always beats an Allow. The order in which policies were attached does not matter. This is why deny statements are a reliable guardrail.

3. Why MFA for console sign-in

Your company in Dubai still has a few IAM users who sign in to the AWS console with just a password. What does adding MFA protect against most directly?

  1. A.A developer who has too many permissions attached
  2. B.An attacker who has stolen or guessed the password
  3. C.Data being read in transit over plain HTTP
  4. D.An S3 bucket being made public by mistake
Show answer

Answer: B. An attacker who has stolen or guessed the password

MFA adds a second factor, such as an authenticator app or security key, so a leaked or phished password alone is not enough to sign in. It does nothing about over-broad permissions or bucket settings, which need least privilege and configuration controls. Phishing-resistant keys (FIDO2/passkeys) give the strongest protection.

4. Problem with old access keys

An audit finds an IAM access key that was created three years ago and is still used by a script on a laptop. What is the main risk?

  1. A.The key will stop working suddenly once it is older than two years
  2. B.A static secret that may have been copied or leaked over time
  3. C.Old keys are allowed to bypass service control policies
  4. D.Old keys are given administrator permissions automatically
Show answer

Answer: B. A static secret that may have been copied or leaked over time

Access keys do not expire by themselves, so a key that has lived on a laptop for years could be in backups, shell history or a public repo. The fix is to move the script to temporary credentials (SSO, roles) or at least rotate the key and limit its permissions. Key age does not change how policies are evaluated.

5. Identity-based vs resource-based policy

Which statement correctly describes a resource-based policy such as an S3 bucket policy?

  1. A.It is attached to a user and lists which resources that user may use
  2. B.It is attached to a group and is inherited by all members
  3. C.It is attached to the AWS account and applies to every service
  4. D.It is attached to the resource and names which principals may access it
Show answer

Answer: D. It is attached to the resource and names which principals may access it

Identity-based policies attach to users, groups or roles and say what that identity can do. Resource-based policies attach to resources like S3 buckets, KMS keys or SQS queues and include a Principal element that says who can access them. Resource-based policies are also how you grant access across accounts.

6. Managed vs inline policies

Why do most teams prefer customer managed policies over inline policies for common permissions?

  1. A.Inline policies are not allowed to contain any Deny statements
  2. B.Managed policies are evaluated before inline policies
  3. C.Inline policies only work when attached to the root user
  4. D.One managed policy is reusable across identities and versioned
Show answer

Answer: D. One managed policy is reusable across identities and versioned

A customer managed policy is a standalone object you can attach to many users, groups and roles, and AWS keeps up to five versions so you can roll back. Inline policies are embedded in one identity and deleted with it, which suits strict one-to-one cases. Both support Allow and Deny and are evaluated together.

7. GCP service accounts

In Google Cloud, what is a service account mainly used for?

  1. A.An identity that workloads use to call Google Cloud APIs
  2. B.A billing account that pays for usage in a project
  3. C.A shared login for a team of human administrators
  4. D.A folder that groups related projects for one team
Show answer

Answer: A. An identity that workloads use to call Google Cloud APIs

A service account is a non-human identity that applications use to authenticate to Google Cloud APIs. You grant it IAM roles like any other principal. Humans should use their own accounts, and attached service accounts are preferred over downloaded JSON keys.

8. Workforce access through SSO

A company with 200 engineers uses Microsoft Entra ID for email. What is the recommended way to give them AWS console and CLI access?

  1. A.Federate Entra ID with IAM Identity Center and use permission sets
  2. B.Create an IAM user and access key for every engineer
  3. C.Share the root user credentials through a password manager
  4. D.Give everyone one IAM user per team with a shared password
Show answer

Answer: A. Federate Entra ID with IAM Identity Center and use permission sets

Federation means people sign in with their existing corporate identity, get temporary credentials, and lose access automatically when they leave the company. IAM Identity Center maps groups from the identity provider to permission sets in each account. This avoids hundreds of long-lived IAM users and access keys.

9. What a principal is

In IAM terms, what is a principal?

  1. A.The resource that is being accessed
  2. B.The region where the request is processed
  3. C.The person or application making a request to AWS
  4. D.The policy that is attached to the resource
Show answer

Answer: C. The person or application making a request to AWS

A principal is the entity that makes the request: the root user, an IAM user, an assumed role session, a federated user or an AWS service. Policies are evaluated against the principal, the action and the resource. Resource-based policies use the Principal element to name who may access them.

10. Meaning of s3:* in a policy

A policy statement has "Effect": "Allow", "Action": "s3:*", "Resource": "*". What does it grant?

  1. A.Only read and list actions on all S3 buckets
  2. B.Every S3 action, including deletes, on all buckets
  3. C.Every action in every AWS service in the account
  4. D.Only actions on buckets whose name starts with s3
Show answer

Answer: B. Every S3 action, including deletes, on all buckets

The wildcard after the service prefix matches every S3 action, which includes DeleteBucket and PutBucketPolicy. With Resource set to "*" it applies to all buckets and objects in scope. This is far more than most workloads need, and least privilege means listing specific actions and ARNs.

11. Rebuilding the stack in a new region

Data is replicated to the DR region, but network, IAM, secrets and servers there were set up by hand years ago. What reduces DR risk?

  1. A.Define it as code and deploy to both regions
  2. B.Take screenshots of the console settings
  3. C.Keep only one region to keep it simple
  4. D.Copy the old server disks every year
Show answer

Answer: A. Define it as code and deploy to both regions

Hand-built environments drift and are hard to rebuild under pressure. Terraform or similar code lets you recreate the same network, permissions and services in the DR region, and test that regularly. Data replication alone is not a working site.

12. Someone stopped CloudTrail

CloudTrail shows a StopLogging call on your main trail from an IAM user who never touches logging. Why is this a high-priority detection?

  1. A.Attackers turn off cloud logs to hide what they do next
  2. B.StopLogging is how AWS rotates its log files daily
  3. C.It means the AWS bill for logging has been paid
  4. D.It only affects logs in the us-east-1 region
Show answer

Answer: A. Attackers turn off cloud logs to hide what they do next

Stopping or deleting a trail blinds the defender, so it often comes just before the real attack. ATT&CK maps it to T1562.008 Disable or Modify Cloud Logs. Alert on StopLogging, DeleteTrail and changes to event selectors, and protect trails with SCPs.

13. Protecting the AWS root user

What is the recommended way to protect an AWS account's root user?

  1. A.Share its password with the whole cloud team for emergencies
  2. B.Create access keys for it and use them in CI pipelines
  3. C.Use it for daily work so actions show the highest privilege
  4. D.Enable MFA on it, delete its access keys, and use it only for rare tasks
Show answer

Answer: D. Enable MFA on it, delete its access keys, and use it only for rare tasks

The root user has full control of the account and cannot be limited by IAM policies. Protect it with strong MFA, keep no access keys for it, and use it only for the few tasks that need it. Daily work should use roles through IAM Identity Center or similar.

14. What SCIM provisioning does

Your IAM team wants to connect Entra ID to Slack and Zoom using SCIM. What will SCIM do for you?

  1. A.Encrypt the SAML assertions sent to each app
  2. B.Create, update and disable app accounts automatically
  3. C.Replace passwords with passkeys inside each app
  4. D.Scan each app for users with weak passwords
Show answer

Answer: B. Create, update and disable app accounts automatically

SCIM is a standard API that lets the identity provider push account changes to SaaS apps. When someone joins, changes team or leaves, the matching account in each app is created, updated or deactivated without manual tickets. It complements SSO, which only handles sign-in.

15. Allow in one policy, deny in another

An IAM user's identity policy allows s3:* on all buckets. The bucket policy on 'finance-reports' has an explicit Deny for s3:DeleteObject for that user. What happens when the user tries to delete a report?

  1. A.Allowed, because the identity policy is evaluated first
  2. B.Allowed, because s3:* is broader than s3:DeleteObject
  3. C.Denied, because an explicit Deny overrides any Allow
  4. D.Denied only if the bucket is in a different account
Show answer

Answer: C. Denied, because an explicit Deny overrides any Allow

AWS evaluates all applicable policies together. If any of them contains an explicit Deny that matches the request, the request is denied, no matter how many Allows exist. This makes explicit Deny statements a reliable guardrail for sensitive actions.

16. Giving 40 engineers AWS access

A Bengaluru startup has 40 engineers who need console and CLI access to five AWS accounts. Which approach is the current best practice?

  1. A.One IAM user per engineer per account, with access keys
  2. B.One shared IAM user per team, with MFA on the user
  3. C.The root user for admins and IAM users for everyone else
  4. D.IAM Identity Center with SSO, giving short-lived credentials
Show answer

Answer: D. IAM Identity Center with SSO, giving short-lived credentials

IAM Identity Center connects to your identity provider and gives people temporary credentials through permission sets, across all accounts. Leavers lose AWS access when they are disabled in the IdP, and there are no long-term access keys to leak. IAM users with keys are now reserved for the few cases that truly need them.

IAM intermediate interview questions medium

17. Cross-account KMS decrypt fails

A role in account B has kms:Decrypt in its IAM policy but cannot read S3 objects encrypted with a customer managed key in account A. What is missing?

  1. A.The key policy in account A must also allow account B's principal
  2. B.KMS keys can never be used across accounts
  3. C.Account B should switch to the AWS managed aws/s3 key
  4. D.S3 Transfer Acceleration must be enabled
Show answer

Answer: A. The key policy in account A must also allow account B's principal

For cross-account use, both the key policy in the owning account and an IAM policy in the calling account must allow the action. The key policy is the main control over who can use a KMS key. AWS managed keys such as aws/s3 cannot be shared across accounts at all.

18. Giving an app on EC2 access to S3

An app on EC2 needs to write to S3. What is the right way to give it credentials?

  1. A.Put an IAM user's access keys in the code
  2. B.Store the root user keys in an env file
  3. C.Make the bucket public for writes
  4. D.Attach an IAM role through an instance profile
Show answer

Answer: D. Attach an IAM role through an instance profile

An instance role provides short-lived credentials that rotate automatically through the instance metadata service, so no long-term keys sit on disk or in code. Azure uses managed identities and Google Cloud uses attached service accounts for the same purpose.

19. An allow and a deny on the same action

A user's IAM policy allows s3:DeleteObject on a bucket. The bucket policy explicitly denies s3:DeleteObject for everyone except a backup role. Can the user delete objects?

  1. A.Yes; identity policies beat bucket policies
  2. B.Yes; the most recent policy wins
  3. C.No; an explicit deny overrides any allow
  4. D.Only if the user has MFA enabled
Show answer

Answer: C. No; an explicit deny overrides any allow

AWS policy evaluation starts from implicit deny, then an allow is needed, but any explicit deny in any applicable policy wins over every allow. Explicit denies are a strong guardrail for sensitive actions.

20. Downloaded service account keys

A team downloads a Google Cloud service account JSON key to let an on-prem job call Cloud Storage. Why is this discouraged, and what is preferred?

  1. A.Long-lived keys leak; use workload identity
  2. B.Keys expire after one hour, so CI jobs fail
  3. C.JSON keys cannot be used to call Cloud Storage
  4. D.Service accounts are only meant for human users
Show answer

Answer: A. Long-lived keys leak; use workload identity

Exported service account keys are long-lived secrets that are easy to leak and hard to track. Workload identity federation lets external workloads exchange their own identity token for short-lived Google credentials with no stored key.

21. Requiring MFA for sensitive actions

You want to let engineers stop production EC2 instances only if they signed in with MFA. Which condition does that?

"Condition": { "Bool": { "aws:MultiFactorAuthPresent": "true" } }
  1. A.Add this condition to a Deny statement for ec2:StopInstances
  2. B.Put the condition in the role's trust policy only
  3. C.Add it to the Resource element of the statement
  4. D.Add this condition to the Allow statement for ec2:StopInstances
Show answer

Answer: D. Add this condition to the Allow statement for ec2:StopInstances

Putting the condition on the Allow means the action is only allowed when the request was made with MFA-authenticated credentials. A Deny with the same "true" condition would do the opposite and block MFA users. For a deny-based guard you would use BoolIfExists with "false", because the key is absent for long-term access keys.

22. Allow with NotAction

A developer writes this statement to 'give everything except IAM'. What does it actually grant?

{
  "Effect": "Allow",
  "NotAction": "iam:*",
  "Resource": "*"
}
  1. A.Nothing, because NotAction can only be used with Deny
  2. B.Every action in every service other than IAM
  3. C.Only read-only actions in services outside IAM
  4. D.Full IAM access, since NotAction inverts the effect
Show answer

Answer: B. Every action in every service other than IAM

NotAction with Allow grants every action that is not listed, across all services and any new services AWS adds later. It does not block IAM if another policy allows it; it simply does not grant IAM. It is valid, but it is almost always far broader than intended.

23. ListBucket needs the bucket ARN

A role can download files but gets AccessDenied when running aws s3 ls s3://reports-prod/. What is wrong with this policy?

{
  "Effect": "Allow",
  "Action": ["s3:GetObject", "s3:ListBucket"],
  "Resource": "arn:aws:s3:::reports-prod/*"
}
  1. A.ListBucket must be granted in a separate Deny statement
  2. B.The S3 ARN is missing the account ID and the region
  3. C.aws s3 ls needs s3:ListAllMyBuckets on the bucket
  4. D.ListBucket needs the bucket ARN, which is not listed
Show answer

Answer: D. ListBucket needs the bucket ARN, which is not listed

s3:ListBucket is a bucket-level action, so its resource is arn:aws:s3:::reports-prod. Object actions like GetObject use the object ARN with /*. The fix is to include both ARNs, ideally in separate statements so each action matches the right resource.

24. What a session policy does

An application calls sts:AssumeRole and passes an inline session policy that allows only s3:GetObject on one prefix. The role itself allows s3:*. What can the session do?

  1. A.All S3 actions, since the role policy is broader
  2. B.s3:* plus GetObject, because the policies add together
  3. C.Nothing until an administrator approves the session policy
  4. D.Only s3:GetObject on that prefix
Show answer

Answer: D. Only s3:GetObject on that prefix

A session policy can only narrow permissions. The session gets the intersection of the role's identity policies and the session policy. This is useful for brokers that hand out tightly scoped credentials per tenant or per request.

25. Finding unused access keys

You need a list of every IAM user with the age of their password and access keys and when each key was last used. Which built-in feature gives this as a CSV?

  1. A.AWS Cost Explorer
  2. B.The IAM credential report
  3. C.Amazon Inspector findings
  4. D.The S3 server access log
Show answer

Answer: B. The IAM credential report

The credential report lists all users with password status, MFA status, access key age, last rotation and last used date. It is the quickest way to find stale keys to rotate or delete. Inspector scans workloads for vulnerabilities, and Cost Explorer shows spending.

26. How long a role session lasts

A data engineer's job runs 6 hours, but the credentials from assuming a role expire after 1 hour. What should you change?

  1. A.Set "Expire": "never" in the role's trust policy
  2. B.Switch the job to use the root user's access keys
  3. C.Raise the role's maximum session duration and request longer
  4. D.Nothing; role sessions can never last more than 1 hour
Show answer

Answer: C. Raise the role's maximum session duration and request longer

The default role session is one hour, but you can set the role's maximum session duration up to 12 hours and request a longer DurationSeconds when assuming it. SDKs that use a credential provider can also refresh credentials automatically before expiry. Role chaining is the exception, capped at one hour.

27. StringEquals vs StringLike

A condition must match any S3 prefix that starts with reports/2026/. Which operator is needed?

"Condition": { "???": { "s3:prefix": "reports/2026/*" } }
  1. A.StringEquals, because it also expands wildcards
  2. B.StringLike, because it supports the * wildcard
  3. C.ArnEquals, because the prefix is part of an ARN
  4. D.NumericEquals, because 2026 is a number
Show answer

Answer: B. StringLike, because it supports the * wildcard

StringEquals compares the literal text, so "reports/2026/*" would only match a value with an actual asterisk. StringLike supports * and ? wildcards. Using the wrong operator is a common reason a condition silently never matches.

28. Using a key only through one service

You want a role to use a KMS key only when the request comes through Amazon S3 in me-central-1, not by calling KMS directly. Which condition fits?

  1. A.aws:SourceIp equal to the S3 service IP range
  2. B.kms:ViaService equal to s3.me-central-1.amazonaws.com
  3. C.kms:EncryptionAlgorithm equal to SYMMETRIC_DEFAULT
  4. D.aws:SecureTransport equal to true for S3 traffic
Show answer

Answer: B. kms:ViaService equal to s3.me-central-1.amazonaws.com

kms:ViaService limits key use to requests that an AWS service makes on the principal's behalf, such as S3 calling KMS for SSE-KMS. A direct kms:Decrypt call from the CLI would then be denied. Service IPs are not reliable or practical as conditions.

29. GCP VPC Service Controls

In Google Cloud, a stolen service account token is used from an attacker's laptop to copy BigQuery data to their own project. Which control is designed to stop that even with valid credentials?

  1. A.A VPC firewall rule denying egress on port 443 from all VMs
  2. B.Granting the service account the Viewer role instead of Editor
  3. C.Turning on default encryption at rest for BigQuery tables
  4. D.A VPC Service Controls perimeter around the projects and services
Show answer

Answer: D. A VPC Service Controls perimeter around the projects and services

VPC Service Controls create a perimeter around projects and Google APIs such as BigQuery and Cloud Storage, blocking data movement to resources outside it and requests from outside unless allowed by access levels. IAM alone trusts a valid token from anywhere. Firewall rules do not govern Google API calls made from the internet.

30. Admin blocked by an SCP

An SCP on your 'Prod' OU denies all actions outside me-central-1 and ap-south-1, with exceptions for global services. A member-account user with AdministratorAccess tries to launch EC2 in us-east-1. What happens?

  1. A.It succeeds, because AdministratorAccess overrides SCPs
  2. B.It succeeds, but CloudTrail marks it as a violation
  3. C.It is denied, because SCPs cap what any principal can do
  4. D.It is denied only if the user has no MFA session
Show answer

Answer: C. It is denied, because SCPs cap what any principal can do

Service control policies set the maximum permissions for every principal in member accounts, including account admins and the account root user. An identity policy cannot grant what an SCP denies. SCPs do not apply to the organization's management account, which is one reason to keep workloads out of it.

31. Assuming a role in another account

A user in AWS account A needs to assume the 'ReadAudit' role in account B. What must be in place?

  1. A.B's role trust policy allows A, and A's identity policy allows sts:AssumeRole on it
  2. B.Only an identity policy in account A allowing sts:AssumeRole on the role
  3. C.Only a trust policy on the role in account B naming account A
  4. D.Both accounts must be in the same AWS Organization and region
Show answer

Answer: A. B's role trust policy allows A, and A's identity policy allows sts:AssumeRole on it

Cross-account access needs both sides to agree. Account B decides who may assume its role through the trust policy, and account A must grant its own user permission to call sts:AssumeRole on that role. If either is missing, the call is denied.

32. Restricting a bucket to your organization

A shared S3 bucket should be readable by any role in any of your 30 AWS accounts, but by nobody outside your AWS Organization. Which bucket policy approach fits best?

  1. A.List all 30 account IDs and update the list for each new account
  2. B.Use a condition on aws:PrincipalOrgID matching your organization ID
  3. C.Make the bucket public and rely on obscure object names
  4. D.Use a condition on aws:SourceIp with your office IP range
Show answer

Answer: B. Use a condition on aws:PrincipalOrgID matching your organization ID

The aws:PrincipalOrgID condition key matches any principal from accounts in your organization, so new accounts are covered automatically. It is simpler and less error-prone than a long list of account IDs. Source IP conditions break for AWS services and remote workers, and public buckets are a classic data leak.

IAM interview questions for experienced candidates hard

33. Cannot read objects a partner uploaded

A partner account uploads files into your older S3 bucket that still uses ACLs. Your own roles get AccessDenied when reading those objects, even with s3:GetObject allowed. What is the fix?

  1. A.Enable versioning so ownership is reset on each write
  2. B.Set Object Ownership to BucketOwnerEnforced so the bucket owner owns all objects
  3. C.Require KMS encryption, which is mandatory for cross-account writes
  4. D.Turn on Requester Pays for the bucket
Show answer

Answer: B. Set Object Ownership to BucketOwnerEnforced so the bucket owner owns all objects

With ACLs enabled, an object uploaded by another account is owned by that account, and the bucket owner may have no access unless an ACL grants it. BucketOwnerEnforced disables ACLs and makes the bucket owner own every object, so access is controlled by policies only. New buckets use this setting by default since 2023, but older buckets often do not.

34. Securing a role for a SaaS vendor

A third-party monitoring SaaS assumes a role in your account. How do you stop another customer of that vendor from tricking it into using your role (the confused deputy problem)?

  1. A.Give the role a long random name
  2. B.Only allow the vendor source IP addresses
  3. C.Require a unique sts:ExternalId in the trust policy
  4. D.Attach only the ReadOnlyAccess managed policy
Show answer

Answer: C. Require a unique sts:ExternalId in the trust policy

The vendor uses one AWS account for all customers, so trusting that account alone is not enough. A unique external ID that the vendor stores for your tenant must be sent on AssumeRole, so another tenant cannot point the vendor at your role ARN. Least privilege still matters, but it does not stop the confused deputy.

35. Bucket policy alone in one account

In the same AWS account, an IAM user has no identity policies at all. The S3 bucket policy explicitly allows that user's ARN to s3:GetObject. Can the user read objects (assume no SCPs, boundaries or KMS)?

  1. A.Yes, a resource policy allow is enough within the same account
  2. B.No, the user always needs an identity policy too
  3. C.No, because bucket policies only apply to other accounts
  4. D.Yes, but only through the S3 console, not the CLI
Show answer

Answer: A. Yes, a resource policy allow is enough within the same account

Within one account, an allow in either the identity policy or the resource-based policy is enough, as long as nothing denies it. Across accounts, both sides must allow. This is why reviewing bucket and key policies matters even for users who look like they have no permissions.

36. Letting developers create roles safely

Developers need to create IAM roles for their Lambda functions without being able to give themselves admin access. Which control does that?

  1. A.Allow iam:CreateRole and rely on code review of every role name
  2. B.Allow iam:* but explicitly deny iam:DeleteRole and DeleteUser
  3. C.Allow iam:CreateRole only in a different, unused region
  4. D.Allow iam:CreateRole only if iam:PermissionsBoundary is the approved one
Show answer

Answer: D. Allow iam:CreateRole only if iam:PermissionsBoundary is the approved one

Requiring the iam:PermissionsBoundary condition forces every new role to carry a boundary that caps its permissions. You also deny removing or changing the boundary and editing the boundary policy itself. Without this, anyone who can create roles and attach policies can escalate to admin.

37. Escalation with CreatePolicyVersion

A user has only these permissions on a customer managed policy that is attached to their own group. Why is this dangerous?

"Action": ["iam:CreatePolicyVersion"],
"Resource": "arn:aws:iam::111111111111:policy/dev-team"
  1. A.They can read the passwords of other IAM users
  2. B.They can make a new default version that grants them anything
  3. C.They can disable CloudTrail without leaving any trace
  4. D.There is no risk; policy versions need approval
Show answer

Answer: B. They can make a new default version that grants them anything

iam:CreatePolicyVersion with --set-as-default lets the caller replace the policy's content, and since the policy is attached to their own group they can grant themselves "*". This is a well-known privilege escalation path. Treat any IAM write action on policies you are subject to as admin-equivalent.

38. Updating code of a privileged Lambda

A developer can call lambda:UpdateFunctionCode on any function, but has no IAM permissions. One function runs with an admin role. What can they do?

  1. A.Nothing beyond changing the function's logic, since they have no IAM rights
  2. B.Deploy code that uses the function's admin role to act on their behalf
  3. C.Only read the function's environment variables
  4. D.Change the function's execution role to their own user
Show answer

Answer: B. Deploy code that uses the function's admin role to act on their behalf

Code inside a Lambda runs with the execution role's credentials. Replacing the code lets the developer run any API calls the role allows, effectively borrowing its admin rights. Scope lambda:UpdateFunctionCode by function ARN and keep powerful roles off functions that many people can edit.

39. ForAllValues with a missing key

A policy allows tagging only with approved tag keys using this condition. A request is made with no tags at all. What happens?

"Effect": "Allow",
"Action": "ec2:CreateTags",
"Condition": {
  "ForAllValues:StringEquals": { "aws:TagKeys": ["env", "owner"] }
}
  1. A.The condition fails, because no approved key was sent
  2. B.The request errors out with a policy syntax error
  3. C.The condition is skipped and the policy is ignored
  4. D.It matches, because ForAllValues is true for an empty set
Show answer

Answer: D. It matches, because ForAllValues is true for an empty set

ForAllValues checks that every value in the request is in the list, which is vacuously true when the key is missing or empty. To also require that the key is present, add a Null condition such as "aws:TagKeys": "false". This trap can make an allow broader than intended.

40. Confused deputy with service principals

An SNS topic policy lets the S3 service principal publish to it so that bucket events can be sent. What should you add to stop someone else's bucket from publishing to your topic?

  1. A.A condition on aws:SourceArn matching your bucket
  2. B.A condition requiring aws:SecureTransport to be true
  3. C.A Deny statement for the s3.amazonaws.com principal
  4. D.Server-side encryption with KMS on the SNS topic
Show answer

Answer: A. A condition on aws:SourceArn matching your bucket

Granting a service principal without conditions means the service may act on behalf of any customer's resource that names your topic. Restricting aws:SourceArn to your bucket ARN, or aws:SourceAccount to your account, prevents this cross-service confused deputy problem. Encryption and TLS do not address who is allowed to call.

41. Killing stolen role credentials

Temporary credentials from a role were stolen and are still valid for several hours. Detaching the role's policies would also break production. What is the targeted fix?

  1. A.Delete the role's trust policy and recreate it again tomorrow
  2. B.Rotate the role's access key from the IAM console page
  3. C.Use "Revoke active sessions" to deny tokens issued before now
  4. D.Wait for the credentials to expire on their own
Show answer

Answer: C. Use "Revoke active sessions" to deny tokens issued before now

The "Revoke active sessions" action adds an inline policy that denies everything when aws:TokenIssueTime is earlier than the current time. Existing stolen sessions stop working, while new legitimate sessions continue. Roles have no access keys to rotate, and waiting gives the attacker hours.

42. Allow only your organization

A shared artifacts bucket must be readable by any account in your AWS Organization, including accounts created next year, but by no one else. Which approach fits best?

  1. A.List every current account ID in the Principal element
  2. B.Principal "*" with a condition aws:PrincipalOrgID equal to your org ID
  3. C.Make the bucket public and rely on obscure object names
  4. D.Principal "*" with a condition aws:SourceIp for the office
Show answer

Answer: B. Principal "*" with a condition aws:PrincipalOrgID equal to your org ID

aws:PrincipalOrgID checks that the calling principal belongs to your organization, so new accounts are covered automatically and outsiders are not. Listing account IDs needs updates every time an account is added. With "*" as the principal, the condition is what keeps it safe, so test it carefully.

43. An SCP that allows S3

An account's SCP allows only s3:* and the developer's IAM role has no policies. What can the developer do in S3?

  1. A.Nothing, because SCPs limit but never grant permissions
  2. B.Everything in S3, because the SCP explicitly allows it
  3. C.Only read S3, because SCPs grant read by default
  4. D.Everything in every service except S3 itself
Show answer

Answer: A. Nothing, because SCPs limit but never grant permissions

An SCP defines the maximum available permissions in an account. Effective access still requires an identity or resource policy that allows the action. Here the role has no policies, so nothing is allowed even though S3 is within the SCP's limit.

44. Stopping service account key downloads

Your GCP security standard says no one may create downloadable service account keys. What enforces this across every project in the organization?

  1. A.The org policy iam.disableServiceAccountKeyCreation
  2. B.Removing the Owner role from every user in every project
  3. C.A VPC firewall rule blocking iam.googleapis.com
  4. D.Setting each new key's expiry to one day only
Show answer

Answer: A. The org policy iam.disableServiceAccountKeyCreation

Organization policy constraints are guardrails that apply to every project under the node where they are set, regardless of IAM roles. Disabling key creation pushes teams toward attached service accounts and Workload Identity Federation, which use short-lived tokens. Firewalls cannot block API calls made from the internet.

45. Deny with NotPrincipal

A bucket policy uses "Effect": "Deny" with "NotPrincipal" listing an admin role ARN, intending to block everyone else. Admins assuming that role are still denied. Why?

  1. A.NotPrincipal can only list AWS service principals
  2. B.Sessions use an assumed-role ARN, not the role ARN listed
  3. C.Deny statements in bucket policies never apply to roles
  4. D.The bucket needs versioning for NotPrincipal to work
Show answer

Answer: B. Sessions use an assumed-role ARN, not the role ARN listed

When someone assumes a role, the principal is arn:aws:sts::account:assumed-role/RoleName/session, so NotPrincipal must list that form too, or the deny hits them. AWS recommends instead a Deny with a condition such as aws:PrincipalArn not equal to the role ARN, which matches the role for any session.

46. MFA deny that access keys bypass

This policy is meant to block deletes without MFA. A developer using a long-term access key with no MFA still deletes objects. Why?

{
  "Effect": "Deny",
  "Action": "s3:DeleteObject",
  "Resource": "*",
  "Condition": { "Bool": { "aws:MultiFactorAuthPresent": "false" } }
}
  1. A.Deny statements are ignored for S3 object-level data actions
  2. B.Access keys always count as MFA-authenticated sessions in IAM
  3. C.Bool conditions only work in S3 bucket policies, not IAM ones
  4. D.The MFA key is missing for access keys, so the Deny skips
Show answer

Answer: D. The MFA key is missing for access keys, so the Deny skips

Requests signed with long-term access keys do not include aws:MultiFactorAuthPresent at all. With Bool, a missing key makes the condition false, so the Deny is skipped. Using BoolIfExists with "false" denies both when the key says false and when it is missing.

Ready to test yourself?

Take a 15-question IAM MCQ test with a score at the end, or practise the full IAM question bank and earn points on the leaderboard.