Least privilege for Amazon EC2 means a scoped instance role, split API actions and IMDSv2
Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.
Amazon EC2 access has two sides: the IAM policies that let people call the EC2 API, and the instance role that applications use. AWS documentation read on 16 Nov 2026 supports narrowing Describe actions, one role per instance profile and policies generated from CloudTrail. This guide gives a read-only grant.
Open the calculator ยท All services
EC2 permissions split into API access and instance roles
AWS documentation says you control who can use EC2 resources with IAM policies and control access to instances with security groups. Applications on an instance get credentials from an IAM role attached through an instance profile, retrieved from the Instance Metadata Service (IMDS).
An instance profile can hold only one IAM role, and an instance can have only one role attached, though many instances can share a role. AWS says to associate least privilege policies that restrict the role to the specific API calls the application requires.
The identities that call this service (people, services, workloads, third parties) are covered in the AWS service identities guide and the workload identities guide.
Describe wildcards and role swaps are the broad actions to watch
- ec2:Describe* in a policy. AWS says Describe actions do not support resource-level permissions, so Resource must be "*"; replacing the wildcard with specific Describe actions is the way to shrink what a user can view.
- Granting the launch wizard more than it needs. AWS lists ec2:RunInstances plus ec2:DescribeImages, ec2:DescribeInstanceTypes, ec2:DescribeVpcs, ec2:DescribeSubnets and a security group action as the minimum for a launch.
- Letting users attach or replace roles without limits. AWS says resource-level permissions can control who may attach, replace or detach IAM roles for an instance.
- Removing a role from an instance profile to revoke access. AWS says the change can take up to one hour to take effect and recommends replacing the instance profile.
A read-only grant for instances, images and snapshots lists four actions
AWS publishes this example for a user who only needs to view instances, AMIs and snapshots in the console. Dropping ec2:DescribeTags limits the view to private AMIs.
| Effect | Action | Resource | Note from AWS |
|---|---|---|---|
| Allow | ec2:DescribeInstances | * | Describe actions need Resource "*" |
| Allow | ec2:DescribeImages | * | Lists AMIs |
| Allow | ec2:DescribeTags | * | Lets the console show public AMIs |
| Allow | ec2:DescribeSnapshots | * | Lists snapshots |
Instance metadata and the instance identity role limit what a host can hand out
AWS documentation says that by default instances accept IMDSv1 and IMDSv2, and that you can require IMDSv2 so IMDSv1 calls fail. IMDSv2 uses session-oriented requests.
Each instance also has an instance identity role with no trust policy, usable only by integrated services such as Systems Manager, GuardDuty Runtime Monitoring and EC2 Instance Connect. Because the credentials are present whether or not a service uses them, they are not a path for your own applications.
Policy generation and CloudTrail show which calls an instance role made
AWS says that before production you can generate an IAM policy from the activity of an IAM role. IAM Access Analyzer reviews your CloudTrail logs and creates a template containing the permissions used during the date range you specify.
To find which API actions a console task needs, AWS suggests a logging service such as CloudTrail. If a policy blocks an action, the console shows an encoded message that the STS DecodeAuthorizationMessage action can decode.
Related pages
Sources
- IAM roles for Amazon EC2, read 16 Nov 2026
- Example policies for the EC2 console, read 16 Nov 2026
- Instance metadata service, read 16 Nov 2026
Last reviewed 16 Nov 2026.