IAM policy example: start and stop tagged EC2 instances, with a least privilege rewrite
Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.
Allows a principal to start, stop and reboot only EC2 instances whose Owner tag equals the caller's user name. The ec2:ResourceTag condition key reads the tag from the instance. The original also allows terminate and every other action through ec2:*.
Open the workbench ยท All examples
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ManageOwnInstances",
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "arn:aws:ec2:*:*:instance/*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/Owner": "${aws:username}"
}
}
}
]
}
What it allows
- Allows every EC2 action on instances tagged Owner with the caller's user name.
What it allows
Allow 834 actions (ec2:*) on arn:aws:ec2:*:*:instance/* when ec2:ResourceTag/Owner StringEquals ${aws:username}.
Action or pattern Actions Access levels ec2:*834 List 225, Read 63, Write 521, Permissions management 23, Tagging 2
Checks
No flags from the six checks.
The tag condition limits the instances, but ec2:* covers 834 actions, including terminate and modify.
Least privilege rewrite
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "StartStopOwn",
"Effect": "Allow",
"Action": [
"ec2:StartInstances",
"ec2:StopInstances",
"ec2:RebootInstances"
],
"Resource": "arn:aws:ec2:*:*:instance/*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/Owner": "${aws:username}"
}
}
},
{
"Sid": "Describe",
"Effect": "Allow",
"Action": "ec2:DescribeInstances",
"Resource": "*"
}
]
}
The rewrite lists three power actions on the tagged instances and a describe call so the caller can find them. Terminate and modify are removed.
What it allows
Allow 3 actions (ec2:StartInstances, ec2:StopInstances, ec2:RebootInstances) on arn:aws:ec2:*:*:instance/* when ec2:ResourceTag/Owner StringEquals ${aws:username}.
Action or pattern Actions Access levels ec2:StartInstances1 Write 1 ec2:StopInstances1 Write 1 ec2:RebootInstances1 Write 1 Allow 1 action (ec2:DescribeInstances) on every resource.
Action or pattern Actions Access levels ec2:DescribeInstances1 List 1
Checks
No flags from the six checks.
Related pages
Sources
- IAM User Guide: attribute-based access control tutorial, read 16 Nov 2026
- IAM User Guide: EC2 access in a specific Region, read 16 Nov 2026
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026
Last reviewed 16 Nov 2026.