使用 Step Functions 调用 Amazon SNS - AWS Step Functions
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

使用 Step Functions 调用 Amazon SNS

Step Functions can control certain AWS services directly from the Amazon 状态语言. For more information, see the following:

支持的 Amazon SNS API:

注意

There is a quota for the maximum input or result data size for a task in Step Functions. This restricts you to 32,768 characters of data when you send to, or receive data from, another service. See 与状态机执行相关的配额.

以下内容包括发布到 Amazon Simple Notification Service (Amazon SNS) 主题的 Task 状态。

{ "StartAt": "Publish to SNS", "States": { "Publish to SNS": { "Type": "Task", "Resource": "arn:aws-cn:states:::sns:publish", "Parameters": { "TopicArn": "arn:aws-cn:sns:us-east-1:123456789012:myTopic", "Message.$": "$.input.message", "MessageAttributes": { "my attribute no 1": { "DataType": "String", "StringValue": "value of my attribute no 1" }, "my attribute no 2": { "DataType": "String", "StringValue": "value of my attribute no 2" } } }, "End": true } } }

以下内容包括发布 Amazon SNS 主题,然后等待返回任务令牌的 Task 状态。请参阅 等待具有任务令牌的回调

{ "StartAt":"Send message to SNS", "States":{ "Send message to SNS":{ "Type":"Task", "Resource":"arn:aws:states:::sns:publish.waitForTaskToken", "Parameters":{ "TopicArn":"arn:aws:sns:us-east-1:123456789012:myTopic", "Message":{ "Input.$":"$", "TaskToken.$":"$$.Task.Token" } }, "End":true } } }

For information on how to configure IAM when using Step Functions with other AWS services, see 集成服务的 IAM 策略.