06 IAM - gannurohith/devops-interview-wiki GitHub Wiki
📁 06 - IAM (Identity and Access Management) (Basic to Intermediate Q&A)
-
What is IAM in AWS? Identity and Access Management allows you to manage users, groups, roles, and policies to securely control access to AWS resources.
-
What are IAM users? Individual accounts with credentials (username/password and access keys) to access AWS resources.
-
What are IAM groups? A collection of users with the same permissions via policies attached to the group.
-
What are IAM roles? Roles provide temporary credentials to entities like EC2, Lambda, or federated users.
-
What is the difference between an IAM user and a role?
- User: Long-term credentials.
- Role: Temporary, assume-able credentials.
-
What are IAM policies? JSON documents that define permissions (Allow/Deny) for actions on AWS resources.
-
How are IAM policies attached? To users, groups, or roles.
-
What is the difference between managed and inline policies?
- Managed: Reusable, AWS or customer-managed.
- Inline: One-to-one attached directly to a single user/group/role.
-
What are AWS managed policies? Predefined policies created and maintained by AWS (e.g.,
AmazonS3ReadOnlyAccess
). -
What is an IAM trust policy? Defines which entities (users, services) can assume a role.
-
How do you assume an IAM role? Via AWS CLI (
sts assume-role
), console switch role, or AWS SDKs. -
What is the principle of least privilege? Users should be granted only the permissions necessary to perform their job.
-
What are IAM access keys? Used for programmatic access (CLI, SDKs); consists of an Access Key ID and Secret Access Key.
-
How do you rotate IAM access keys securely? Create a new key, test it, then disable/delete the old one.
-
What is IAM identity federation? Grants temporary access to AWS resources via external identity providers (AD, SAML, Google, etc.).
-
What is AWS STS? Security Token Service provides temporary security credentials for IAM roles.
-
How do you audit IAM activity? Use CloudTrail, IAM Access Analyzer, and Credential Reports.
-
What are service-linked roles? IAM roles linked to specific AWS services for them to perform actions on your behalf.
-
What is a resource-based policy? Policies attached directly to resources like S3 buckets or Lambda functions.
-
What is a permissions boundary? An advanced feature to set the maximum permissions an IAM role or user can have.
-
How can you restrict a user to a specific S3 bucket only? Attach a policy allowing only actions on that bucket using ARN condition.
-
Can IAM policies deny access explicitly? Yes, using
"Effect": "Deny"
. Explicit deny always overrides allow. -
How do you enforce MFA in IAM? Attach an IAM policy with condition:
"aws:MultiFactorAuthPresent": true
-
What is IAM policy versioning? Policies can have multiple versions but only one active at a time (up to 5 versions).
-
What is an IAM credential report? CSV file listing all IAM users and the status of their credentials.
-
What is IAM Access Analyzer? Tool that finds unintended public or cross-account access to your resources.
-
Can IAM roles be assumed across accounts? Yes, using trust policies that allow roles from another account to assume them.
-
What tools help manage IAM permissions visually?
- IAM Policy Simulator
- AWS Access Analyzer
- IAM console policy editor
-
How do you restrict IAM access by IP address? Add a condition in the policy:
"aws:SourceIp": "203.0.113.0/24"
-
What are the IAM best practices?
- Use roles, not users, for applications
- Enable MFA
- Rotate keys regularly
- Apply least privilege principle
- Audit with CloudTrail and Access Analyzer
07. IAM – Identity and Access Management (Q&A)
-
What is IAM in AWS? Answer: IAM is AWS's security service to manage users, groups, roles, and policies for controlling access to AWS resources.
-
What’s the difference between IAM user and IAM role? Answer: IAM user is for a specific person; IAM role is assumed temporarily by users/services and used for cross-account or service-level access.
-
What is a policy in IAM and what types exist? Answer: A policy defines permissions in JSON. Types: identity-based, resource-based, SCPs (for Org), ACLs (for S3), and session policies.
-
How does IAM help in achieving least privilege? Answer: By assigning only required permissions via scoped policies and regularly reviewing roles, adhering to security best practices.
-
How do you allow read-only access to S3 for a group of users? Answer: Attach an AWS managed or custom read-only S3 policy to the IAM group.
-
What is an IAM inline policy? When should it be used? Answer: Inline policies are embedded directly into a user, group, or role. Use for tightly coupled permissions.
-
What is the IAM policy evaluation logic? Answer: Explicit Deny > Allow > Default Deny. If any explicit deny matches, access is denied regardless of allows.
-
How do you grant temporary access using IAM? Answer: Use IAM roles with STS (e.g.,
AssumeRole
) to grant time-limited, scoped access. -
How can you delegate access to IAM users from another AWS account? Answer: Use role assumption with
trust policy
allowing the external account to assume the role. -
How do IAM permissions differ from resource policies (e.g., in S3)? Answer: IAM permissions are identity-based; resource policies are attached to the resource and can allow cross-account access.
-
What is a service-linked role? Answer: A pre-defined IAM role linked to an AWS service for managing it securely. Created automatically or manually as needed.
-
What is an access key and how is it used? Answer: Access key = Key ID + Secret. Used for CLI/SDK access. Should be rotated regularly and never hardcoded.
-
How do you audit IAM usage and permissions? Answer: Use IAM Access Analyzer, CloudTrail for API activity, and IAM Credential Reports.
-
How can you restrict an IAM user from deleting resources? Answer: Use deny actions in the policy for delete operations (e.g.,
"ec2:TerminateInstances"
), or create scoped permissions. -
What is a permission boundary in IAM? Answer: It’s a managed policy that acts as the maximum permissions a user/role can get—even if their policies allow more.
-
Explain how IAM integrates with EC2. Answer: IAM roles can be attached to EC2 instances to allow access to AWS services (e.g., S3, CloudWatch) without using credentials.
-
What is the difference between
AssumeRole
andSwitchRole
? Answer:AssumeRole
is an API call used programmatically;SwitchRole
is for UI-based role switching between accounts. -
How do you restrict access to AWS Console only (no CLI)? Answer: Don’t generate access keys, or use a policy denying API access (
Deny
on"*"
with"NotAction": ["aws-portal:ViewBilling"]
, etc.). -
How do you monitor unauthorized access attempts? Answer: Enable CloudTrail logs and configure GuardDuty or CloudWatch alarms to detect unusual activity.
-
Can IAM users be assigned to multiple groups? Answer: Yes. A user can belong to multiple IAM groups and inherits permissions from all.
-
What’s the maximum policy size in IAM? Answer: 6,144 characters per policy document (individual), up to 10 managed policies per user/role.
-
What are the IAM best practices? Answer: Enable MFA, use roles over users, follow least privilege, avoid root usage, rotate credentials, use IAM Access Analyzer.
-
How do you enforce MFA for a user or group? Answer: Use a condition in the policy:
"Condition": { "BoolIfExists": { "aws:MultiFactorAuthPresent": "true" } }
-
What is the IAM Credential Report? Answer: A downloadable report showing password age, key rotation, MFA status for all users in the account.
-
What is AWS Organizations and how does IAM relate to it? Answer: Organizations manages multiple accounts centrally. IAM works at account level; Org policies (SCPs) control max permissions across accounts.