Login to AWS console, thực hiện nội dung sau:
*Yêu cầu máy cài sẵn AWS CLI latest.

1. Phát hành access key/secret key cho user đã tạo ở Lab1
2. Thiết lập access key/ secret key cho AWS CLI.
3. Tương tác với 1 vài service bằng CLI.
4. Tạo policy enforce-mfa-policy và gắn vào “developer-group”
5. Thử gõ lại CLI xem còn xài dc ko?
6. Cài MFA cho user “developer-01”
7. Thiết lập sesssion_token sử dụng MFA code.
8. Gõ lệnh CLI sử dụng profile đã có MFA.
#Test credential
aws sts get-caller-identity

#List all s3 bucket
aws s3 ls

#Download file
aws s3 cp <s3 uri> <local destination>

#Upload file
aws s3 cp <local destination> <s3 uri> 

#Lisst file
aws s3 ls <s3://path>

#Using cli with MFA
#Step 1 issue temporary token
aws sts get-session-token --serial-number arn:aws:iam::123456789012:mfa/developer-01-iphone --token-code 123456

#Step 2: config credential file.
"C:\\Users\\<your user name>\\.aws\\credentials"
#--------------------
[udemy-mfa]
aws_access_key_id = <your-access-key-id>
aws_secret_access_key = <your-secret-access-key>
aws_session_token = <your-session-token>
#-------------

#Step 3: specify --profile when run command.
aws s3 ls --profile udemy-mfa
aws s3 ls s3://<your-bucket-name>/ --profile udemy-mfa

image.png

image.png

image.png

1. Phát hành access key/secret key cho user đã tạo ở Lab1

Có 2 cách phát hành

image.png

image.png

⇒ Phát hành key cho chính mình

Lab dùng user do admin phát hành để tạo “developer-01”

image.png

image.png

image.png

*Access key này không được phép lộ, nó đại diện cho chính user này*

2. Thiết lập access key/ secret key cho AWS CLI.

image.png