选择用于SNS消息的特定JSON字段

huangapple go评论84阅读模式
英文:

Selecting specific JSON fields to use in SNS message

问题

  1. 我正在尝试构建一个阶段函数,它接收 JSON 作为输入,然后在步函数中通过 SNS 发送消息时仅使用此 JSON 的部分内容。我尝试使用一些可用的 [内置 JSON 操作函数][1],但没有成功。
  2. 是否有一种方法可以提取特定的 JSON 字段以用于 SNS 消息,而不使用 Lambda
  3. 对于消息字段,我希望它是:
  4. message.$: $.name $.questions 等等...
  5. 但这不起作用
  6. 以下是我的代码:
  7. stepFunctions:
  8. stateMachines:
  9. hellostepfunc1:
  10. name: test
  11. definition:
  12. Comment: "test"
  13. StartAt: SNSState
  14. States:
  15. SNSState:
  16. Type: Task
  17. InputPath: $
  18. Resource: arn:aws:states:::sns:publish
  19. Parameters:
  20. TopicArn:
  21. Fn::GetAtt: [ MyTopic, TopicArn ]
  22. Message.$: $ //这里我想发送多个,例如 $.name $questions
  23. End: true
  24. [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:

  1. message.$: $.name $.questions etc...

But this doesn't work

Here is my code:

  1. stepFunctions:
  2. stateMachines:
  3. hellostepfunc1:
  4. name: test
  5. definition:
  6. Comment: "test"
  7. StartAt: SNSState
  8. States:
  9. SNSState:
  10. Type: Task
  11. InputPath: $
  12. Resource: arn:aws:states:::sns:publish
  13. Parameters:
  14. TopicArn:
  15. Fn::GetAtt: [ MyTopic, TopicArn ]
  16. Message.$: $ //here I would like to send multiple e.g $.name $questions
  17. 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.

huangapple
  • 本文由 发表于 2023年2月14日 19:04:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75446911.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定