The following code examples show how to use EnableMfaDevice
.
- AWS CLI
-
To enable an MFA device
After you use the
create-virtual-mfa-device
command to create a new virtual MFA device, you can assign the MFA device to a user. The followingenable-mfa-device
example assigns the MFA device with the serial numberarn:aws:iam::210987654321:mfa/BobsMFADevice
to the userBob
. The command also synchronizes the device with AWS by including the first two codes in sequence from the virtual MFA device.aws iam enable-mfa-device \ --user-name
Bob
\ --serial-numberarn:aws:iam::210987654321:mfa/BobsMFADevice
\ --authentication-code1123456
\ --authentication-code2789012
This command produces no output.
For more information, see Enabling a virtual multi-factor authentication (MFA) device in the AWS IAM User Guide.
-
For API details, see EnableMfaDevice
in AWS CLI Command Reference.
-
For a complete list of AWS SDK developer guides and code examples, see Using this service with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.