I think that it's actually the other way around...
When creating the Lambda function, you can specify the role for it to use. The ability to allow a function to use a Role requires the iam:PassRole
permission. Anyone with this permission can configure a Lambda function to use a specific (or any) IAM Role.
Here's a sample policy from Granting a User Permissions to Pass a Role to an AWS Service - AWS Identity and Access Management that grants an IAM User the ability to pass a role:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"iam:GetRole",
"iam:PassRole"
],
"Resource": "arn:aws:iam::<account-id>:role/EC2-roles-for-XYZ-*"
}]
}
iam:PassRole
is a very important permission because it controls who can pass a role to a service. Used incorrectly, users might gain too much permission. For example, let's say that there is an Admin Role that has lots of permissions. Anyone who is granted permission to use PassRole
could create a resource (eg Amazon EC2 instance or AWS Lambda function) that uses this role, thereby giving them Admin capabilities. For this reason, the ability to use PassRole
should be strictly controlled.
Therefore, rather than the role trusting a Lambda function, you actually need a user with PassRole
to assign the role to the function.
"Resource": <Lambda ARN>
under Action – Ninad Gaikwad