amazon-web-services - Dynamodb 触发器使用 lambda 更新另一个 dynamobo 表
问题描述
我正在为我的 lambda 使用 dynamodb 触发器。所以我正在考虑两个条件,每当我的表 1 更新时,应该触发 lambda,并根据条件表达式更新表 2,就像我在表 2 中应用的更改一样。因为我是要使用 boto 3 资源需要对示例逻辑进行相同的重新分级。我是使用 dynamodb 触发器处理事件的新手。任何帮助将不胜感激。
解决方案
Table-1 ~~~~~~~~> AWS Lambda --------->Table2
Event received by AWS Lambda will look something like this. What you need to do is based on event name process the values present and store it in Table-2.
def lambda_handler(event, context):
dynamodb = boto3.resource('dynamodb', region_name='eu-west-1')
table2 = dynamodb.Table('Table-2')
# Read the records in the event
for record in event['Records']:
# process record and prepare required object for Table-2
table_2_obj = process_record(record)
put_item_response = table2.put_item(table_2_obj)
# Verify the response if required
print(put_item_response)
推荐阅读
- python - tensorflow 2.x 代码中的条件报错
- php - 无法在 Mac 上使用 XAMPP 安装 INTL 扩展
- pytorch - 如何为不同通道构建具有多个数组的 PyTorch 数据集
- c++ - 具有附加模板参数的可变 CRTP 基类
- c++ - 在 C++ 中的特定时间后退出函数
- python-3.x - Aho-Corasick 实施耗时过长
- javascript - TypeError:无法读取未定义的属性“地图”。找不到解决办法
- java - 我将如何在 MAC 上更新我的 ANDROID_SDK_ROOT / JAVA_HOME / PATH 环境变量来构建 Android
- android - 如何在 Tac tac toe,kotlin 中编写绘图逻辑
- ios - 排毒测试无法运行