SNS

Amazon Simple Notification Service (SNS) is a highly available, durable, secure, fully managed pub/sub messaging service that enables you to decouple microservices, distributed systems, and serverless applications. Amazon SNS provides topics for high-throughput, push-based, many-to-many messaging. Using Amazon SNS topics, your publisher systems can fan out messages to a large number of subscriber endpoints for parallel processing, including Amazon SQS queues, AWS Lambda functions, and HTTP/S webhooks. Additionally, SNS can be used to fan out notifications to end users using mobile push, SMS, and email. Source: AWS

Command

rhub add:action <group.eventId> <filterId> AWS SNS

Param

Description

eventId

The event that will receive te action.

Example: payment.payment-fulfilled

filterId

The filter/trigger in the event that will process the action.

Example: on-event

Operations

Operation

Description

Publish Message

Sends a message to an Amazon SNS topic or sends a text message (SMS message) directly to a phone number.

AWS Documentation.

Publish Message

By adding the publish queue operation, you must specify the targert, it can be a Topic, Target or SMS and the type of the message you wish to send.

Select the message target.
Select the message payload type.

If you select JSON as the message type, the CLI fills the event YAML payload property with the event model mapping.

Target Example

The YAML action properties change according to the selected target type.

Topic
Target
SMS
Topic

YAML

-
id: my-action
async: false
type: AWS
action: SQS
operation: 'Publish Message'
serviceAccountId: my-aws-us-east-account-id
template:
TopicArn: ""
Message:
default: '##### Type the message content. #####'
APNS:
aps: {}
FCM:
data:
message: '##### Type the message content. #####'
url: ""
ADM:
data:
message: '##### Type the message content. #####'
url: ""
Subject: ""
MessageAttributes: {}
MessageStructure: json

YAML PARAMS

Params

Description

id, async, type, action, operation, serviceAccountId

The action default parameters, see more.t

TopicArn

The topic you want to publish to.

Message

The message you want to send.

The Message parameter is a sns json property if the MessageStructure is set to JSON.

Subject

Optional parameter to be used as the "Subject" line when the message is delivered to email endpoints. This field will also be included, if present, in the standard JSON messages delivered to other endpoints.

MessageAttributes

Custom object structured metadata, each message can have up to 10 attributes, see more.

MessageStructure

Set MessageStructure to json if you want to send a different message for each protocol. For example, using one publish action, you can send a short message to your SMS subscribers and a longer message to your email subscribers. If you set MessageStructure to json, the value of the Message parameter must:

  • be a syntactically valid JSON object; and

  • contain at least a top-level JSON key of "default" with a value that is a string.

You can define other top-level keys that define the message you want to send to a specific transport protocol (e.g., "http").

For information about sending different messages for each protocol using the AWS Management Console, go to Create Different Messages for Each Protocol in the Amazon Simple Notification Service Getting Started Guide.

Valid value: json

Target

YAML

-
id: my-action
async: false
type: AWS
action: SQS
operation: 'Publish Message'
serviceAccountId: my-aws-us-east-account-id
template:
TopicArn: ""
Message:
default: '##### Type the message content. #####'
APNS:
aps: {}
FCM:
data:
message: '##### Type the message content. #####'
url: ""
ADM:
data:
message: '##### Type the message content. #####'
url: ""
Subject: ""
MessageAttributes: {}
MessageStructure: json

YAML PARAMS

Params

Description

id, async, type, action, operation, serviceAccountId

The action default parameters, see more.t

TargetArn

Either TopicArn or EndpointArn, but not both.

Message

The message you want to send.

The Message parameter is a sns json property if the MessageStructure is set to JSON.

Subject

Optional parameter to be used as the "Subject" line when the message is delivered to email endpoints. This field will also be included, if present, in the standard JSON messages delivered to other endpoints.

MessageAttributes

Custom object structured metadata, each message can have up to 10 attributes, see more.

MessageStructure

Set MessageStructure to json if you want to send a different message for each protocol. For example, using one publish action, you can send a short message to your SMS subscribers and a longer message to your email subscribers. If you set MessageStructure to json, the value of the Message parameter must:

  • be a syntactically valid JSON object; and

  • contain at least a top-level JSON key of "default" with a value that is a string.

You can define other top-level keys that define the message you want to send to a specific transport protocol (e.g., "http").

For information about sending different messages for each protocol using the AWS Management Console, go to Create Different Messages for Each Protocol in the Amazon Simple Notification Service Getting Started Guide.

Valid value: json

SMS

YAML

-
id: my-action
async: false
type: AWS
action: SQS
operation: 'Publish Message'
serviceAccountId: my-aws-us-east-account-id
template:
PhoneNumber: ""
Message:
default: '##### Type the message content. #####'
APNS:
aps: {}
FCM:
data:
message: '##### Type the message content. #####'
url: ""
ADM:
data:
message: '##### Type the message content. #####'
url: ""
Subject: ""
MessageAttributes: {}
MessageStructure: json

YAML PARAMS

Params

Description

id, async, type, action, operation, serviceAccountId

The action default parameters, see more.t

PhoneNumber

The phone number to which you want to deliver an SMS message. Use E.164 format.

If you don't specify a value for the PhoneNumber parameter, you must specify a value for the TargetArn or TopicArn parameters

Message

The message you want to send.

The Message parameter is a sns json property if the MessageStructure is set to JSON.

Subject

Optional parameter to be used as the "Subject" line when the message is delivered to email endpoints. This field will also be included, if present, in the standard JSON messages delivered to other endpoints.

MessageAttributes

Custom object structured metadata, each message can have up to 10 attributes, see more.

MessageStructure

Set MessageStructure to json if you want to send a different message for each protocol. For example, using one publish action, you can send a short message to your SMS subscribers and a longer message to your email subscribers. If you set MessageStructure to json, the value of the Message parameter must:

  • be a syntactically valid JSON object; and

  • contain at least a top-level JSON key of "default" with a value that is a string.

You can define other top-level keys that define the message you want to send to a specific transport protocol (e.g., "http").

For information about sending different messages for each protocol using the AWS Management Console, go to Create Different Messages for Each Protocol in the Amazon Simple Notification Service Getting Started Guide.

Valid value: json