英文:
Selecting specific JSON fields to use in SNS message
问题
我正在尝试构建一个阶段函数,它接收 JSON 作为输入,然后在步函数中通过 SNS 发送消息时仅使用此 JSON 的部分内容。我尝试使用一些可用的 [内置 JSON 操作函数][1],但没有成功。
是否有一种方法可以提取特定的 JSON 字段以用于 SNS 消息,而不使用 Lambda?
对于消息字段,我希望它是:
message.$: $.name $.questions 等等...
但这不起作用
以下是我的代码:
stepFunctions:
stateMachines:
hellostepfunc1:
name: test
definition:
Comment: "test"
StartAt: SNSState
States:
SNSState:
Type: Task
InputPath: $
Resource: arn:aws:states:::sns:publish
Parameters:
TopicArn:
Fn::GetAtt: [ MyTopic, TopicArn ]
Message.$: $ //这里我想发送多个,例如 $.name $questions
End: true
[1]: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html#asl-intrsc-func-json-manipulate
英文:
I'm trying to build a step function which receives json as input and then uses only some of this JSON in a message sent via SNS in the step function. I've tried using some of the instrinsic json manipulation functions available but with no luck.
Is there a way to extract specific json fields for an SNS message without using a lambda?
For the message field, I would like the it to be:
message.$: $.name $.questions etc...
But this doesn't work
Here is my code:
stepFunctions:
stateMachines:
hellostepfunc1:
name: test
definition:
Comment: "test"
StartAt: SNSState
States:
SNSState:
Type: Task
InputPath: $
Resource: arn:aws:states:::sns:publish
Parameters:
TopicArn:
Fn::GetAtt: [ MyTopic, TopicArn ]
Message.$: $ //here I would like to send multiple e.g $.name $questions
End: true
答案1
得分: 1
最好的方法是使用AWS Lambda函数。也就是说,开发一个自定义的AWS Lambda函数,可以使用JSON库读取和操作JSON以满足您的业务需求,然后将这些Lambda函数连接到Amazon States Language文档中。
英文:
The best way is to use an AWS Lambda function. That is, develop a custom AWS Lambda function that can read and manipulate JSON to meet your business requirments using a JSON library. Then hook these Lambda functions into an Amazon States Language document.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论