Reputation: 33618
Let say that there is a lambda function that has IAM policy with access to s3://my-bucket/users/
. And this function is invoked by user Bob which has IAM policy access to s3://my-bucket/users/bob
. Is there a way to "merge" or apply policy from Bob user to lambda function to restrict access? For example, if Bob passes the folder name Alice
lambda function fails when tries to access s3://my-bucket/users/alice
.
Any ideas?
Upvotes: 0
Views: 321
Reputation: 327
I see this as an authorization problem which requires a custom authorization module.
One way to this problem is as follows
s3://my-bucket/users/
.s3://my-bucket/users/
are fully accessible by a user in a data base./bob
and /admin
.s3://my-bucket/users/bob/personalDetaills.json
or s3://my-bucket/users/admin/employeeDetails.json
then request is approved and record is fetched. Request is approved because Bob is authorized for /bob
and /admin
suffixes.s3://my-bucket/users/alice
then a user not authorized error is thrown.Upvotes: 0
Reputation: 270104
No.
The Lambda function will run with permissions from the IAM Role that is associated with the function itself, regardless of who or what triggered the function.
One option would be for Bob to pass a set of credentials to the function when it is invoked (as parameters that will come through to the function in the event
), and then have the Lambda function use those credentials. However, this is a highly unusual thing to do.
Upvotes: 1