Skip to main content

Amazon SNS Component

Manage subscriptions, topics, and messages within Amazon (AWS) SNS

Component key: aws-sns

Description

Amazon SNS is a service for both application-to-application (A2A) and application-to-person (A2P) communication. The Amazon SNS component allows you to interact with an SNS Topic.

Connections

AWS SNS Access Key and Secret

An AWS IAM access key pair is required to interact with Amazon SNS. Make sure that the key pair you generate in AWS has proper permissions to the SNS resources you want to access. Read about Amazon SNS IAM policies in the AWS docs.

InputNotesExample
Access Key ID
string
/ Required
accessKeyId
An AWS IAM Access Key ID
AKIAIOSFODNN7EXAMPLE
Secret Access Key
password
/ Required
secretAccessKey
An AWS IAM Secret Access Key
wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

AWS Role ARN

To enable the IAM role authentication begin by logging into the AWS Console and navigate to Identity and Access Management (IAM).

To create a user and generate credentials:

  1. Navigate to Users and select Create User.
  • Provide a User name and check the box providing them user access to the AWS Managment Console if needed.
  • Once completed with the User creation, copy the ARN provided in the summary for a later step.
  1. To obtain the ARN for an existing User, click on the designated username from the Users page and the ARN will be provided in the summary section.

  2. From the summary section, select Create access key

  • Select Third-party service as the access key type and select next.
  • Set a description and select create access key.
  • Copy the Access Key and Secret access key and enter those into the connection configuration of your integration along with the ARN.

To create and assign a user a role:

  1. Navigate to Roles and select Create Role.
  • Select Custom Trust Policy for the Trusted entity types
  • Copy the following statement into the statement console. Making sure to replace the ARN with the user's actual ARN from the previous section
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "ARN"
},
"Action": "sts:AssumeRole"
}
]
}
  • When adding permissions provide the AmazonSNSFullAccess permission
  • Complete remaining steps and select Create Role
InputNotesExample
Access Key ID
string
/ Required
accessKeyId
An AWS IAM Access Key ID
AKIAIOSFODNN7EXAMPLE
Role ARN
string
/ Required
roleARN
An AWS IAM Role ARN
arn:aws:iam::OtherAccount-ID:role/assumed-role-name
Secret Access Key
password
/ Required
secretAccessKey
An AWS IAM Secret Access Key
wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

Triggers

Subscription Trigger

Confirm subscription and unsubscribe requests and validate SNS messages | key: subscriptionTrigger

InputDefaultNotes
Parse Message
boolean
/ Required
parseMessage
false
When enabled the message from SNS will be parsed as JSON and returned. If disabled it will be passed as received.

Amazon SNS can be configured to send notification to an HTTPS endpoint. To point SNS notifications towards your integration, identify your integration's webhook URL, and subscribe that URL to an SNS topic. Once a subscription has been created, new messages sent to your SNS topic will be sent to your Prismatic instance via its webhook URL.

Messages from SNS take one of three forms: Subscription Confirmation, Unsubscribe Confirmation or Notification. If a subscription or unsubscribe message is received, this trigger automatically handles the subscription confirmation process. This process lets Amazon SNS know that your instance is ready to receive and process notifications.

Depending on what type of message is received, the trigger will then follow a "Subscribe", "Unsubscribe" or "Notification" branch. These branches make it so you can configure additional steps that execute (e.g. you can alert your team via Slack that a subscription has been confirmed). "Subscribe" and "Unsubscribe" branches can be left blank if you don't have any additional steps you'd like to run once a subscription has been confirmed - you will likely only fill in steps under the "Notification" branch.

In addition to confirming subscriptions, this trigger verifies the signature of messages that come in, so you know they originated from Amazon.

Testing must be done through SNS

Because of signature verification, testing of integrations with this trigger must be done using Amazon SNS. Tests from the integration designer, or from curl or another HTTP client will fail since you can't spoof Amazon's message signature.

When a "Notification" message comes in, and it is a JSON string, you can optionally choose to parse the JSON using the "Parse Message" input. Note that if the incoming message is not valid JSON, the trigger will throw an error when "Parse Message" is set to true.

{
"payload": {
"headers": {
"x-amz-sns-message-type": "Notification",
"x-amz-sns-message-id": "da41e39f-ea4d-435a-b922-c6aae3915ebe",
"x-amz-sns-topic-arn": "arn:aws:sns:us-west-2:123456789012:MyTopic",
"x-amz-sns-subscription-arn": "arn:aws:sns:us-west-2:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55",
"Content-Length": "761",
"Content-Type": "text/plain; charset=UTF-8",
"Host": "ec2-50-17-44-49.compute-1.amazonaws.com",
"Connection": "Keep-Alive",
"User-Agent": "Amazon Simple Notification Service Agent"
},
"queryParameters": {},
"rawBody": {
"data": {}
},
"webhookUrls": {},
"webhookApiKeys": {},
"customer": {
"externalId": "abc-123",
"name": "Example Corp",
"id": "exampleId"
},
"body": {
"data": {
"Type": "Notification",
"MessageId": "da41e39f-ea4d-435a-b922-c6aae3915ebe",
"TopicArn": "arn:aws:sns:us-west-2:123456789012:MyTopic",
"Subject": "test",
"Message": "test message",
"Timestamp": "2012-04-25T21:49:25.719Z",
"SignatureVersion": "1",
"Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
"SigningCertURL": "https://sns.us-west-2.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
"UnsubscribeURL": "https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"
}
},
"executionId": "",
"instance": {
"id": "example",
"name": "exampleName"
},
"pathFragment": "example",
"invokeUrl": "Url",
"user": {
"email": "email@email.test",
"externalId": "externalId",
"id": "123",
"name": "name"
}
},
"branch": "Notification"
}

Actions

Create Topic

Create an Amazon SNS Topic | key: createTopic

InputNotesExample
Connection
connection
/ Required
awsConnection
 
 
AWS Region
string
awsRegion
AWS provides services in multiple regions, like us-west-2 or eu-west-1.
us-east-1
Name
string
/ Required
name
Provide a string for the name of the topic.
MyExampleTopic

{
"data": {
"TopicArn": "arn:aws:Example Topic Arn"
}
}

Delete Topic

Delete an Amazon SNS Topic | key: deleteTopic

InputNotesExample
Connection
connection
/ Required
awsConnection
 
 
AWS Region
string
awsRegion
AWS provides services in multiple regions, like us-west-2 or eu-west-1.
us-east-1
Topic Arn
string
/ Required
topicArn
An Amazon SNS topic is a logical access point that acts as a communication channel.
arn:aws:sns:us-east-2:123456789012:MyExampleTopic

Get Topic Attributes

Retrieves the attributes of an Amazon SNS Topic. | key: getTopicAttributes

InputNotesExample
Connection
connection
/ Required
awsConnection
 
 
AWS Region
string
awsRegion
AWS provides services in multiple regions, like us-west-2 or eu-west-1.
us-east-1
Topic Arn
string
/ Required
topicArn
An Amazon SNS topic is a logical access point that acts as a communication channel.
arn:aws:sns:us-east-2:123456789012:MyExampleTopic

{
"data": {
"Attributes": {
"Policy": "Example Policy",
"Owner": "0123456789000",
"topicArn": "arn:aws:sns:us-east-2:123456789012:MyExampleTopic",
"SubscriptionsPending": "1",
"EffectiveDeliveryPolicy": "Example Delivery Policy",
"SubscriptionsConfirmed": "5",
"DisplayName": "Example Display Name",
"SubscriptionsDeleted": "5"
}
}
}

List Opt Out Numbers

Create an Amazon SNS Topic | key: listOptOutNumbers

InputNotesExample
Connection
connection
/ Required
awsConnection
 
 
AWS Region
string
awsRegion
AWS provides services in multiple regions, like us-west-2 or eu-west-1.
us-east-1
Next Token
string
nextToken
Specify the pagination token that's returned by a previous request to retrieve the next page of results
lslTXFcbLQKkb0vP9Kgh5hy0Y0OnC7Z9ZPHPwPmMnxSk3eiDRMkct7D8E

{
"data": {
"phoneNumbers": [
"15556164096",
"18980994152",
"18008988422"
]
}
}

List Subscriptions

Retrieve the subscriptions of an Amazon SNS Topic | key: listSubscriptions

InputNotesExample
Connection
connection
/ Required
awsConnection
 
 
AWS Region
string
awsRegion
AWS provides services in multiple regions, like us-west-2 or eu-west-1.
us-east-1
Next Token
string
nextToken
Specify the pagination token that's returned by a previous request to retrieve the next page of results
lslTXFcbLQKkb0vP9Kgh5hy0Y0OnC7Z9ZPHPwPmMnxSk3eiDRMkct7D8E
Topic Arn
string
/ Required
topicArn
An Amazon SNS topic is a logical access point that acts as a communication channel.
arn:aws:sns:us-east-2:123456789012:MyExampleTopic

{
"data": {
"Subscriptions": [
{
"SubscriptionArn": "arn:aws:sns:us-east-2:123456789012:MyExampleTopic:00000000-00000000-00000000-00000000",
"Owner": "0123456789000",
"Protocol": "https",
"Endpoint": "https://example.com/",
"TopicArn": "arn:aws:sns:us-east-2:123456789012:MyExampleTopic"
},
{
"SubscriptionArn": "PendingConfirmation",
"Owner": "0123456789000",
"Protocol": "email",
"Endpoint": "admin@example.com",
"TopicArn": "arn:aws:sns:us-east-2:123456789012:MyExampleTopic"
}
]
}
}

List Topics

List available Amazon SNS Topics | key: listTopics

InputNotesExample
Connection
connection
/ Required
awsConnection
 
 
AWS Region
string
awsRegion
AWS provides services in multiple regions, like us-west-2 or eu-west-1.
us-east-1
Next Token
string
nextToken
Specify the pagination token that's returned by a previous request to retrieve the next page of results
lslTXFcbLQKkb0vP9Kgh5hy0Y0OnC7Z9ZPHPwPmMnxSk3eiDRMkct7D8E

{
"data": {
"Topics": [
{
"TopicArn": "arn:aws:Example Topic Arn"
}
]
}
}

Publish Batch Messages

Publishes up to ten messages to the specified Amazon SNS Topic | key: publishBatchMessages

InputDefaultNotesExample
Connection
connection
/ Required
awsConnection
 
 
 
AWS Region
string
awsRegion
AWS provides services in multiple regions, like us-west-2 or eu-west-1.
us-east-1
Message Entries
code
/ Required
publishBatchEntries
To add a Binary Message add a Template Field containing a Buffer from a previous field to the BinaryValue attribute. For MessageAttributes data types, see: https://docs.aws.amazon.com/sns/latest/dg/sns-message-attributes.html
 
Topic Arn
string
/ Required
topicArn
An Amazon SNS topic is a logical access point that acts as a communication channel.
arn:aws:sns:us-east-2:123456789012:MyExampleTopic

{
"data": {
"$metadata": {
"httpStatusCode": 200,
"requestId": "3df5ab1c-8e8a-426f-a2d1-bd7a39ef8651",
"attempts": 1,
"totalRetryDelay": 0
},
"Successful": [
{
"Id": "2",
"MessageId": "6d1a92c3-77bc-49a5-bf62-1f047c34f9e7"
}
],
"Failed": []
}
}

Publish Message

Publish a message to an Amazon SNS Topic | key: publishMessage

InputNotesExample
Connection
connection
/ Required
awsConnection
 
 
AWS Region
string
awsRegion
AWS provides services in multiple regions, like us-west-2 or eu-west-1.
us-east-1
Message
string
/ Required
message
Provide a string for the message you would like to send.
 
Message Attributes
string
Key Value List
messageAttributes
For each item, provide a key value pair representing a message attribute, to supply a binary you must provide a Buffer to the key value. When determining your message attributes, it is important that you follow the specifications listed in the Amazon SNS docs: https://docs.aws.amazon.com/sns/latest/api/API_MessageAttributeValue.html
This is an example attribute
Topic Arn
string
/ Required
topicArn
An Amazon SNS topic is a logical access point that acts as a communication channel.
arn:aws:sns:us-east-2:123456789012:MyExampleTopic

{
"data": {
"MessageId": "00000000-00000000-00000000-00000000"
}
}

Publish SMS

Publish an SMS message to an Amazon SNS Topic | key: publishSms

InputNotesExample
Connection
connection
/ Required
awsConnection
 
 
AWS Region
string
awsRegion
AWS provides services in multiple regions, like us-west-2 or eu-west-1.
us-east-1
Message
string
/ Required
message
Provide a string for the message you would like to send.
 
Phone Number
string
/ Required
phoneNumber
Provide a phone number that you would like to subscribe to your topic.
12345678901

{
"data": {
"MessageId": "00000000-00000000-00000000-00000000"
}
}

Subscribe to Topic

Subscribe to an Amazon SNS Topic | key: subscribe

InputDefaultNotesExample
Connection
connection
/ Required
awsConnection
 
 
 
AWS Region
string
awsRegion
AWS provides services in multiple regions, like us-west-2 or eu-west-1.
us-east-1
Endpoint
string
/ Required
endpoint
The endpoint that you want to receive notifications. This could be an email address, URL, phone number, or SQS/application/Lambda/Firehose ARN.
example@company.com
protocol
string
/ Required
protocol
https
When you subscribe an endpoint to a topic, you must specify which protocol to use when this topic receives messages.
 
Topic Arn
string
/ Required
topicArn
An Amazon SNS topic is a logical access point that acts as a communication channel.
arn:aws:sns:us-east-2:123456789012:MyExampleTopic

{
"data": {
"SubscriptionArn": "arn:aws:sns:us-east-2:123456789012:MyExampleTopic:00000000-00000000-00000000-00000000"
}
}

Unsubscribe from a Topic

Unsubscribe from an Amazon SNS Topic | key: unsubscribe

InputNotesExample
Connection
connection
/ Required
awsConnection
 
 
AWS Region
string
awsRegion
AWS provides services in multiple regions, like us-west-2 or eu-west-1.
us-east-1
Subscription Arn
string
/ Required
subscriptionArn
The unique identifier for a topic subscription
arn:aws:sns:us-east-2:123456789012:MyExampleTopic:00000000-00000000-00000000-00000000