根据调用动态设置 lambda 中的假定角色
在以下情况下,您将如何实现安全模型:
- 用户能够“编写”自己的 lambda 函数并与其他用户共享。
- 只应允许此 lambda 在每个用户的基础上动态承担角色。例如,基于通过事件对象传递的“userId”键(原因是:lambda 函数将敏感文件写入 s3 存储桶中的“userId”特定路径),
- 相同的 lambda 代码应该可由其他用户以其各自的权限执行执行策略,而不仅仅是复制粘贴 lambda 代码,而只是具有不同的执行策略。
有没有办法在运行时动态地向 lambda 函数授予权限?例如,假设一个基于执行该角色的用户的角色?
How would you implement a security model with the following situation:
- Users are able to "write" their own lambda functions and share them with other users.
- This lambda should only be allowed to assume a role dynamically on a per-user basis. For example based on a "userId" key that's delivered via the event object (Reason being: the lambda function writes sensitive files to a "userId" specific path in a s3 bucket)
- the same lambda code should be executable by other users with their respective execution policies without just copy pasting the lambda code and just having a different execution policy.
Is there a way to give permissions to a lambda function dynamically at runtime? For example assuming a role that is based on the user executing it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用策略变量这应该是可能的。
例如,如果您的“用户”是 IAM 用户,并且您的 S3 存储桶的前缀包含用户名,那么您可以
在 IAM 策略中用于访问 S3 并将其附加到每个 IAM 用户。
请参阅有关策略变量的文档。
This should be possible using policy variables.
For example, if your "users" are IAM users and the prefix of your S3 buckets includes the username then you could use
in an IAM policy for accessing S3 and attach it to each IAM user.
See the documentation on policy variables.