Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
IAM Best Practices Setup
📖 Scenario: You are setting up AWS Identity and Access Management (IAM) for a small company. The company wants to follow best practices to keep their cloud resources secure.You will create an IAM user, assign a group with limited permissions, and enable multi-factor authentication (MFA) for extra security.
🎯 Goal: Build a secure IAM setup by creating an IAM user, an IAM group with specific permissions, attaching the user to the group, and enabling MFA for the user.
📋 What You'll Learn
Create an IAM user named developer
Create an IAM group named ReadOnlyGroup with the AWS managed policy ReadOnlyAccess
Add the developer user to the ReadOnlyGroup
Enable MFA for the developer user
💡 Why This Matters
🌍 Real World
Companies use IAM to control who can access their cloud resources and what actions they can perform. Following best practices helps keep data safe.
💼 Career
Understanding IAM basics is essential for cloud administrators and security engineers to manage user access securely.
Progress0 / 4 steps
1
Create IAM user developer
Write the AWS CLI command to create an IAM user named developer.
AWS
Hint
Use the aws iam create-user command with the --user-name option.
2
Create IAM group ReadOnlyGroup with ReadOnlyAccess policy
Write the AWS CLI commands to create an IAM group named ReadOnlyGroup and attach the AWS managed policy ReadOnlyAccess to it.
AWS
Hint
First create the group with aws iam create-group, then attach the policy with aws iam attach-group-policy.
3
Add user developer to group ReadOnlyGroup
Write the AWS CLI command to add the IAM user developer to the IAM group ReadOnlyGroup.
AWS
Hint
Use aws iam add-user-to-group with the --user-name and --group-name options.
4
Enable MFA for user developer
Write the AWS CLI command to enable a virtual MFA device for the IAM user developer. Assume the MFA device ARN is arn:aws:iam::123456789012:mfa/developer.
AWS
Hint
Use aws iam enable-mfa-device with --user-name, --serial-number, and two consecutive MFA codes --authentication-code1 and --authentication-code2.
Practice
(1/5)
1. What is the main reason to follow the principle of least privilege in AWS IAM?
easy
A. To create permanent access keys for all users
B. To allow users full access to all AWS services
C. To give users only the permissions they need to do their job
D. To disable multi-factor authentication (MFA) for easier access
Solution
Step 1: Understand least privilege concept
Least privilege means giving users only the permissions they need, nothing more.
Step 2: Identify correct option
To give users only the permissions they need to do their job matches this concept by limiting permissions to what is necessary.
Final Answer:
To give users only the permissions they need to do their job -> Option C
Quick Check:
Least privilege = minimal permissions [OK]
Hint: Least privilege means minimal needed permissions only [OK]
Common Mistakes:
Giving users full access unnecessarily
Using permanent keys instead of temporary credentials
Ignoring MFA setup
2. Which of the following is the correct way to assign permissions to an AWS service using IAM?
easy
A. Create an IAM role and assign it to the AWS service
B. Generate permanent access keys and embed them in the service code
C. Create an IAM user and attach policies directly to the user
D. Use root account credentials for the service
Solution
Step 1: Understand IAM roles for services
IAM roles allow AWS services to assume permissions temporarily without permanent keys.
Step 2: Identify best practice
Assigning an IAM role to the service is the recommended way to grant permissions securely.
Final Answer:
Create an IAM role and assign it to the AWS service -> Option A
Quick Check:
Use roles for services, not permanent keys [OK]
Hint: Use roles for AWS services, not permanent keys [OK]
Common Mistakes:
Attaching policies directly to users for services
Embedding permanent keys in code
Using root account credentials
3. Consider this IAM policy snippet attached to a user:
The policy allows only the "s3:ListBucket" action on the specific bucket resource.
Step 2: Determine allowed operations
"s3:ListBucket" lets the user see the list of objects but not upload or delete.
Final Answer:
List the contents of the example-bucket -> Option B
Quick Check:
Action = s3:ListBucket means list only [OK]
Hint: Check the Action field to know allowed operations [OK]
Common Mistakes:
Assuming upload or delete permissions from list permission
Thinking the policy applies to all buckets
Ignoring the specific resource ARN
4. You created an IAM user with full S3 access but forgot to enable MFA. What is the best way to fix this?
medium
A. Attach an MFA policy and require MFA for sensitive actions
B. Delete the user and create a new one with MFA enabled
C. Remove all permissions from the user
D. Share the root account credentials with the user
Solution
Step 1: Understand MFA enforcement
MFA can be required by attaching policies that enforce MFA for sensitive actions.
Step 2: Apply best practice
Attaching an MFA policy is better than deleting the user or removing permissions.
Final Answer:
Attach an MFA policy and require MFA for sensitive actions -> Option A
Quick Check:
Enable MFA via policy, don't delete users [OK]
Hint: Use policies to enforce MFA, not user deletion [OK]
Common Mistakes:
Deleting users unnecessarily
Removing all permissions without MFA
Sharing root credentials
5. Your company wants to allow temporary access to AWS resources for contractors without creating permanent IAM users. Which approach follows best IAM practices?
hard
A. Give contractors permanent access keys with admin permissions
B. Create permanent IAM users with full access for contractors
C. Share your root account credentials with contractors
D. Create IAM roles with limited permissions and let contractors assume them
Solution
Step 1: Identify temporary access method
IAM roles allow temporary credentials that contractors can assume without permanent users.
Step 2: Match best practice
Creating roles with limited permissions follows least privilege and avoids permanent keys.
Final Answer:
Create IAM roles with limited permissions and let contractors assume them -> Option D
Quick Check:
Temporary roles for contractors = best practice [OK]
Hint: Use roles for temporary access, avoid permanent users [OK]