Identity, Permission, Trust and Resource Policies
Last updated
Was this helpful?
Last updated
Was this helpful?
There are the following types of policies:
Identity-based policies are attached to users/groups and define what those identities can do across AWS services
This policy would be attached directly to an IAM user or group and allows them to start/stop EC2 instances tagged as "Production" and view all instances.
IAM role must have two types of policies:
Trust Policy (only one):
Defines WHO can assume the role
Sometimes called "trust relationship policy"
Always uses the sts:AssumeRole action
Must include Principal element
Permission Policies (can have multiple):
Define WHAT the role can do
Lists allowed/denied AWS actions
No Principal element needed
Can attach multiple permission policies to a role
Think of it this way:
Trust Policy = Who can use this role?
Permission Policy = What can this role do?
Both are required for a role to be functional. You can't have a role without a trust policy, and a role without permission policies wouldn't be able to do anything.
Resource-based (e.g. S3 bucket policy) policies are attached to resources (like S3 buckets) . Resource-based policy must declare the "Principle" element to define who can access that resource.
This policy is attached directly to the S3 bucket and controls access to that specific resource.
A common real-world example might combine these:
A developer has an identity-based policy allowing them to assume certain roles
Those roles have permission policies defining what AWS services they can access
The resources they need to access might have resource-based policies allowing access from those roles