Ravindra BagaleCourses & study guides Track your progress

AWS Cloud

AWS IAM and Security Interview Questions and Answers (50 Questions for Freshers to Senior)

This page has 50 new AWS IAM and security interview questions with full answers. They start with fresher basics and end with senior design and troubleshooting scenarios. Every answer uses easy English, made-up example values, and the account ID 111122223333 only as a sample.

1. An everyday example: the office building with ID cards

In almost every AWS interview, the first technical round starts with IAM. A wrong IAM answer tells the interviewer that you may give too much access in a real project. That is a big risk for any company.

Think of a big office building. The building owner has a master key. That is the root user. Staff get ID cards with only the floors they need. Those are IAM users and groups with policies. A visitor gets a temporary pass that stops working in the evening. That is an IAM role with temporary STS credentials. The security guard checks every card at every door. That is the IAM policy evaluation that runs on every API call.

How to use this page

  • First read the question and answer it aloud in about 60 seconds.
  • Then open the answer and compare. Note what you missed.
  • Run the safe read-only commands in your own practice account.
  • Revise the senior scenarios one day before the interview.

2. Fresher level questions

Start here if you are a fresher or have less than two years of experience. Try to answer each question aloud first. Then open it and compare.

Q1. What is the difference between authentication and authorization in AWS? Fresher

Authentication answers the question "Who are you?". Authorization answers "What are you allowed to do?".

Everyday example: at an airport, showing your passport is authentication. The boarding pass that lets you into one gate only is authorization.

In AWS, you authenticate with a password and MFA in the console, or with access keys or temporary credentials for the CLI and SDK. After that, IAM checks your policies on every API call to decide if the action is allowed. Both steps must pass. A valid login with no policy still gives you "AccessDenied".

Q2. What is an IAM principal? Fresher

A principal is any identity that can make a request to AWS.

It can be the root user, an IAM user, an IAM role session, a federated user, or an AWS service such as lambda.amazonaws.com.

You see the word "Principal" mainly in resource-based policies and in role trust policies. There it tells AWS who is allowed to use the resource or assume the role. For example, a trust policy with "Principal": {"Service": "ec2.amazonaws.com"} lets EC2 instances assume that role.

Q3. Why should you not use the root user for daily work? Fresher

The root user has full control of the account and you cannot limit it with IAM policies.

If someone steals the root password, they can close the account, change billing and delete everything.

Best practice is simple. Turn on MFA for root. Do not create access keys for root. Use root only for the few tasks that need it, such as changing the account support plan or closing the account. Do daily work with IAM Identity Center users or roles that have only the permissions they need.

Q4. Why does AWS recommend IAM roles instead of IAM users with long-term keys? Fresher

An IAM user is a long-term identity for one person or application. It can have a password and long-term access keys.

An IAM role has no password and no long-term keys. Anyone who is trusted can assume it and gets temporary credentials that expire.

Everyday example: a user is like a permanent employee ID card. A role is like a visitor badge that you return at the end of the day.

Today, AWS recommends roles and IAM Identity Center for people, and roles for applications on EC2, Lambda and containers.

Q5. What is an IAM group and can a group be used in a policy Principal? Fresher

An IAM group is a collection of IAM users. You attach policies to the group, and every user in it gets those permissions. This makes access easy to manage. For example, put all developers in a "Developers" group.

A group is not an identity. It cannot sign in and it cannot be named as a Principal in a resource-based policy or trust policy. You also cannot put a group inside another group.

Q6. What are the main parts of an IAM policy statement? Fresher

A policy statement usually has these parts:

  • Effect: Allow or Deny.
  • Action: the API actions, such as s3:GetObject.
  • Resource: the ARN the action applies to.
  • Condition: optional extra checks, such as MFA or source IP.
  • Principal: only in resource-based and trust policies.

Example: "Allow s3:GetObject on arn:aws:s3:::demo-reports-bucket/* only if MFA is present." Reading a policy in this order makes it easy to explain in an interview.

Q7. What is an ARN and how do you read it? Fresher

ARN means Amazon Resource Name. It is a unique ID for a resource in AWS.

The common format is arn:partition:service:region:account-id:resource.

Example: arn:aws:iam::111122223333:role/AppReadOnly. Partition is aws, service is iam, region is empty because IAM is global, the account is 111122223333 and the resource is the role named AppReadOnly.

Some ARNs leave parts empty. An S3 bucket ARN such as arn:aws:s3:::demo-reports-bucket has no region and no account.

Q8. Why do most teams prefer customer managed policies over AWS managed and inline policies? Fresher

An AWS managed policy is created and updated by AWS, for example ReadOnlyAccess. It is easy but often wider than you need.

A customer managed policy is created by you. You can reuse it on many users, groups and roles, and it keeps versions so you can roll back.

An inline policy is written directly inside one user, group or role. It is deleted when that identity is deleted.

Most teams prefer customer managed policies because they are reusable, reviewable and least-privilege.

Q9. What is MFA and which MFA types does AWS support? Fresher

MFA means multi-factor authentication. You prove who you are with something you know, like a password, plus something you have, like a phone or a security key.

Everyday example: an ATM needs your card and your PIN.

AWS supports passkeys and FIDO security keys, virtual authenticator apps, and hardware TOTP tokens. Turn on MFA for the root user and for every person who signs in. You can also require MFA in policies with the condition key aws:MultiFactorAuthPresent.

Q10. How do you apply the principle of least privilege to an AWS IAM role in practice? Fresher

Least privilege means giving only the permissions needed to do a task, and nothing more.

Why: if a key or role is misused, the damage stays small.

How: start with no access. Add only the actions and resources the job needs. Use conditions where useful. Review unused permissions with IAM last-accessed data and IAM Access Analyzer, and remove them.

Example: a reporting app needs only s3:GetObject on one bucket, not s3:* on all buckets.

Q11. How do you see who you are logged in as from the AWS CLI? Fresher

Run the STS get-caller-identity command. It works even with no IAM permissions, so it is the first check in any access problem.

aws sts get-caller-identity

Output:

{
    "UserId": "AROAEXAMPLEID:dev-session",
    "Account": "111122223333",
    "Arn": "arn:aws:sts::111122223333:assumed-role/DevReadOnly/dev-session"
}

You are using the role DevReadOnly in account 111122223333 with a session named dev-session. If the account or role is not what you expected, fix your profile before you debug policies.

Q12. What is AWS IAM Identity Center? Fresher

IAM Identity Center is the recommended way to give people access to many AWS accounts.

Why: creating separate IAM users in every account is hard to manage and leaves long-term passwords and keys.

What: you connect a workforce identity source, such as the built-in directory, Microsoft Entra ID or Okta. Then you create permission sets and assign them to users or groups for chosen accounts.

How it works for the user: they sign in once to the access portal, pick an account and a role, and get temporary credentials for the console or CLI.

Q13. What is the difference between an identity-based policy and a resource-based policy? Fresher

An identity-based policy is attached to a user, group or role. It says what that identity can do.

A resource-based policy is attached to the resource itself, such as an S3 bucket policy, an SQS queue policy or a KMS key policy. It says who can use this resource, so it has a Principal element.

Resource-based policies are very useful for cross-account access, because the resource owner can allow another account directly.

Q14. What is AWS KMS used for? Fresher

AWS KMS (Key Management Service) creates and controls encryption keys.

Everyday example: a bank locker. The bank keeps the master key safe, and you decide who may open your locker.

Services like S3, EBS, RDS and DynamoDB call KMS to encrypt your data. KMS keys never leave KMS unencrypted. Every use of a key is logged in CloudTrail, and key policies decide who can use or manage the key.

Q15. How do you decide whether a value belongs in Secrets Manager or in SSM Parameter Store? Fresher

Both store configuration and secrets.

Secrets Manager is built for secrets like database passwords and API tokens. It supports automatic rotation, cross-Region replication of secrets, and has a per-secret monthly charge.

Parameter Store stores configuration and secrets as plain String or encrypted SecureString parameters. Standard parameters have no extra storage charge. It has no built-in rotation.

Simple rule: use Secrets Manager for credentials that must rotate, and Parameter Store for app settings and simple values.

Q16. What does Amazon GuardDuty do? Fresher

GuardDuty is a threat detection service. You turn it on, and it watches data sources such as CloudTrail events, VPC Flow Logs and DNS logs.

It uses threat intelligence and machine learning to raise findings. Examples: an EC2 instance talking to a known bad IP, crypto-mining behaviour, or API calls from an unusual location.

GuardDuty does not block traffic by itself. You send findings to EventBridge and then to email, a ticket or an automatic response such as isolating the instance.

Q17. What is the difference between AWS WAF and AWS Shield? Fresher

AWS WAF is a web application firewall. It filters HTTP and HTTPS requests on CloudFront, Application Load Balancer, API Gateway and some other services. You write rules for SQL injection, bad bots, rate limits or blocked countries.

AWS Shield protects against DDoS attacks. Shield Standard is on automatically for all customers at no extra cost and protects against common network and transport layer attacks. Shield Advanced is a paid service with extra protection, response team support and cost protection.

3. Mid level questions

These questions check how you use the service in real projects. Interviewers expect the why, the how and one real example.

Q18. How does AWS evaluate a request when there are many policies? Mid level

AWS follows a fixed logic.

  • Step 1: By default, everything is denied.
  • Step 2: If any applicable policy has an explicit Deny, the request is denied. Deny always wins.
  • Step 3: Limits are checked: SCPs, RCPs, permission boundaries and session policies. The action must be allowed by each of them that applies.
  • Step 4: An identity-based or resource-based policy must Allow the action.

Everyday example: you need the manager's approval and you must not be on the blocked list. If you are on the blocked list, no approval helps.

Q19. How does a permission boundary stop privilege escalation when developers create their own roles? Mid level

A permission boundary is a managed policy that sets the maximum permissions a user or role can ever have. It does not grant anything by itself.

The effective permission is the overlap of the identity policy and the boundary.

Real use: you let developers create their own IAM roles for Lambda. You require that every new role must carry the boundary "DevBoundary". Then even if a developer attaches AdministratorAccess, the role can only do what the boundary allows. This stops privilege escalation.

Q20. What is a Service Control Policy (SCP)? Mid level

An SCP is a policy in AWS Organizations. It sets the maximum permissions for IAM users and roles in member accounts of an organization or OU.

SCPs never grant access. A user still needs an IAM Allow.

Common uses: deny actions outside approved Regions, deny turning off CloudTrail or GuardDuty, and deny leaving the organization.

Note: SCPs do not affect the management account, and they do not limit service-linked roles.

Q21. What is the difference between an SCP and a resource control policy (RCP)? Mid level

Both live in AWS Organizations and both only set limits.

An SCP limits what your principals (users and roles in your accounts) can do.

An RCP limits what can be done to your resources, such as S3 buckets or KMS keys, no matter who is calling.

Example: an RCP can say that S3 buckets in your organization can only be accessed by principals from your own organization. That helps stop accidental sharing with outside accounts, even if a bucket policy is too open.

Q22. How does cross-account access with an IAM role work? Mid level

There are two sides.

  • In account B (the owner), create a role. Its trust policy allows account A, for example arn:aws:iam::111122223333:root. Attach a permission policy with what the role may do.
  • In account A, give the user or role permission for sts:AssumeRole on that role ARN.

Then the person in account A calls AssumeRole and receives temporary credentials for account B.

aws sts assume-role --role-arn arn:aws:iam::444455556666:role/AuditReadOnly --role-session-name audit-check

The output has AccessKeyId, SecretAccessKey, SessionToken and Expiration. These keys work only until the expiry time.

Q23. What is the confused deputy problem and how does ExternalId help? Mid level

A confused deputy is a trusted service that is tricked into acting for the wrong customer.

Example: a third-party monitoring company assumes roles in many customer accounts. If customer X can guess customer Y's role ARN, X might make the company read Y's data.

Fix: the vendor gives each customer a unique ExternalId. The customer's trust policy requires sts:ExternalId to match. The vendor always sends the correct ExternalId for each customer, so it cannot be tricked. For AWS services, use aws:SourceArn and aws:SourceAccount conditions for the same reason.

Q24. What does iam:PassRole mean and why is it risky? Mid level

iam:PassRole lets a user give an IAM role to an AWS service, for example attaching a role to an EC2 instance or a Lambda function.

It is risky because a user could pass a powerful role, such as an admin role, to a resource they control. Then they act with that role's power. This is privilege escalation.

Safe practice: allow PassRole only for specific role ARNs, and add the condition iam:PassedToService so the role can be passed only to the intended service, such as lambda.amazonaws.com.

Q25. How long can temporary credentials from AssumeRole last? Mid level

By default, AssumeRole credentials last 1 hour.

You can ask for 15 minutes up to the role's maximum session duration. The role owner can set that maximum from 1 hour up to 12 hours.

There is one important exception. When you use one role to assume another role (role chaining), the session is limited to 1 hour at most.

Interview tip: also say that short sessions reduce damage if credentials leak.

Q26. What is ABAC and how is it different from RBAC? Mid level

RBAC (role-based access control) gives access by job role. You create a policy for each role, and you update policies when new resources come.

ABAC (attribute-based access control) gives access by tags. Example: allow EC2 stop and start only when the instance tag Project matches the user's tag Project, using aws:ResourceTag/Project and aws:PrincipalTag/Project.

ABAC scales well. When a new project starts, you only tag people and resources. You do not write new policies. The risk is tag control, so you must also restrict who can change tags.

Q27. How do you find and remove unused IAM permissions? Mid level

Use these tools:

  • IAM last-accessed information shows when each service was last used by a user or role.
  • IAM Access Analyzer unused access findings list unused roles, keys, passwords and permissions.
  • Access Analyzer policy generation can build a least-privilege policy from CloudTrail activity.
  • The credential report lists all users with password and key age.

Then remove unused permissions in small steps, test, and keep the change in version control.

Q28. What does IAM Access Analyzer find with external access analysis? Mid level

It finds resources that are shared outside your zone of trust. The zone of trust is your account or your whole organization.

It checks resource-based policies on S3 buckets, IAM role trust policies, KMS keys, Lambda functions, SQS queues, Secrets Manager secrets and more.

Example finding: "Bucket demo-reports-bucket allows read access from account 444455556666." You then decide if this is intended. If it is, archive the finding. If not, fix the policy.

Q29. What is the difference between AWS owned, AWS managed and customer managed KMS keys? Mid level

AWS owned keys are used by AWS services inside their own accounts. You cannot see or manage them, and there is no extra charge.

AWS managed keys are created in your account by a service, with names like aws/s3. You can see them, but you cannot change their policy or rotation.

Customer managed keys are created by you. You control the key policy, grants, rotation, aliases and deletion.

Use customer managed keys when you need cross-account use, custom access control or full audit control.

Q30. Why does KMS use envelope encryption for large data, and how does it work step by step? Mid level

Envelope encryption means you encrypt data with a data key, and then encrypt that data key with a KMS key.

Why: KMS Encrypt works directly only on small data, up to 4 KB. Large files need local encryption.

How: the app calls GenerateDataKey. KMS returns a plain data key and an encrypted copy. The app encrypts the file with the plain key, deletes the plain key from memory, and stores the encrypted key next to the file. To decrypt, it sends the encrypted key to KMS to get the plain key back.

Everyday example: you lock a box with a small key and keep that small key inside a bank locker.

Q31. What happens when you schedule a KMS key for deletion? Mid level

KMS does not delete the key at once. You choose a waiting period from 7 to 30 days. The default is 30 days.

During that time the key is in "Pending deletion" state and cannot be used. You can cancel the deletion.

After deletion, any data encrypted with that key can never be decrypted again.

Safe practice: first disable the key and watch CloudTrail and CloudWatch for failed calls. Use a CloudWatch alarm for any attempt to use a key that is pending deletion.

Q32. How do you rotate a database password stored in Secrets Manager? Mid level

Turn on rotation for the secret and choose a schedule, such as every 30 days.

For RDS and Aurora, Secrets Manager provides managed rotation or ready-made rotation Lambda functions. The rotation creates a new password, sets it in the database, tests it, and then marks it as the current version.

The app must read the secret from Secrets Manager at runtime and cache it for a short time. It must not hard-code the password. The alternating-users strategy can avoid failed logins during the switch.

Q33. How do you require MFA for sensitive actions in a policy? Mid level

Add a condition that checks the MFA flag. A common pattern is a Deny statement that blocks sensitive actions when MFA is not present.

Example idea: Deny ec2:TerminateInstances with condition BoolIfExists aws:MultiFactorAuthPresent = false.

Use BoolIfExists so requests that do not carry the key, such as long-term access key calls, are also denied.

Also remember that people who sign in through IAM Identity Center handle MFA at sign-in.

Q34. How do you securely give an EC2 application access to S3? Mid level

Do not store access keys on the server.

  • Create an IAM role with a trust policy for ec2.amazonaws.com.
  • Attach a least-privilege policy, such as s3:GetObject on one bucket path.
  • Attach the role to the instance through an instance profile.

The SDK on the instance gets temporary credentials from the instance metadata service and refreshes them automatically.

Also require IMDSv2 on the instance, so the metadata service needs a session token. This blocks many SSRF attacks.

Q35. What is the difference between IMDSv1 and IMDSv2? Mid level

Both give an EC2 instance information about itself, including temporary role credentials.

IMDSv1 uses a simple GET request. If a web app has an SSRF bug, an attacker may trick it into reading credentials.

IMDSv2 first needs a PUT request to get a session token, then sends the token with each request. This blocks most SSRF attacks.

TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/iam/security-credentials/

Output:

AppS3ReadRole

The instance has the role AppS3ReadRole. Set HttpTokens to required so only IMDSv2 works.

4. Senior level and scenario questions

These questions check design thinking and troubleshooting. Think aloud. Say what you check first, what you change, and how you prevent it next time.

Q36. An access key was pushed to a public GitHub repository. What do you do? Senior

Act in minutes, not hours.

  • Step 1: Deactivate the key immediately, then delete it after you confirm nothing important uses it.
  • Step 2: Check CloudTrail for every call made with that access key ID. Look for new users, new keys, new roles, EC2 launches in strange Regions and changes to logging.
  • Step 3: Remove anything the attacker created and revoke active role sessions they may have started.
  • Step 4: Rotate other secrets that were in the same repository.
  • Step 5: Clean the Git history and check AWS Health and any AWS Support case.

Prevention: use roles and IAM Identity Center instead of long-term keys, and add secret scanning to the pipeline.

Q37. A developer gets AccessDenied even though his IAM policy allows the action. How do you troubleshoot? Senior

Remember that an Allow is not enough. Check each layer in order.

  • Who is calling? Run aws sts get-caller-identity.
  • Read the full error. Many services now say which policy type denied the call, such as an SCP or a permission boundary.
  • Check for an explicit Deny in any policy.
  • Check SCPs and RCPs on the account and OU.
  • Check the permission boundary and any session policy.
  • Check the resource policy, such as the bucket policy or KMS key policy.
  • Check conditions like Region, MFA, source IP or VPC endpoint.

Use the IAM policy simulator and CloudTrail errorCode to confirm the cause.

Q38. How would you design IAM for a company with 50 AWS accounts? Senior

Use AWS Organizations with OUs such as Security, Infrastructure, Workloads-Prod, Workloads-NonProd and Sandbox.

  • People sign in through IAM Identity Center connected to the company directory. Access is given with permission sets by group, for example Developers-ReadOnly in prod and Developers-PowerUser in dev.
  • No IAM users with long-term keys, except rare documented exceptions.
  • SCPs block risky actions, such as disabling CloudTrail, leaving the organization or using unapproved Regions.
  • An organization trail sends CloudTrail logs to a locked log archive account.
  • GuardDuty, Security Hub and Access Analyzer are managed from a delegated security account.
  • Break-glass access is protected with strong MFA and alerts on every use.
Q39. How do you let a third-party vendor access only one S3 folder in your account safely? Senior

Give access through a role, not through a shared user.

  • Create a role in your account. The trust policy allows only the vendor's account and requires an ExternalId that you agreed with them.
  • The permission policy allows only the needed actions on one prefix, for example s3:GetObject and s3:PutObject on arn:aws:s3:::partner-share-bucket/vendor-a/*, and s3:ListBucket with a prefix condition.
  • If the bucket uses a customer managed KMS key, also allow the role in the key policy.
  • Set a short maximum session duration and watch CloudTrail data events for that prefix.
  • Review and remove the access when the contract ends.
Q40. How do you prevent developers from creating IAM roles that are more powerful than themselves? Senior

Use permission boundaries together with conditions.

  • Allow iam:CreateRole only if the condition iam:PermissionsBoundary equals your DevBoundary policy ARN.
  • Allow attaching policies to roles only when that boundary is present.
  • Deny changing or deleting the boundary policy itself.
  • Allow iam:PassRole only for roles under a path such as /app/ and only to approved services.
  • Optionally force a role name prefix, such as app-*.

Result: developers can move fast and create roles for Lambda or ECS, but no role can ever go beyond the boundary.

Q41. How would you detect and respond automatically when someone disables CloudTrail? Senior

First prevent it. Use an SCP that denies cloudtrail:StopLogging, DeleteTrail and UpdateTrail for everyone except a protected admin role. Use an organization trail that member accounts cannot change.

Then detect it. Create an EventBridge rule that matches CloudTrail API calls with eventName StopLogging or DeleteTrail. Send the event to SNS for the security team, and to a Lambda function that turns logging on again.

Also use AWS Config managed rules to check that CloudTrail is enabled, and Security Hub to show the finding in one place.

Q42. An attacker obtained temporary credentials from a role. How do you revoke them? Senior

Temporary credentials cannot be deleted one by one, and they stay valid until they expire.

In the IAM console you can choose "Revoke active sessions" on the role. AWS adds an inline policy that denies all actions for sessions issued before the current time, using the condition key aws:TokenIssueTime.

Then find out how they got the credentials. For example, check for an SSRF bug on an EC2 instance using IMDSv1, a leaked CI token or a too-open trust policy. Fix that cause, or the attacker can simply get new credentials.

Q43. How do you share an encrypted EBS snapshot or AMI with another account? Senior

Snapshots encrypted with the default AWS managed key (aws/ebs) cannot be shared, because you cannot change that key's policy.

Steps:

  • Copy the snapshot and re-encrypt it with a customer managed KMS key.
  • In the key policy, allow the target account to use the key, for example kms:Decrypt, kms:DescribeKey, kms:CreateGrant and kms:ReEncrypt*.
  • Share the snapshot or AMI with the target account ID.
  • In the target account, copy it and re-encrypt it with their own key, so they do not depend on your key later.
Q44. How do you make sure an S3 bucket can never be made public, even by an admin by mistake? Senior

Use several layers.

  • Turn on S3 Block Public Access at the account level, and keep it on for every bucket.
  • Use an SCP that denies s3:PutAccountPublicAccessBlock and s3:PutBucketPublicAccessBlock changes for everyone except a security role.
  • Keep Object Ownership as "Bucket owner enforced", which turns off ACLs.
  • Use IAM Access Analyzer and AWS Config rules to alert on any public or cross-account access.
  • For websites, serve content through CloudFront with Origin Access Control, so the bucket itself stays private.
Q45. What is the difference between a KMS key policy and an IAM policy for KMS access? Senior

Every KMS key must have a key policy. The key policy is the main control.

An IAM policy can give KMS access only if the key policy allows it. Most default key policies have a statement that trusts the account, like Principal arn:aws:iam::111122223333:root. That statement lets IAM policies in the same account work.

If you remove that statement, IAM policies alone stop working for that key. For cross-account use, both the key policy in the owner account and an IAM policy in the other account must allow the action.

Grants are a third way, often used by AWS services for short-term key use.

Q46. How do you protect a production account from a stolen developer laptop? Senior

Think in layers.

  • No long-term access keys on laptops. Use IAM Identity Center with short CLI sessions.
  • Strong MFA, preferably phishing-resistant passkeys or security keys.
  • Developers get read-only in production. Changes go only through the CI/CD pipeline role.
  • Conditions such as aws:SourceIp or VPN-only access for sensitive actions, where practical.
  • Short session durations so stolen sessions expire fast.
  • GuardDuty and CloudTrail alerts for unusual API calls.

When the laptop is reported lost, disable the user in the identity provider and revoke active sessions.

Q47. How would you explain the shared responsibility model with an example? Senior

AWS is responsible for security "of" the cloud: data centres, hardware, the network and the software that runs services.

The customer is responsible for security "in" the cloud: IAM, data, encryption choices, security groups, and patching the guest OS on EC2.

Example with EC2: AWS patches the physical host. You patch Amazon Linux inside your instance and close port 22 to the internet.

Example with Lambda: AWS also manages the OS and runtime patches. You still own your code, IAM role and input validation.

The line moves depending on how managed the service is.

Q48. How do you audit who changed a security group rule last night? Senior

Use CloudTrail. Security group changes are management events, which CloudTrail records by default.

aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=AuthorizeSecurityGroupIngress --max-results 5 --query "Events[].{time:EventTime,user:Username}"

Output:

[
    {
        "time": "2026-11-18T22:41:09+05:30",
        "user": "dev-session"
    }
]

A session named dev-session added an inbound rule at 22:41. Open the full event to see the role ARN, source IP and the exact rule. Event history keeps 90 days. For longer history, use a trail that stores logs in S3 or CloudTrail Lake.

Q49. How do you secure the CI/CD pipeline's access to AWS? Senior

Avoid storing long-term AWS keys in the CI tool.

  • Use OIDC federation. For example, GitHub Actions gets a short token, and AWS trusts it through an IAM OIDC identity provider.
  • The role trust policy must check the audience and the subject, such as the exact repository and branch, for example repo:example-org/shop-app:ref:refs/heads/main.
  • Give the deploy role only the permissions to deploy that stack.
  • Use separate roles for dev and prod, and require approval before prod.
  • Log every deployment in CloudTrail and alert on use from unexpected repositories.
Q50. How would you encrypt data at rest and in transit for a three-tier web application? Senior

In transit:

  • HTTPS at CloudFront and the ALB with ACM certificates.
  • TLS between the app and RDS. You can force it with the database parameter that requires SSL or TLS connections.
  • S3 bucket policy that denies requests when aws:SecureTransport is false.

At rest:

  • EBS, RDS, S3 and backups encrypted with KMS keys. Use customer managed keys if you need control or cross-account sharing.
  • Secrets in Secrets Manager, not in code.

Also explain key access: only the app role and admins can use the keys, and CloudTrail logs every use.

5. Frequently asked questions

Do I need to remember every IAM condition key?

No. Remember the common ones such as aws:MultiFactorAuthPresent, aws:SourceIp, aws:PrincipalOrgID, aws:RequestedRegion and aws:SourceVpce. Say that you check the documentation for the rest. Interviewers like honest answers.

Which security services should a fresher know by name?

Know IAM, IAM Identity Center, KMS, Secrets Manager, CloudTrail, GuardDuty, Security Hub, AWS WAF and AWS Shield. Be able to say one line about what each one does.

How do I practise IAM without risk?

Use a separate practice account. Create a test role with read-only access and try the IAM policy simulator. Never practise on a company production account.

6. Quick revision

  • Default is deny. An explicit Deny always wins.
  • Prefer roles and temporary credentials over long-term access keys.
  • SCPs and permission boundaries set the maximum. They never grant access.
  • Use KMS for keys and Secrets Manager for secrets with rotation.
  • Turn on MFA, CloudTrail and GuardDuty in every account.

This page is one part of a 500-question AWS interview set. Open the full list here: All 500 AWS interview questions.