# 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:*.

```json
{
  "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.

- Allows 834 actions (ec2:*) on arn:aws:ec2:*:*:instance/* when ec2:ResourceTag/Owner StringEquals ${aws:username}.

Checks:
- No flags.

The tag condition limits the instances, but ec2:* covers 834 actions, including terminate and modify.

## Least privilege rewrite

```json
{
  "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.

- Allows 3 actions (ec2:StartInstances, ec2:StopInstances, ec2:RebootInstances) on arn:aws:ec2:*:*:instance/* when ec2:ResourceTag/Owner StringEquals ${aws:username}.
- Allows 1 action (ec2:DescribeInstances) on every resource.

Checks:
- No flags.

- [Paste it into the workbench](/)
- [Every EC2 action and its access level](/actions/ec2/)

## Related pages

- [IAM policy example: limit EC2 actions to one Region](/examples/ec2-actions-in-one-region/)
- [IAM policy example: launch EC2 instances in one subnet](/examples/ec2-run-instances-in-one-subnet/)
- [IAM policy example: snapshot tagged EBS volumes](/examples/ec2-create-snapshots-tagged-volumes/)
- [All of them](/examples/)

## Sources

- IAM User Guide: attribute-based access control tutorial: https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_attribute-based-access-control.html (read 16 Nov 2026)
- IAM User Guide: EC2 access in a specific Region: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_ec2_region.html (read 16 Nov 2026)
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026): https://docs.aws.amazon.com/service-authorization/latest/reference/service-reference.html (read 16 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://iampolicygenerator.com/examples/ec2-start-stop-own-tagged-instances/

This site is not affiliated with Amazon Web Services. AWS service and product names are used only to describe AWS services.
