Love Reddy Isireddy
5 min readSep 9, 2024

AWS IAM Scenario based Questions ❓

❓You need to allow an EC2 instance to read from an S3 bucket. How do you accomplish this?

Answer: Create an IAM role with a policy that allows access to the S3 bucket and attach this role to the EC2 instance. The policy should have actions like s3:GetObject and specify the S3 bucket ARN.

❓A developer needs to grant permissions to an IAM user to manage IAM roles but not to create new users. What should you do?

Answer: Attach a policy to the IAM user that grants iam:ListRoles, iam:GetRole, iam:UpdateRole, iam:AttachRolePolicy, and iam:DetachRolePolicy, but not iam:CreateUser.

❓You need to provide a third-party service with temporary access to your S3 bucket. How can you do this securely?

Answer: Use AWS STS to create a role with the required permissions and configure a trust policy that allows the third-party service to assume the role. Generate temporary credentials using sts:AssumeRole.

❓You want to ensure that an IAM user can only access resources in the dev environment but not in prod. How should you configure the permissions?

Answer: Attach a policy to the IAM user that restricts access to resources with specific tags or resource names corresponding to the dev environment only.

❓You have a policy that grants s3:ListBucket permission to a user for all buckets. You want to restrict this to only one specific bucket. How?

Answer: Modify the policy to include a condition that specifies the bucket ARN in the s3:ListBucket action, such as "Resource": "arn:aws:s3:::my-bucket".

❓An IAM user should have access to start and stop EC2 instances but should not be able to terminate them. What permissions should you include?

Answer: Grant permissions for ec2:StartInstances and ec2:StopInstances, but exclude ec2:TerminateInstances from the policy.

❓You need to provide a developer with access to all services within a specific region. How do you accomplish this?

Answer: Create a policy with permissions for the required services and include a condition that restricts access based on the aws:RequestedRegion key.

❓An application needs to interact with DynamoDB but should not have access to any other AWS services. How should you configure this?

Answer: Create an IAM role with a policy that grants permissions only to DynamoDB actions and attach this role to the application.

❓You need to enforce MFA (Multi-Factor Authentication) for IAM users accessing the AWS Management Console. How do you set this up?

Answer: Configure an IAM policy that requires MFA for all actions by specifying a condition with aws:MultiFactorAuthPresent set to true.

❓You want to limit access to a specific S3 bucket for a user to only read objects. What permissions should you grant?

Answer: Attach a policy with the action s3:GetObject and specify the bucket ARN in the resource section of the policy.

❓You want to provide a temporary developer access to a Lambda function for one month. How do you do this?

Answer: Create an IAM role with permissions for Lambda and use AWS STS to issue temporary security credentials with a 1-month expiration.

❓A team needs to share read-only access to an RDS instance. What is the best way to achieve this?

Answer: Create an IAM policy with read-only permissions for RDS and attach it to the team’s IAM users or roles.

❓You have an IAM policy that grants access to an S3 bucket. However, you want to restrict this access to requests originating from a specific IP address. How?

Answer: Add a condition to the policy that checks the IP address using the aws:SourceIp key.

❓You want to grant permissions to an IAM role for creating and managing CloudFormation stacks. What permissions should you include?

Answer: Grant cloudformation:CreateStack, cloudformation:UpdateStack, cloudformation:DeleteStack, and other necessary cloudformation:* permissions.

❓A service needs to interact with DynamoDB tables but should not be able to update or delete items. What permissions should be granted?

Answer: Grant dynamodb:GetItem and dynamodb:Query actions but exclude dynamodb:UpdateItem and dynamodb:DeleteItem.

❓You need to restrict an IAM user’s access to only a specific prefix within an S3 bucket. How do you set this up?

Answer: Use a policy with the s3:Prefix condition to limit access to the desired prefix within the bucket.

❓You have a team that needs to access a shared S3 bucket but should not be able to modify bucket policies. What permissions should be restricted?

Answer: Grant s3:GetObject and s3:ListBucket permissions but exclude s3:PutBucketPolicy and s3:DeleteBucketPolicy.

❓You want to prevent IAM users from changing their own permissions. How can you enforce this?

Answer: Create and attach a policy that explicitly denies iam:PutUserPolicy, iam:AttachUserPolicy, and iam:DetachUserPolicy actions.

❓You need to allow an application to access EC2 instances and S3 buckets but want to enforce the least privilege principle. How should you do this?

Answer: Create separate roles with policies specific to EC2 and S3 permissions, then attach these roles to the application with the minimum required permissions.

❓A user needs to access only the CloudWatch logs but not modify them. What permissions should you provide?

Answer: Grant logs:DescribeLogGroups, logs:DescribeLogStreams, and logs:GetLogEvents permissions, and exclude any write actions.

❓You have a policy that should only apply if a specific tag is present on the resource. How do you configure this in the policy?

Answer: Use the Condition block in the policy with aws:RequestTag or aws:TagKeys to check for the specific tag on the resource.

❓A specific IAM user should have read-only access to AWS Config and should not be able to make any changes. How do you configure this?

Answer: Attach a policy that includes config:Describe* and config:Get* actions, and exclude any actions that modify configurations.

❓You need to allow an application to perform actions on a DynamoDB table but prevent it from scanning the entire table. What permissions should you grant?

Answer: Grant dynamodb:GetItem and dynamodb:Query actions, but exclude dynamodb:Scan.

❓You need to enable cross-account access for a user in Account A to access resources in Account B. What steps should you take?

Answer: In Account B, create a role with a trust policy allowing Account A to assume the role. In Account A, provide the IAM user with permissions to assume the role in Account B.

❓You need to set up a policy that allows an IAM user to assume a role in a different AWS account. What permissions are required?

Answer: Grant sts:AssumeRole permission in the policy attached to the IAM user. The role in the other account should have a trust policy allowing the user’s account to assume it.

🥷Enjoy your Learning and Please comment if you feel — any other similar questions we can add to this page..!

Thank you much for reading📍

“ Yours Love ( @lisireddy across all the platforms )