Bird
Raised Fist0
AWScloud~20 mins

Multi-factor authentication setup in AWS - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

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
Challenge - 5 Problems
🎖️
MFA Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary purpose of enabling MFA on an AWS root account?

Why should you enable Multi-factor Authentication (MFA) on the AWS root account?

ATo enable automatic backup of all AWS resources.
BTo allow multiple users to share the root account credentials safely.
CTo automatically reset the root account password every 30 days.
DTo add an extra layer of security by requiring a second form of verification during login.
Attempts:
2 left
💡 Hint

Think about how MFA helps protect accounts beyond just a password.

Configuration
intermediate
2:00remaining
Which AWS CLI command correctly enables a virtual MFA device for a user?

Choose the AWS CLI command that correctly associates a virtual MFA device with an IAM user named 'alice'.

Aaws iam attach-mfa-device --user alice --device arn:aws:iam::123456789012:mfa/alice
Baws iam create-virtual-mfa-device --virtual-mfa-device-name alice --outfile /path/to/qr-code.png
Caws iam enable-mfa-device --user-name alice --serial-number arn:aws:iam::123456789012:mfa/alice --authentication-code1 123456 --authentication-code2 654321
Daws iam set-mfa --username alice --device-arn arn:aws:iam::123456789012:mfa/alice
Attempts:
2 left
💡 Hint

Look for the command that enables MFA with authentication codes.

security
advanced
2:00remaining
What happens if an IAM user tries to access AWS resources without MFA when a policy requires MFA?

An IAM policy requires MFA for accessing S3 buckets. What is the result if the user tries to access the bucket without MFA?

AAccess is granted but with read-only permissions.
BAccess is denied because the policy condition requiring MFA is not met.
CAccess is granted normally without any restrictions.
DThe user is prompted to set up MFA before access is allowed.
Attempts:
2 left
💡 Hint

Consider how IAM policies enforce conditions.

service_behavior
advanced
2:00remaining
How does AWS handle MFA device removal for an IAM user when the device is lost?

If an IAM user loses their MFA device, what is the recommended AWS process to restore access?

AAn administrator must deactivate the lost MFA device and assign a new one to the user.
BThe user can reset the MFA device themselves via the AWS Management Console without admin help.
CThe user can continue accessing resources without MFA once the device is lost.
DAWS automatically disables MFA after 24 hours of inactivity.
Attempts:
2 left
💡 Hint

Think about who controls MFA device management for IAM users.

Architecture
expert
3:00remaining
Designing MFA enforcement for a multi-account AWS environment

You manage multiple AWS accounts linked via AWS Organizations. You want to enforce MFA for all IAM users across all accounts without manually configuring each account. Which AWS feature or approach achieves this most effectively?

AUse AWS Organizations Service Control Policies (SCPs) to require MFA for all IAM users in member accounts.
BManually enable MFA on each IAM user in every account using the AWS Management Console.
CCreate a Lambda function that scans accounts and enables MFA devices automatically.
DRely on IAM password policies to enforce MFA usage.
Attempts:
2 left
💡 Hint

Consider centralized policy enforcement across multiple accounts.

Practice

(1/5)
1. What is the main purpose of enabling Multi-factor Authentication (MFA) on an AWS account?
easy
A. To allow multiple users to share the same password
B. To speed up the login process by skipping passwords
C. To add an extra layer of security by requiring a second verification step
D. To automatically reset passwords every 30 days

Solution

  1. Step 1: Understand MFA purpose

    MFA requires a user to provide two forms of identification, usually a password and a code from a device, to increase security.
  2. Step 2: Compare options

    Only To add an extra layer of security by requiring a second verification step describes adding a second verification step for better security, which is the core of MFA.
  3. Final Answer:

    To add an extra layer of security by requiring a second verification step -> Option C
  4. Quick Check:

    MFA purpose = extra security step [OK]
Hint: MFA means two steps to prove identity, not faster login [OK]
Common Mistakes:
  • Thinking MFA speeds up login
  • Confusing MFA with password sharing
  • Assuming MFA resets passwords automatically
2. Which AWS CLI command correctly enables a virtual MFA device for a user named alice?
easy
A. aws iam enable-mfa-device --user-name alice --serial-number arn:aws:iam::123456789012:mfa/alice --authentication-code1 123456 --authentication-code2 654321
B. aws iam create-mfa-device --user alice --code1 123456 --code2 654321
C. aws iam add-mfa --username alice --device arn:aws:mfa:alice --codes 123456 654321
D. aws iam setup-mfa-device --user alice --serial arn:aws:iam::123456789012:mfa/alice --code 123456

Solution

  1. Step 1: Identify correct AWS CLI command syntax

    The command to enable an MFA device is aws iam enable-mfa-device with parameters for user name, serial number, and two consecutive authentication codes.
  2. Step 2: Match options to syntax

    aws iam enable-mfa-device --user-name alice --serial-number arn:aws:iam::123456789012:mfa/alice --authentication-code1 123456 --authentication-code2 654321 matches the correct command and parameters exactly. Other options use incorrect commands or missing parameters.
  3. Final Answer:

    aws iam enable-mfa-device --user-name alice --serial-number arn:aws:iam::123456789012:mfa/alice --authentication-code1 123456 --authentication-code2 654321 -> Option A
  4. Quick Check:

    Enable MFA CLI command = aws iam enable-mfa-device --user-name alice --serial-number arn:aws:iam::123456789012:mfa/alice --authentication-code1 123456 --authentication-code2 654321 [OK]
Hint: Enable MFA uses 'enable-mfa-device' with two codes [OK]
Common Mistakes:
  • Using 'create-mfa-device' instead of 'enable-mfa-device'
  • Providing only one authentication code
  • Incorrect parameter names or missing serial number
3. Given this AWS CLI command sequence, what will be the output status of the MFA device for user bob?
aws iam create-virtual-mfa-device --virtual-mfa-device-name bob-mfa --outfile /tmp/bob-mfa.png
aws iam enable-mfa-device --user-name bob --serial-number arn:aws:iam::123456789012:mfa/bob-mfa --authentication-code1 123456 --authentication-code2 654321
aws iam list-mfa-devices --user-name bob
medium
A. An error will occur because the authentication codes are missing
B. No MFA devices will be listed for user bob
C. The virtual MFA device will be created but not enabled
D. The MFA device named 'bob-mfa' will be listed as active for user bob

Solution

  1. Step 1: Understand command sequence

    The first command creates a virtual MFA device and outputs a QR code image. The second command enables this MFA device for user bob using two authentication codes. The third command lists all MFA devices for bob.
  2. Step 2: Predict output of list command

    Since the device was created and enabled successfully, the list command will show the 'bob-mfa' device as active for user bob.
  3. Final Answer:

    The MFA device named 'bob-mfa' will be listed as active for user bob -> Option D
  4. Quick Check:

    Created and enabled MFA device appears in list [OK]
Hint: Create then enable MFA device before listing to see it [OK]
Common Mistakes:
  • Assuming device is listed before enabling
  • Thinking missing codes cause error here
  • Confusing creation with enabling steps
4. A user tries to enable MFA with this command but gets an error:
aws iam enable-mfa-device --user-name carol --serial-number arn:aws:iam::123456789012:mfa/carol --authentication-code1 123456
What is the most likely cause of the error?
medium
A. Only one authentication code was provided instead of two
B. The serial number ARN is incorrect format
C. The user name 'carol' does not exist
D. The command should use 'create-mfa-device' instead

Solution

  1. Step 1: Review command requirements

    The enable-mfa-device command requires two consecutive authentication codes to verify the MFA device setup.
  2. Step 2: Identify missing parameter

    The command only provides one authentication code (authentication-code1) and misses the second (authentication-code2), causing the error.
  3. Final Answer:

    Only one authentication code was provided instead of two -> Option A
  4. Quick Check:

    Enable MFA needs two codes, missing one causes error [OK]
Hint: Enable MFA requires two codes, not one [OK]
Common Mistakes:
  • Providing only one authentication code
  • Assuming ARN format error without checking codes
  • Confusing enable with create commands
5. You want to enforce MFA for all IAM users in your AWS account to improve security. Which approach is the best practice to achieve this?
hard
A. Use a single MFA device shared by all users to simplify management
B. Create an IAM policy that denies all actions unless MFA is used, then attach it to all users
C. Require users to change passwords every 30 days instead of using MFA
D. Manually enable MFA on each user without any policy enforcement

Solution

  1. Step 1: Understand MFA enforcement methods

    To enforce MFA, you need a policy that denies actions unless MFA is present. This ensures users cannot bypass MFA even if enabled.
  2. Step 2: Evaluate options for best practice

    Create an IAM policy that denies all actions unless MFA is used, then attach it to all users uses an IAM policy to enforce MFA for all users, which is scalable and secure. Other options either lack enforcement or reduce security.
  3. Final Answer:

    Create an IAM policy that denies all actions unless MFA is used, then attach it to all users -> Option B
  4. Quick Check:

    Enforce MFA with deny policy = Create an IAM policy that denies all actions unless MFA is used, then attach it to all users [OK]
Hint: Use deny policy requiring MFA for all users [OK]
Common Mistakes:
  • Relying on manual enabling without enforcement
  • Using password rotation instead of MFA
  • Sharing one MFA device among users