Best practice: Avoid using the Root User. Instead, create IAM Users with minimal permissions needed to manage resources. This makes management easier and reduces security risks.
In this section, we will create a policy to restrict a user to only interact with EC2 Instances in the ap-southeast-1 region.
2.1. On the left navigation menu, select
Policies
2.2. In the Policies interface, click Create policy.
2.3. Step 1 - Specify permissions, - Go to the JSON tab, paste the following JSON into the Policy Editor, and click Next.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:RequestedRegion": "ap-southeast-1"
}
}
}
]
}
This policy allows users to manage EC2 instances only in the ap-southeast-1 region.
2.4. Step 2 - Review and Create:
Enter a Policy Name: ec2-restricted-region-group
.
Enter a Description: Allow access to EC2 only in ap-southeast-1
.
Click Create policy.
To reuse this policy, assign it to an IAM Group. All IAM Users in this group will have the same permissions.
3.1. Access User groups from the left navigation menu.
ec2-restricted-region-group
.4.1. Access Users from the left
navigation menu.
4.2. Click Create user.
4.3. Step 1 - Specify user details: Step 1 - Specify user details:
restricted_user
.restricted_user1
.4.4. Step 2 - Set permissions:
4.5. Step 3 - Review and Create:
4.6. Step 4 - Retrieve password:
4.7. Log in as the IAM User:
restricted_user
and password: restricted_user1
.