知识卡片
桶事件如何触发函数
S3 桶存储对象,Lambda 执行已部署的函数代码。书中的 bucket b => lambda l 请求在桶中创建对象时触发函数。执行层先创建 Lambda 并保存响应中的 ARN(资源唯一标识),再创建桶,由 Lambda 侧授权来自该桶的调用,最后在 S3 侧配置发往该 ARN 的对象创建通知。授权允许接收,通知确定什么时候向哪个目标投递。
书中的 SDK 请求还依赖地区、凭据、Lambda 执行角色,以及事先准备的函数代码包。这些是教学项目的设置。函数执行角色的用途与授予 S3 调用函数的权限不同,前者让函数代码以指定身份运行,后者控制谁可触发函数。
相关卡片 [[解析与资源创建分层]]、[[同步宏等待异步执行]]、[[宏展开可能触发外部写入]]。
结构图:
sequenceDiagram
participant M as 宏的部署逻辑
participant L as Lambda
participant S as S3
M->>L: 创建函数
L-->>M: 返回函数 ARN
M->>S: 创建桶
M->>L: 授权该桶调用函数
M->>S: 配置对象创建通知及函数 ARN
S->>L: 对象创建事件触发函数
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
- · 从解析进入部署
原书出处 · 1 处
- Writing an infrastructure DSL 从解析进入部署 · 查看原书依据
When the clients are ready, we create the lambda, saving the result in output. Why? Because we will be creating a bucket next, and if it has an event, we need to know the Amazon Resource Name (ARN; a unique identifier) of the lambda so we know where to send the event. We also need to add so-called AWS Identity Access Management (IAM) permissions to tell the lambda that our bucket is allowed to send events.