从DynamoDB读取步骤功能工作流程中的DynamoDB迭代数据
我是编码和学习AWS服务的新手。我正在尝试从台阶功能工作流程中的dynamoDB表中迭代数据。例如,对于书ID,我想检查购买该书的客户的名字。我主要是在尝试使用MAP状态进行练习,并尝试与DDB集成。
我创建了一个带有id
的DDB表作为分区密钥,并添加了cust_name1
和cust_name2
作为书籍的多个客户的属性。现在,在我的步骤功能中,我想使用地图状态查询有多少人拥有该书ID。这可能吗?还是有更好的方法在此情况下使用地图状态?
我可以在任务状态下执行此操作,但要弄清楚如何在此情况下使用MAP状态。
{
"Comment": "A description of my state machine",
"StartAt": "DynamoDB Get Book Purchases",
"States": {
"DynamoDB Get Book Purchases": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:getItem",
"Parameters": {
"TableName": "get-book-data",
"Key": {
"id": {
"S": "121-11-2436"
}
}
},
"ResultPath": "$.DynamoDB",
"End": true
}
}
}
I am new to coding and learning about AWS services. I am trying to fetch data iteratively from a DynamoDB table in a Step Functions workflow. For Example, say for a book ID I want to check the names of customers that purchased the book. I am primarily trying to do practice using Map state and try to integrate with DDB.
I created a DDB table with id
as partition key and added cust_name1
and cust_name2
as attributes for multiple customers of a book. Now in my Step Functions, I want to use a Map state to query how many people have that book ID. Is this possible? Or is there a better way to use Map state for this scenario?
I am able to do this in a Task state, but trying to figure out how to use Map state for this scenario.
{
"Comment": "A description of my state machine",
"StartAt": "DynamoDB Get Book Purchases",
"States": {
"DynamoDB Get Book Purchases": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:getItem",
"Parameters": {
"TableName": "get-book-data",
"Key": {
"id": {
"S": "121-11-2436"
}
}
},
"ResultPath": "$.DynamoDB",
"End": true
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MAP(在步骤功能中)旨在在数组或列表的每个元素上应用功能。
Count
是一个聚合功能,因此,将其用作MAP
的一部分没有用。为了进行练习,您可以尝试允许用户购买多本书,其中
地图
功能将检查库存中每本书的可用性。Map (in Step Functions) is designed to apply a function on each of the elements of an array or list.
Count
is an aggregation function and therefore, using it as part ofMap
is not that useful.For your exercise, you can try to allow users to buy multiple books, where the
Map
functions will check the availability of each of the books in your inventory.