Think of an AWS IAM Role like a secure building with a job inside.
For example:
An IAM Role has 2 important parts:
This answers:
“Which AWS service, user, or account is allowed to use this role?”
It is like the security guard at the entrance.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
This means:
✅ Lambda can enter the building.
But this policy does NOT say what Lambda can do yet.
Once Lambda enters the building, permissions decide:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": "*"
}
]
}
This means:
✅ The role can read objects from S3.
Imagine a school laboratory.
The lab says:
“Only science teachers may enter.”
That is the trust policy.
Inside the lab:
That is the permissions policy.
Both are required.
Lambda can assume the role… but cannot do anything useful.
Like entering an empty room.
The role has powers… but nobody is allowed to use it.
Like a locked superhero suit nobody can wear.