EnableMfaDevice 사용하기
EnableMfaDevice 사용하기 (CLI)
EnableMfaDevice(MFA 디바이스 활성화) API를 활용하는 방법을 코드 예시로 정리했어요. 각 예시는 어떤 동작을 하는지, 어떤 파라미터를 쓰는지 순서대로 살펴볼 수 있어요.
출처: 문서
본문
다음 코드 예시들은 EnableMfaDevice 를 어떻게 사용하는지 보여줘요.
AWS CLI
MFA 디바이스 활성화하기
aws iam enable-mfa-device \
--user-name Bob \
--serial-number arn:aws:iam::210987654321:mfa/BobsMFADevice \
--authentication-code1 123456 \
--authentication-code2 789012
create-virtual-mfa-device 명령으로 새 가상 MFA 디바이스를 만든 뒤에는 그 MFA 디바이스를 사용자에게 할당할 수 있어요. 다음 enable-mfa-device 예시는 일련번호가 arn:aws:iam::210987654321:mfa/BobsMFADevice인 MFA 디바이스를 Bob 사용자에게 할당해요. 이 명령은 가상 MFA 디바이스에서 나온 처음 두 개의 연속 코드를 포함해 디바이스를 AWS와 동기화하기도 해요.
PowerShell Tools (V4)
예시 1: 일련번호가 987654321098인 하드웨어 MFA 디바이스를 활성화하고 Bob 사용자와 연결해요. 디바이스에서 나온 처음 두 개의 연속 코드도 함께 전달해요.
Enable-IAMMFADevice -UserName "Bob" -SerialNumber "987654321098" -AuthenticationCode1 "12345678" -AuthenticationCode2 "87654321"
예시 2: 가상 MFA 디바이스를 만들고 활성화해요. 첫 번째 명령은 가상 디바이스를 만들고 디바이스의 객체 표현을 $MFADevice 변수에 반환해요. .Base32StringSeed나 QRCodePng 속성을 사용해 사용자의 소프트웨어 애플리케이션을 구성할 수 있어요. 마지막 명령은 디바이스를 일련번호로 식별해 David 사용자에게 할당해요. 또한 가상 MFA 디바이스에서 나온 처음 두 개의 연속 코드를 포함해 디바이스를 AWS와 동기화해요.
$MFADevice = New-IAMVirtualMFADevice -VirtualMFADeviceName "MyMFADevice"
# see example for New-IAMVirtualMFADevice to see how to configure the software program with PNG or base32 seed code
Enable-IAMMFADevice -UserName "David" -SerialNumber -SerialNumber $MFADevice.SerialNumber -AuthenticationCode1 "24681357" -AuthenticationCode2 "13572468"
PowerShell Tools (V5)
예시 1: 일련번호가 987654321098인 하드웨어 MFA 디바이스를 활성화하고 Bob 사용자와 연결해요. 디바이스에서 나온 처음 두 개의 연속 코드도 함께 전달해요.
Enable-IAMMFADevice -UserName "Bob" -SerialNumber "987654321098" -AuthenticationCode1 "12345678" -AuthenticationCode2 "87654321"
예시 2: 가상 MFA 디바이스를 만들고 활성화해요. 첫 번째 명령은 가상 디바이스를 만들고 디바이스의 객체 표현을 $MFADevice 변수에 반환해요. .Base32StringSeed나 QRCodePng 속성을 사용해 사용자의 소프트웨어 애플리케이션을 구성할 수 있어요. 마지막 명령은 디바이스를 일련번호로 식별해 David 사용자에게 할당해요. 또한 가상 MFA 디바이스에서 나온 처음 두 개의 연속 코드를 포함해 디바이스를 AWS와 동기화해요.
$MFADevice = New-IAMVirtualMFADevice -VirtualMFADeviceName "MyMFADevice"
# see example for New-IAMVirtualMFADevice to see how to configure the software program with PNG or base32 seed code
Enable-IAMMFADevice -UserName "David" -SerialNumber -SerialNumber $MFADevice.SerialNumber -AuthenticationCode1 "24681357" -AuthenticationCode2 "13572468"