
ℹ️ Information: AWS EC2 offers various instance families optimized for different workloads. By restricting which instance families users can deploy, organizations can implement effective cost governance while ensuring workloads run on appropriately sized resources.
💡 Pro Tip: For development and testing environments, limiting users to cost-effective general purpose instances can significantly reduce your AWS bill while still providing sufficient resources for non-production workloads.
AWS organizes EC2 instances into families that target specific use cases:
For comprehensive information on all instance types, refer to the Amazon EC2 Instance Types documentation.
Analyze Compute Requirements
As a Cloud Engineer, you’ve received the following requirements from the Development team:
Select Appropriate Instance Families


Create an IAM Policy for Instance Family Restriction
IAM

Switch to the JSON editor tab
Delete any existing template code in the editor

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*"
},
{
"Effect": "Deny",
"Action": "ec2:RunInstances",
"Resource": "arn:aws:ec2:*:148922931563:instance/*",
"Condition": {
"StringNotLike": {
"ec2:InstanceType": [
"t3.*",
"t4g.*",
"m5.*"
]
}
}
}
]
}
🔒 Security Note: Replace the account ID (148922931563) in the Resource ARN with your own AWS account ID. You can copy your account ID by clicking the account dropdown in the top navigation bar.

Scroll down and click Next to go to Step 2: Review and create.
Enter the following details:
EC2_FamilyRestrictRestrict EC2 instances to t3, t4g and m5 families only

Attach the Policy to an IAM Group

Select the Permissions tab
Click Add permissions, then select Attach policies

EC2_FamilyRestrict




Test Allowed Instance Family: T4g
EC2_T4g_FamilyRestrict as the instance name



Test Denied Instance Family: M6i
EC2_M6i_FamilyRestrict as the instance name


Additional Testing
For complete verification, you can repeat step 5 with T3 and M5 instance families to confirm they are allowed by the policy.
⚠️ Warning: Remember to terminate any test instances after verification to avoid unnecessary charges. The IAM policy restricts which instance types can be launched but doesn’t prevent charges for running instances.