AWS IAM Roles interview questions
Reviewed by Mark Dickie · Last updated
12 questions on this page you can answer and see marked on the spot. Go to the first one
AWS IAM roles are identities in AWS that you can assume to obtain temporary, scoped permissions rather than long-lived access keys. For an interview on IAM role security, expect questions on trust policies, the difference between identity-based and resource-based policies, STS token lifetimes, and how permissions combine or conflict when a role is assumed. You should also be able to explain role chaining, permission boundaries, and the conditions under which a role can be assumed cross-account.
IAM roles are central to how AWS enforces least privilege at scale, so interviewers treat them as a core topic rather than an optional one. A strong answer usually names the specific API calls (AssumeRole, AssumeRoleWithWebIdentity, AssumeRoleWithSAML) and can describe what a trust policy actually grants: permission to call sts:AssumeRole, not the permissions attached to the role itself.
What does an IAM role interview typically test?
| Concept | What to know |
|---|---|
| Trust policy | A resource-based policy on the role that decides who can assume it. |
| Permissions policy | Identity-based policy attached to the role that scopes what the assumed-role session can do. |
| STS tokens | Temporary credentials with a configurable session duration (15 min to 12 hours). |
| Permission boundary | An upper limit on maximum permissions; the effective permission is the intersection of the boundary and the identity policy. |
| Role chaining | Assuming role A, then from that session assuming role B. The second session's lifetime is capped by the first. |
| Cross-account access | Requires the trusting account's role trust policy and the trusted account's identity policy to both permit the action. |
How do IAM role permissions get evaluated?
- The effective permissions of an assumed role session are the intersection of the role's identity-based permissions policy and any session policy passed at assume time, further intersected with any permission boundary attached to the role.
- A resource-based policy on the target resource (for example, an S3 bucket policy) can grant access without an explicit identity-based allow, but SCPs in an organization can block the result.
- An explicit
Denyalways wins over anyAllow, whether it comes from the trust policy, the permissions policy, a session policy, an SCP, or a permission boundary. - When a role is assumed via
AssumeRole, the trust policy is checked first; only then are the temporary credentials issued so the permissions policy can apply during the session.
What mistakes come up in IAM role security interviews?
Candidates often confuse the trust policy with the permissions policy, or assume that attaching an inline policy named AdministratorAccess to a role is the same as the managed policy of that name. Another common gap is not knowing that sts:AssumeRole permission lives on the calling identity in the trusted account, not on the role itself. Be ready to walk through a cross-account scenario step by step, naming which policy in which account must allow what.
Key facts
- Tarmac has 27 AWS interview questions on this topic, 25 of them on this page, at difficulty 1–5 of 5.
- Tarmac tracked 5,372 job postings asking for AWS in September 2026.
- Roles asking for AWS advertise a median base salary of US$172,500, across 1,891 job postings as of September 2026.
- Tarmac last reviewed these AWS interview questions on 13 October 2026.
At a glance
| Questions | 25 shown · 27 in the bank |
|---|---|
| Difficulty | 1–5 of 5 |
| Formats | Multiple choice, True / false, Short answer, Fill in the blank, Design exercise |
What you'll review
- iam roles
Practice questions
Try one before you open the answer. Pick an option and press Check; it's marked on the spot.
In AWS IAM, what is the primary purpose of an IAM role?#
Options
Show answer
An IAM role defines a set of permissions that trusted principals — IAM users, AWS services, or other AWS accounts — can temporarily assume via AWS STS instead of using long-term credentials. This is the key distinction from IAM users, who rely on permanent access keys or passwords. Roles enable secure, temporary, delegatable access across services and accounts.
An IAM role is an identity with permission policies that is not uniquely associated with any one person. Instead, a role is designed to be assumed by trusted entities — IAM users, AWS services (like EC2 or Lambda), or other AWS accounts — who receive temporary security credentials through AWS STS. This is distinct from IAM users, which rely on long-term credentials such as access keys or passwords. The option describing permanently storing access keys for an application and the option describing creating a new IAM user account with a fixed password describe characteristics of IAM users, not roles. The option describing encrypting data at rest in S3 buckets describes a KMS/S3 encryption function unrelated to IAM roles.
True or false: An AWS IAM role provides long-term access keys that are permanently stored and shared with the entity assuming the role.#
Options
Show answer
The statement is false. An IAM role does not provide long-term access keys. When an entity assumes a role, AWS STS issues temporary credentials that expire automatically, so no permanent keys are shared. Long-term access keys belong to IAM users instead.
The statement is false. IAM roles do not carry long-term access keys. When a trusted entity such as an EC2 instance, a user, or another AWS account assumes a role, AWS Security Token Service (STS) issues temporary credentials (an access key ID, secret access key, and session token) that expire automatically. This removes the need to distribute or rotate permanent keys. Long-term access keys belong to IAM users, which is one of the main differences between users and roles.
True or false: An IAM role has no long-term access keys (such as a permanent access key ID and secret access key) associated with it. Instead, it provides temporary security credentials that are generated when an eligible principal assumes the role.#
Options
Show answer
True. An IAM role has no long-term access keys. When an eligible principal assumes the role, AWS STS issues temporary security credentials that expire after a set duration, so no permanent secrets need to be managed for the role.
True. An IAM role is an identity with a permissions policy and a trust policy, but unlike an IAM user it has no long-term credentials. When a principal (an AWS service, a federated user, or another account) assumes the role, AWS STS issues temporary credentials that expire after a defined period. This is the core reason roles are the recommended mechanism for granting access to AWS resources and services without managing long-term keys.
Which AWS IAM entity is primarily designed to grant temporary, revocable permissions to a principal such as an AWS service, a federated user, or another AWS account?#
Show answer
An IAM role. A role is assumed by a principal, and AWS STS issues temporary credentials for it that expire automatically.
The correct entity is the IAM role, which is an assumable identity. Its trust policy specifies which principals may assume it, and its permissions policy defines what actions they can perform once they do. When assumed, AWS STS issues temporary credentials that expire automatically, which is what makes the access temporary and revocable. An IAM user with access keys uses long-term credentials, an IAM group is a container for managing users (not services or federated users), and an IAM policy is a permissions document rather than an identity that can be assumed.
An IAM role is primarily designed to provide which of the following?#
Options
Show answer
Temporary security credentials is what an IAM role is primarily designed to provide. Trusted principals such as IAM users, AWS services, or federated identities call AssumeRole to get short-lived credentials, so no long-lived access keys need to be stored or shared.
An IAM role is an identity with permission policies that trusted principals, such as IAM users, AWS services, or federated identities, can assume to receive temporary, automatically expiring security credentials. This avoids embedding long-lived access keys. The option describing temporary credentials obtained by assuming the role is the correct one; the access-key options describe long-lived credentials that roles are designed to replace, and the root password option describes a sign-in credential unrelated to roles.
An EC2 instance running an application needs to read objects from an S3 bucket. You want to follow the principle of least privilege and avoid placing long-lived access keys on the instance. Which approach correctly grants the instance the permissions it needs using IAM roles?#
Options
Show answer
Attach an IAM role with an S3 read permission policy to the EC2 instance via an instance profile. AWS automatically provides the instance with short-lived temporary credentials through the instance metadata service, eliminating the need for long-lived access keys on the instance. This follows least-privilege best practice and avoids the security risk of embedded credentials.
IAM roles designed for EC2 are attached through an instance profile. AWS automatically delivers short-lived credentials to the instance metadata service, so no long-lived access keys are stored on the instance. Creating an IAM user with an S3 read policy, generating access keys, and embedding them in the application configuration embeds long-lived keys, violating the requirement. Creating an IAM role and attaching it directly to the S3 bucket is invalid — roles are assumed by principals, not attached to S3 buckets. Adding a bucket policy to S3 that allows access from the EC2 instance's elastic IP address relies on an IP address, which is fragile and does not use IAM roles at all.
You are creating an IAM role that EC2 instances will assume to access an S3 bucket. Which principal should you specify in the role's trust policy so that EC2 instances in your account can assume this role? Give the principal's value as it appears in the policy.#
Show answer
ec2.amazonaws.com. In the trust policy's Principal element, you specify the EC2 service principal, which lets the EC2 service assume the role on behalf of instances launched with an instance profile that contains it.
An IAM role's trust policy is its resource-based policy, and its Principal element declares who may assume the role. For a role intended for EC2 instances, the Principal must be the EC2 service principal, ec2.amazonaws.com. The EC2 service then assumes the role on behalf of any instance launched with an instance profile that contains that role.
A user in AWS Account A needs to assume an IAM role in AWS Account B. What is the name of the resource-based policy on the role in Account B that defines who is allowed to assume it, and what IAM action must the user's identity-based policy in Account A explicitly grant on the target role's ARN?#
Show answer
The role in Account B has a trust policy, which is its resource-based policy, and it lists Account A or the specific user as a trusted Principal. The user in Account A must have an identity-based policy that grants sts:AssumeRole on the target role's ARN. Both permissions are required: the trust policy authorizes the cross-account principal, and the identity-based policy authorizes the user to call AssumeRole on that specific role ARN.
Cross-account role assumption requires authorization on both sides. The role in Account B carries a trust policy, which is its resource-based policy, whose Principal element identifies the trusted account or user. Separately, the calling identity in Account A needs an identity-based policy granting sts:AssumeRole on the target role's ARN. STS evaluates both before issuing temporary credentials.
An AWS IAM role has two policy documents: a trust policy and a permissions policy. Which statement correctly describes what each policy controls?#
Options
Show answer
The trust policy controls which principals, such as IAM users, roles, or AWS services, can call AssumeRole on the role. The permissions policy controls which actions the role's temporary session can perform once assumed. Both must allow the access for it to succeed.
The trust policy is a resource-based policy attached to the role that names the principals (IAM users, roles, accounts, or AWS services) allowed to call AssumeRole. The permissions policy is an identity-based policy that grants the temporary session permission to call AWS service APIs. The option saying the trust policy defines the session's actions and the permissions policy defines who can assume the role has the two roles reversed. The option about session duration and concurrent session limits is wrong because the trust policy does not set session duration and the permissions policy does not cap session counts. The option claiming the permissions policy has no effect on API calls is wrong because it is exactly what authorizes those calls.
True or false: when an IAM role is attached to an EC2 instance via an instance profile, the role's temporary credentials are stored on the instance's EBS root volume and remain usable after the instance is stopped or terminated.#
Options
Show answer
The statement is false: an IAM role attached to an EC2 instance through an instance profile does not store its credentials on the EBS root volume. The instance fetches short-lived credentials from the Instance Metadata Service while it runs. Those credentials expire, so they are not usable once the instance is stopped or terminated.
The statement is false. EC2 instance profiles deliver short-lived, automatically rotated role credentials through the Instance Metadata Service at runtime, not as files on the EBS root volume. Because the credentials are not persisted on disk and they expire, stopping or terminating the instance leaves nothing on the volume that remains usable, and the metadata endpoint is no longer reachable once the instance is down.
An EC2 instance is launched with an IAM role attached via an instance profile. Which mechanism provides the application running on that instance with the role's temporary AWS credentials?#
Options
Show answer
The Instance Metadata Service (IMDS), reachable at the link-local address 169.254.169.254, supplies temporary credentials for an EC2 instance profile role. The AWS SDK's default credential provider chain fetches them automatically, so no long-lived access keys need to be stored on the instance.
The Instance Metadata Service supplies the short-lived credentials for a role attached through an EC2 instance profile, served at the link-local address 169.254.169.254. The AWS SDK's default credential provider chain checks this source automatically, so applications get credentials without any long-lived keys being stored on the instance. Long-lived IAM user keys, Parameter Store secrets, and Cognito identity pools are not the delivery mechanism for an instance-profile role.
An IAM role in AWS has a trust policy and a permission policy attached. Which statement correctly describes the purpose of each?#
Options
Show answer
The trust policy determines which principals, such as accounts, users, or services, may assume an IAM role. The permission policies determine which actions and resources the temporary session credentials can access. Mixing up the two can over-grant or under-grant access.
The trust policy is a resource-based policy attached to the role. Its Principal element lists the accounts, users, or services allowed to call sts:AssumeRole to obtain temporary credentials. The permission policy is an identity-based policy attached to the role that governs what those session credentials can do. The option stating that the trust policy controls who may assume the role and the permission policy controls the actions and resources the session can access is the only accurate description. The option claiming the permission policy controls who may assume the role reverses the two purposes. The option saying both policies control who may assume the role is wrong because session duration is governed by the role's maximum session duration setting, not by the permission policy. The option saying the trust policy grants actions to the session reverses the purposes again.
An AWS account (Account A) grants a SaaS vendor (Account V) cross-account access by creating an IAM role whose trust policy allows arn:aws:iam::V:root as the Principal. The security team is concerned about the confused deputy problem: another customer of the same SaaS vendor could trick the vendor into assuming Account A's role and accessing its resources. Which change to the role's trust policy directly prevents this?#
Options
Show answer
Add a Condition with sts:ExternalId set to a unique secret value that Account A provides to the vendor. The sts:ExternalId condition is the AWS-standard mechanism for preventing the confused deputy problem in cross-account role assumption: each customer assigns a distinct External ID, so the trusted third party cannot assume one customer's role on behalf of another. Source IP, SourceAccount, and MFA do not distinguish between the third party's different customers.
The confused deputy problem occurs when a third party (the SaaS vendor) that is trusted by multiple customers can be tricked into assuming one customer's role on behalf of a different customer. The standard AWS mechanism to prevent this is the sts:ExternalId condition. Account A generates a unique, hard-to-guess External ID and requires it in the trust policy; the vendor must pass this value when calling sts:AssumeRole. Because each customer assigns a different External ID, the vendor cannot use Account A's role unless the caller supplies Account A's specific ID, preventing cross-customer confusion. aws:SourceIp is unreliable (NAT, proxies) and does not distinguish between the vendor's customers. aws:SourceAccount set to Account V only confirms the caller is from the vendor's account, which is already guaranteed by the Principal — it does nothing to separate the vendor's customers. An MFA requirement adds authentication for the vendor's human users but does not prevent a programmatic confused-deputy attack where the vendor's own automation is the deputy.
An EC2 instance in Account A (111111111111) has the IAM role AppRole attached through an instance profile. AppRole's permissions policy allows sts:AssumeRole on arn:aws:iam::222222222222:role/SharedRole. In Account B (222222222222), SharedRole has a trust policy whose Principal is arn:aws:iam::111111111111:role/AppRole, and a permissions policy that grants s3:GetObject on arn:aws:s3:::shared-bucket/*. The bucket shared-bucket is in Account B and has no bucket policy. Which statement is correct?#
Options
Show answer
Yes, the EC2 instance can read objects from shared-bucket. AppRole is allowed to assume SharedRole, SharedRole's trust policy trusts AppRole, and the resulting session carries SharedRole's s3:GetObject permission. Because the bucket and SharedRole are in the same account, no bucket policy is needed.
The instance calls sts:AssumeRole with the ARN of SharedRole. AppRole's permissions policy allows that call, and SharedRole's trust policy lists AppRole as a trusted principal, so STS returns temporary credentials for SharedRole. Those credentials carry SharedRole's permissions, which include s3:GetObject on shared-bucket/*. The session does not inherit AppRole's permissions, so the absence of S3 permissions on AppRole is irrelevant. Because shared-bucket and SharedRole are both in Account B, an identity-based permission on the principal is sufficient for same-account access, and the bucket needs no bucket policy. The option stating that a bucket policy naming AppRole is required is wrong for this reason, as is the option requiring the instance profile ARN in the trust policy, since the trust policy names the role principal.
When you create an IAM role in AWS, you attach a JSON policy document that specifies which principals (accounts, services, or users) are allowed to assume the role. This document is commonly called the _____ policy. For a principal to successfully assume the role, the policy must explicitly grant the _____ action. The set of AWS resource permissions the assumed role will hold is defined separately by one or more _____ policies attached to the role.#
Show answer
When you create an IAM role in AWS, you attach a JSON policy document that specifies which principals (accounts, services, or users) are allowed to assume the role. This document is commonly called the trust policy. For a principal to successfully assume the role, the policy must explicitly grant the sts:AssumeRole action. The set of AWS resource permissions the assumed role will hold is defined separately by one or more permissions policies attached to the role.
Every IAM role has two distinct policy layers. The trust policy (also called the assume-role policy document) controls who can obtain the role's credentials, and it must include a statement that allows the sts:AssumeRole action (or a variant such as sts:AssumeRoleWithSAML) for the intended principal. The permissions policies attached to the role control what the role can do after it is assumed, such as reading an S3 object or starting an EC2 instance. A principal without an sts:AssumeRole grant cannot use the role even if the permissions policies would allow the action, and an assumed principal gets only the permissions the role's policies grant.
You are designing the IAM architecture for a multi-account AWS environment. Account A hosts a stateless API on ECS that needs to read objects from an S3 bucket in Account B and write audit records to a DynamoDB table in Account C. The security team requires that no long-lived access keys be used, that each service gets least-privilege permissions, and that an administrator can centrally revoke the API's access to either downstream resource within minutes without touching the application's deployment. Propose the IAM role and trust-policy design that satisfies these requirements.#
Show answer
Give the ECS tasks a dedicated task role in Account A (not the execution role) and attach no access keys. In Account B, create role XAccountS3Reader whose trust policy names the specific Account A task role ARN as its principal, with a permissions policy allowing s3:GetObject only on the bucket's object ARN. In Account C, create role XAccountAuditWriter with a trust policy naming the same task role ARN and a permissions policy allowing dynamodb:PutItem only on the audit table ARN. The Account A task role's permissions policy allows sts:AssumeRole only on those two role ARNs. The application calls AssumeRole (or uses an SDK credential provider that does so) to obtain short-lived temporary credentials for each downstream role. To revoke access, an administrator removes the Account A principal from the downstream trust policy, so every new AssumeRole call fails immediately, with no application redeploy. Credentials already issued stay valid until they expire, so bound that window by requesting a short session duration (DurationSeconds, minimum 900 seconds) so the application re-assumes frequently. For an immediate cutoff of live sessions, attach an inline deny policy to the downstream role conditioned on aws:TokenIssueTime earlier than the revocation time.
The design separates three concerns: ephemeral credentials from STS AssumeRole remove long-lived keys; least privilege is enforced by scoping each cross-account role's permissions policy to a single action and exact resource ARN; and central revocation works by editing the trust policy on the downstream role, which blocks new AssumeRole calls immediately because the trust check happens at assumption time. Credentials already issued are not invalidated by a trust-policy change, so their exposure is bounded by session duration, and a token-issue-time deny is the mechanism that cuts off live sessions.
Account A (111111111111) has an IAM role CrossAccountRole whose trust policy allows sts:AssumeRole for the principal arn:aws:iam::222222222222:root. Account B (222222222222) has an IAM user alice with no managed or inline identity-based policy at all. Can alice successfully call sts:AssumeRole on CrossAccountRole? Explain why or why not, naming each condition that must hold for a cross-account AssumeRole call to succeed and which of them is met or unmet here.#
Show answer
No. For a cross-account sts:AssumeRole call to succeed, two conditions must both be met: (1) the target role's trust policy must allow the calling account's principal, which is satisfied because the trust policy permits arn:aws:iam::222222222222:root. (2) The calling IAM entity must have an identity-based policy granting sts:AssumeRole on the target role ARN. Alice has no identity-based policies at all, so there is no Allow statement for sts:AssumeRole. In AWS IAM the default decision for any action is an implicit Deny, so without an explicit Allow the call is denied. The trust policy is necessary but not sufficient: it establishes whom the role trusts, but the caller still needs its own permission to make the API call. Therefore alice cannot assume CrossAccountRole.
No, alice cannot assume the role. A cross-account sts:AssumeRole call requires both that the target role's trust policy allows the calling account's principal and that the calling IAM entity holds an identity-based policy granting sts:AssumeRole on the target role ARN. The first condition is met, since the trust policy allows arn:aws:iam::222222222222:root. The second fails, since alice has no managed or inline identity-based policies and therefore no Allow statement for sts:AssumeRole. IAM applies an implicit Deny by default, so without an explicit Allow the call is denied regardless of the trust policy. The trust policy is necessary but not sufficient: it defines whom the role trusts, while the caller still needs its own permission to invoke the API.
When you call sts:AssumeRole and pass an inline session policy via the Policy parameter, how are the session's effective permissions determined relative to the role's own assigned policies?#
Show answer
The session's effective permissions are the intersection of the role's identity-based policies and the inline session policy. The session policy can only narrow (restrict) the permissions granted by the role; it cannot expand them. If a permission is allowed by the role but denied or not allowed by the session policy, it is not granted to the session.
An inline session policy passed via the Policy parameter of AssumeRole acts as an additional filter on top of the role's identity-based policies. The effective session permissions are the intersection of the two: an action is allowed only if both the role's policies and the session policy permit it. A session policy therefore can only narrow the role's permissions and can never grant an action the role does not already allow. A reference answer should state the intersection and the narrowing-only behavior.
An IAM role named DataWorker has the following configuration:#
Options
Show answer
The resulting session has no effective S3 permissions. AWS computes effective session permissions as the intersection of the role's identity-based policy, its permissions boundary, and any session policy passed during AssumeRole. Here the boundary allows only s3:GetObject/s3:PutObject on bucketA/* while the session policy allows only s3:GetObject on bucketB/*; the two resource sets do not overlap, so the intersection is empty. Session policies and permissions boundaries are both purely restrictive — neither can expand what the other grants.
Effective session permissions are the intersection of three layers: (1) the role's identity-based policy, (2) the role's permissions boundary, and (3) any session policy passed during AssumeRole. Layer 1 grants s3:* on all resources — the broadest possible. Layer 2 (permissions boundary) narrows this to s3:GetObject and s3:PutObject on bucketA/* only. Layer 3 (session policy) allows only s3:GetObject on bucketB/*. The final intersection of layers 2 and 3 requires matching both the action AND the resource: s3:GetObject on bucketA/* does not overlap with s3:GetObject on bucketB/* (different resource ARNs), and s3:PutObject on bucketA/* has no corresponding grant in the session policy at all. The result is an empty permission set — the temporary credentials cannot perform any S3 operation. This illustrates how session policies and permissions boundaries are both purely restrictive: neither can ever expand the permissions granted by the other.
An organization (Account A) lets a third-party SaaS vendor (Account B) access specific S3 objects in Account A's bucket. The vendor serves many customers, each with its own ExternalId issued by Account A. Account A's IAM role has this trust policy:#
Show answer
Its primary purpose is to prevent the confused deputy problem. Because the vendor's IAM user holds a blanket sts:AssumeRole grant on Account A's role, nothing in the identity policy stops it from assuming the role while acting for the wrong customer. Without ExternalId, a request made on behalf of Customer X could reach Account A's resources under another customer's context, whether by mistake or by a malicious request. The condition requires each AssumeRole call to present the ExternalId that Account A issued to that specific customer. Account A's trust policy checks that value, so the assumption succeeds only when the vendor is acting for the customer who holds that token. The ExternalId does not enforce MFA, does not reduce the permissions granted by the role's permission policy, and does not stop the vendor's IAM identity from being granted sts:AssumeRole in the first place.
Without sts:ExternalId, the vendor's broadly granted sts:AssumeRole permission would let it assume Account A's role on behalf of any of its customers, which is the classic confused deputy problem. The condition forces the vendor to pass a customer-specific token that Account A validates in the trust policy, so each AssumeRole call is bound to the customer that owns that token. It does not enforce MFA (that would use the aws:MultiFactorAuthPresent condition key), it does not restrict the role's permissions (that is the permission policy's job), and it does not prevent the role ARN from being shared; it prevents one customer's requests from succeeding under another customer's context.
Which condition keys are commonly used in an IAM role trust policy to protect against the confused deputy problem when a service (e.g., an AWS service or a third-party AWS account) assumes the role? Name the keys and say which scenario each one addresses.#
Show answer
The two condition keys commonly used in a trust policy for the confused deputy problem are sts:ExternalId (for third-party / cross-account role assumption) and aws:SourceAccount combined with aws:SourceArn (for restricting which AWS account or resource ARN can trigger a service to assume the role). sts:ExternalId requires the caller to pass a pre-agreed value the trust policy must match. aws:SourceAccount and aws:SourceArn bind the role assumption to a specific source account or resource, preventing another AWS account from invoking the service in a way that causes it to assume the role for an unintended principal.
The two widely-used condition-key families for confused-deputy protection in trust policies are sts:ExternalId (for third-party / cross-account scenarios) and aws:SourceAccount/aws:SourceArn (for AWS service-to-role scenarios). sts:ExternalId is a caller-supplied token the trust policy must match, so a confused deputy cannot assume the role without the agreed value. aws:SourceAccount/aws:SourceArn bind the role assumption to the specific source account or resource that triggers the service to assume the role, so another account's resource cannot cause the service to act on its behalf.
Consider the following cross-account IAM role setup between Account A (111111111111) and Account B (222222222222). In Account A, a role named AuditRole has a trust policy with Principal: { AWS: 'arn:aws:iam::222222222222:root' }, Action: 'sts:AssumeRole', and Condition: { StringEquals: { 'sts:ExternalId': 'partner-xyz' } }. The role's permission policy grants s3:GetObject on arn:aws:s3:::logs-bucket/*. In Account B, IAM user analyst has an inline policy granting sts:AssumeRole on arn:aws:iam::111111111111:role/AuditRole. What must the analyst include in their AssumeRole API call to successfully assume AuditRole, and what is the single S3 permission the resulting role session grants? Explain why each requirement is necessary.#
Show answer
The analyst must pass ExternalId=partner-xyz as a parameter in the sts:AssumeRole call. The trust policy's StringEquals condition on sts:ExternalId requires this exact value to match, so without it AWS denies the request even though the analyst has sts:AssumeRole permission via their inline policy in Account B. Both sides are required: the Account B identity policy authorizes the call on the role ARN, and the Account A trust policy condition must also evaluate to true. The resulting session carries only the permission policy of AuditRole, which here grants s3:GetObject on arn:aws:s3:::logs-bucket/*, so the single S3 permission is reading objects in that bucket. The session cannot list the bucket or delete objects because those actions are not granted.
The trust policy in Account A delegates to Account B's root principal, so Account B's identity policies decide which users may call AssumeRole. The analyst's inline policy grants sts:AssumeRole on the role ARN, which covers the Account B side. The trust policy also carries a StringEquals condition on sts:ExternalId, so the analyst must pass ExternalId=partner-xyz explicitly in the AssumeRole call; if it is missing or wrong, the condition is false and the request is denied even though the identity permission exists. The assumed session's permissions come from AuditRole's permission policy, which grants only s3:GetObject on arn:aws:s3:::logs-bucket/*, so the session can read objects in that bucket but cannot list it or access other resources.
You are the platform security lead for a 60-account AWS Organization (control tower, ~200 developers, mixed EC2/ECS/Lambda workloads, one centralized security-audit account that scans every member account). Your CTO wants a single document governing how IAM roles are designed, assumed, and chained across accounts. Specifically, she asks you to address: (1) how cross-account trust policies are locked down so a compromised member account cannot widen access; (2) how to use permission boundaries alongside identity-based policies so a self-service developer role cannot exceed a blast-radius ceiling even if someone attaches a broad managed policy; (3) how role chaining affects session duration for the security-audit tool that hops through a hub account into every spoke; and (4) where session policies fit in the evaluation logic and what they buy you that attached policies cannot. Produce the design.#
Show answer
IAM Role Security Architecture for a 60-Account Organization
1. Cross-Account Trust Policy Hardening
Every cross-account role's trust policy is authored as a CloudFormation StackSet deployed from the security-audit account so that member-account administrators cannot silently widen trust. Each trust policy follows this pattern:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::HUB-ACCOUNT:role/AuditHubRole" },
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalId": "<unique-per-spoke-id>",
"aws:SourceAccount": "HUB-ACCOUNT"
},
"ArnLike": {
"aws:SourceArn": "arn:aws:iam::HUB-ACCOUNT:role/AuditHubRole"
}
}
}]
}
The Principal is pinned to the exact hub role ARN — never root or *. The sts:ExternalId condition prevents the confused-deputy attack: even if an attacker in the hub account can influence which role is assumed, they cannot construct a valid AssumeRole call without the spoke-specific external ID, which is stored only in Secrets Manager in the audit account. aws:SourceArn adds defense-in-depth by verifying the caller's actual ARN. An SCP at the Organization root denies iam:UpdateAssumeRolePolicy on cross-account roles for all principals except a break-glass role in the audit account, ensuring trust policies are centrally governed.
2. Permission Boundaries as Blast-Radius Ceilings
Every self-service developer role carries BOTH an identity-based policy (granting fine-grained, resource-scoped permissions) AND a permission boundary (a managed policy capping the maximum allowed actions). The evaluation logic is:
Effective permission = (identity-based policy ALLOW) ∩ (permission boundary ALLOW), minus any explicit DENY anywhere in the evaluation chain (SCP → identity policy → permission boundary → session policy → resource-based policy).
Concrete pattern: the boundary policy denies a set of dangerous services (e.g., iam:*, organizations:*, kms:CreateKey) and caps all S3 actions to buckets tagged Environment=dev. A developer may attach AdministratorAccess as an identity-based policy, but the effective permissions remain bounded by the boundary — they cannot perform any action the boundary does not also allow, and any explicit Deny in the boundary overrides the broad identity-based Allow. This means the blast radius is architecturally capped regardless of what identity-based policies accumulate on the role.
3. Role Chaining and Session Duration
The audit tool works as follows: a Lambda in the audit account assumes AuditHubRole in the hub account (Session 1), then from the hub assumes SpokeAuditRole in each spoke account (Session 2 — this is a chained session).
Key constraint: a chained STS session's DurationSeconds cannot exceed the remaining lifetime of the parent session, and AWS enforces a hard maximum of 1 hour for chained AssumeRole calls regardless of the role's MaxSessionDuration setting. Even though SpokeAuditRole may have MaxSessionDuration set to 4 hours, the audit tool will only receive a token valid for at most 1 hour (or less, if the parent session has less than 1 hour remaining).
The audit tool mitigates this by:
- Requesting the maximum feasible duration at each hop and caching tokens per spoke account with their expiry timestamps.
- Re-chaining through the hub (obtaining a fresh parent session) before the cached spoke token expires, amortizing the re-assumption cost across the fan-out.
- Using a token-vending Lambda in the audit account that refreshes all spoke tokens in parallel via Step Functions when any token crosses the 15-minute-remaining threshold.
4. Session Policies for Dynamic Scoping
Session policies are passed inline during the AssumeRole (or AssumeRoleWithWebIdentity, GetFederationToken) call as the Policy parameter. They act as an additional AND-filter: the final effective permissions are the intersection of (identity-based policy ∩ permission boundary ∩ session policy), still subject to any explicit Deny.
A session policy can ONLY narrow permissions — it can never grant an action that the role's attached policies and boundary do not already allow.
Concrete use case attached policies cannot serve: a single DataProcessingRole is assumed by hundreds of ECS tasks, each processing a different tenant's data. At assume time, the task passes a session policy that restricts S3 access to arn:aws:s3:::data-bucket/tenant-<tenant-id>/*, where <tenant-id> is injected by the task orchestrator. Without session policies, you would need a separate role per tenant (hitting role limits and creating operational overhead) or a single broad role that every task shares (violating least privilege). The session policy provides per-invocation, dynamic scoping with zero role proliferation.
This design exercise tests staff-level depth across four pillars of IAM role security: (1) trust-policy hardening with external IDs, source-ARN conditions, and SCP governance to prevent confused-deputy and trust-policy tampering; (2) the intersection semantics of permission boundaries and identity-based policies, including explicit-Deny override; (3) the practical ceiling on chained STS sessions (1-hour hard cap regardless of MaxSessionDuration) and how to architect around it; and (4) session policies as a runtime AND-filter that enables dynamic per-invocation scoping impossible with static attached policies alone. A strong answer must correctly state the evaluation order and intersection logic, must not confuse permission boundaries with SCPs or resource-based policies, and must articulate the chained-session duration constraint precisely.
Your company operates a multi-tenant SaaS platform on AWS. Each customer has its own AWS account, and your SaaS control plane (running in your AWS account) needs to assume IAM roles in each customer's account to perform read-only inventory and configuration drift checks. Some customers also want to allow your platform to take limited remediation actions (for example, updating specific S3 bucket policies or rotating specific KMS keys). You have 200+ customer accounts today and expect rapid growth. Design the IAM role delegation architecture that: (a) prevents the confused deputy problem, where one customer could trick your platform into assuming another customer's role; (b) enforces least privilege so the platform can never exceed the customer's intended scope, even if a developer accidentally over-permissions the role; (c) scopes individual sessions to only the resources needed per operation; (d) prevents indefinite credential lifetime through role chaining; and (e) provides detective controls for auditing and anomaly detection on role assumption. Address the IAM primitives involved, the evaluation logic that governs effective permissions, and the trade-offs of your approach.#
Show answer
Use a layered model for cross-account delegation. (1) Confused deputy: each customer's role trust policy requires an sts:ExternalId condition matching a unique, high-entropy, per-customer value that the platform stores in AWS Secrets Manager and passes on every AssumeRole call. Without the correct ExternalId, STS rejects the call even though the platform's account is trusted, so one tenant cannot make the platform assume another tenant's role. (2) Least-privilege guardrail: each customer role has a permissions boundary that caps the maximum actions and resources (for example, s3:GetObject on specific prefixes, kms:Decrypt on specific key ARNs). Effective permissions are the intersection of the identity-based policies and the permissions boundary; an explicit deny in either, or an implicit deny (no allow in both), blocks the action. An accidental over-permission in the identity policy therefore cannot exceed the boundary, and customers can further restrict the identity policy without loosening the boundary. (3) Session scoping: each AssumeRole call passes an inline session policy or managed session policy ARN that narrows the session to the resources needed for that operation. Session policies can only reduce permissions, so read-only inventory sessions and remediation sessions can use the same role with different scopes. Effective permissions for a session are identity policy AND permissions boundary AND session policy, with any deny winning. (4) Duration and chaining: set MaxSessionDuration to the shortest operationally viable value (1 hour is typical) and keep credentials short-lived. When a role is assumed using credentials from another assumed role (role chaining), the session is capped at 1 hour and cannot be extended, so a chain cannot create long-lived credentials. The control plane's own credentials are rotated automatically, and sts:SourceIdentity can be set on the assumption so the originating caller identity is carried through the session and recorded in CloudTrail. (5) Detective controls: log all STS and CloudTrail events, including userIdentity.sessionContext, sourceIdentity, source account and IP, and whether a session policy was used. Stream CloudTrail to S3 and CloudWatch Logs, and alert on repeated failed AssumeRole calls (ExternalId guessing), assumptions from unexpected accounts or IPs, and unusual session volume. At scale, deploy the role, trust policy, and boundary to every account with a CloudFormation StackSet across the organization, and run an orchestrator that retrieves each account's ExternalId and performs the AssumeRole calls. Trade-offs: boundaries and session policies add policy complexity and must be tested, short sessions require the orchestrator to re-assume roles often, and per-customer ExternalIds add secret-management overhead in exchange for strong tenant isolation.
This is an open design question, so it is graded as a short answer against the expected keywords and the sample answer. The sample answer covers each required part: ExternalId in the trust policy blocks confused-deputy attacks, a permissions boundary intersects with identity policies to cap accidental over-permissions, session policies narrow each session without creating new roles, and role chaining is capped at one hour so it cannot yield indefinite credentials. Detective controls use CloudTrail session context and source identity, and scale is handled through StackSets and an orchestrator. The effective-permission rule (identity policy AND boundary AND session policy, with any explicit deny winning) is stated explicitly, as the question requires.
Account A defines an IAM role CrossAccountRole with a trust policy that allows sts:AssumeRole from principal arn:aws:iam::AccountB:root (no other conditions). The role's attached permission policy grants s3:GetObject on arn:aws:s3:::shared-bucket/* and nothing else. An EC2 instance in Account B runs under an instance profile whose IAM role has NO identity-based permission for sts:AssumeRole on CrossAccountRole. Account B is not a member of any AWS Organization and no SCPs apply. Can the EC2 instance in Account B successfully call sts:AssumeRole on CrossAccountRole? Explain why or why not, and state what permissions a resulting session would carry if the call succeeded.#
Show answer
No, the call is denied. Cross-account role assumption needs two independent grants: the role's trust policy in Account A must name the caller's principal (here, Account B), and the caller's own identity-based policy in Account B must allow sts:AssumeRole on the role's ARN. The trust policy names Account B, but the instance profile role has no identity-based sts:AssumeRole allow, so the request is denied because the caller's side is missing. Adding that allow in Account B's policies would make the call succeed. If it succeeded, the session would carry only the role's attached permission policy, which is s3:GetObject on arn:aws:s3:::shared-bucket/*; it would not inherit the instance profile role's Account B permissions, and the session's permissions are not a union of the caller's and the role's policies.
Cross-account AssumeRole is allowed only when both sides permit it: the target role's trust policy (resource-based, in Account A) must trust the caller, and the caller's identity-based policy (in Account B) must grant sts:AssumeRole on the role's ARN. Here the trust policy trusts Account B, but the instance profile role has no identity-based sts:AssumeRole grant, so the call is denied. No SCPs or other conditions apply, so this missing grant is the only blocker. If the call had succeeded, the temporary credentials would carry only the role's attached permissions (s3:GetObject on arn:aws:s3:::shared-bucket/*), not the caller's Account B permissions, since assumed-role sessions take the role's permissions rather than a combination of both policy sets.
Related interview questions
Job market
See aws salaries and hiring demand from live job postings.
The other 2 questions
This page shows 25 and marks what you pick. That's as far as a page can go. A free account opens the other 2 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.
Free · the whole bank · 100 marked answers per 30 days · written feedback on the paid plan