Objectives
After this lab, you will have:
- An AWS Account secured with MFA on the Root User
- AWS CLI v2 installed and configured to work
- A dedicated IAM user with the appropriate permissions (do not use Root anymore)
- An IAM Group with the policy properly attached
Requirements
- An email address not previously used to register for AWS (or an existing account)
- A credit/debit card (AWS Free Tier — this lab incurs no charges)
- A terminal (macOS/Linux) or PowerShell (Windows)
Secure the Root User with MFA
This is a mandatory step to do immediately after creating the account:
- Log in to console.aws.amazon.com
- Click the account name (top right) → Security credentials
- Section Multi-factor authentication (MFA) → Assign MFA device
- Select Authenticator app (use Google Authenticator or Authy)
- Scan the QR code → Enter two consecutive codes → Add MFA
Check: Sign out and sign in to the console again; it will require the MFA code. ✅
Create an IAM Admin User
From now on, use this IAM user instead of the Root user:
In the console:


- Search for IAM in the console → Users → Create user
- Username:
admin-yourname(for example:admin-john) - Check Provide user access to the AWS Management Console
- Custom password — select “Autogenerated password“: AWS automatically generates a random password and sends the password to you after creation. You can enter a password yourself by selecting “Custom password“
- Users must create a new password at next sign-in: The user will be required to change their password at the next sign-in after the account is created.
- Next ??? Add user to group
-
Create group ??? Group name:
Administrators - Find and select a policy: AdministratorAccess ??? Create user group
- Add user to group Administrators ??? Next ??? Create user
- Download .csv or record the Console sign-in URL, username, and password
Enable MFA for the IAM user:
- Click the user you just created Security credentials
- Assign MFA device Repeat the process as Root
Install and configure the AWS CLI
Linux:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install aws --version
Windows (PowerShell):
# Download từ: https://awscli.amazonaws.com/AWSCLIV2.msi # Chạy installer, sau đó: aws --version
Create an Access Key for an IAM User

- Sign in with IAM user just created (use the Console sign-in URL from step 3)
- Click the user name (top right) → Security credentials
- Access keys → Create access key
- Use case: Command Line Interface (CLI)
- Check the confirmation box → Next → Create access key
- Download .csv Save it securely, The Secret Key is displayed only once!
Configure AWS CLI

#
# Cấu hình profile mặc định aws configure # Nhập thông tin: # AWS Access Key ID: <Access Key ID từ bước 5> # AWS Secret Access Key: <Secret Access Key từ bước 5> # Default region name: ap-southeast-1 (hoặc region gần bạn nhất) # Default output format: json # Kiểm tra cấu hình aws sts get-caller-identity
Expected result:
If you see the output shown above in the CLI, the connection was successful! ✅
{
"UserId": "AIDARA4XYMAICN36K2MWF",
"Account": "070648356880",
"Arn": "arn:aws:iam::070648356880:user/admin-lu"
}
Create a Second IAM User Using the CLI (Hands-On)
Create a standard IAM user (not an administrator) using the CLI:
GROUP="Developers"
USER="developer-01"
POLICY="DeveloperPolicy"
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
POLICY_ARN="arn:aws:iam::${ACCOUNT_ID}:policy/${POLICY}"
## 1. Tạo Group
aws iam create-group --group-name $GROUP
## 2. Tạo Policy (S3 + DynamoDB + Lambda)
cat > developer-policy.json << 'EOF'
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject","s3:ListBucket","s3:PutObject"],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": ["dynamodb:GetItem","dynamodb:PutItem","dynamodb:Query","dynamodb:Scan"],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": ["lambda:InvokeFunction","lambda:GetFunction","lambda:ListFunctions"],
"Resource": "*"
}
]
}
EOF
aws iam create-policy \
--policy-name $POLICY \
--policy-document file://developer-policy.json \
--description "Policy cho Developer team"
## 3. Gán Policy → Group
aws iam attach-group-policy \
--group-name $GROUP \
--policy-arn $POLICY_ARN
## 4. Tạo User → thêm vào Group → tạo password
aws iam create-user --user-name $USER
aws iam add-user-to-group --user-name $USER --group-name $GROUP
aws iam create-login-profile \
--user-name $USER \
--password "TempPass123!" \
--password-reset-required
## 5. Kiểm tra kết quá
aws iam get-user --user-name $USER
aws iam list-groups-for-user --user-name $USER
aws iam list-attached-group-policies --group-name $GROUP
Result:


- When logging in to the AWS Console for the first time with the user
developer-01, the system will require you to change the password before continuing. This is the effect of the flag--password-reset-requiredwhen running the commandcreate-login-profile. This is a security best practice to prevent temporary passwords from remaining active for too long. At this point, creating the IAM user via the CLI is complete.
Check Permissions (Optional — recommended)
Test whether the policy is working correctly using IAM Policy Simulator:

# Kiểm tra permission cụ thể bằng CLI
aws iam simulate-principal-policy \
--policy-source-arn "arn:aws:iam::${ACCOUNT_ID}:user/developer-01" \
--action-names "s3:GetObject" "ec2:DescribeInstances" \
--resource-arns "arn:aws:s3:::*"
-
s3:GetObject???allowed✅ -
ec2:DescribeInstances???implicitDeny✅ (not included in the policy)
Summary
Through this lab, you have set up a properly secured AWS environment from the outset:
- Root user protected by MFA and not used directly for day-to-day work
-
IAM Admin user separate from
AdministratorAccessthe Root user, protected by MFA and used instead of Root from now on - AWS CLI configured and successfully authenticated using an Access Key
- IAM Group + Policy created correctly: permissions are attached to the group rather than directly to the user
-
Standard IAM User (
developer-01) with exactly the permissions required: no more, no less