---
title: AWS SNS actions
source: https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/aws/aws-sns
---

This page provides a reference for AWS SNS actions available in the workflow automation actions catalog. Use these actions to publish messages to Amazon SNS topics.

## Prerequisites

Before using AWS actions in workflow automation, ensure you have:

-   An AWS account with appropriate permissions.
-   AWS credentials configured (IAM user credentials, IAM role ARN, or session credentials).
-   The necessary IAM permissions for the specific AWS services you plan to use.

See [Set up AWS credentials](https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/set-up-aws-credentials/) for information on how to create IAM users and IAM roles, and set up static and session AWS credentials for integration with workflow automation AWS actions.

## Publish a message to an SNS topic

The action identifier is `aws.sns.publish`.

Sends a message to an Amazon SNS topic. All subscribers to the topic will receive the message.

The following table describes the input fields for this action.

| **Input**                | **Type** | **Description**                                                                                                                                                                                                                                                        | **Example**                                                   |
| ------------------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| `awsRoleArn`             | String   | Optional. IAM role ARN to assume for AWS API calls.                                                                                                                                                                                                                    | `arn:aws:iam::123456789012:role/my-workflow-role`             |
| `awsAccessKeyId`         | String   | Optional. AWS access key ID. Pass as a secret.                                                                                                                                                                                                                         | `${{ :secrets:awsAccessKeyId }}`                              |
| `awsSecretAccessKey`     | String   | Optional. AWS secret access key. Pass as a secret.                                                                                                                                                                                                                     | `${{ :secrets:awsSecretAccessKey }}`                          |
| `awsSessionToken`        | String   | Optional. Temporary session token for STS authentication. Pass as a secret.                                                                                                                                                                                            | `${{ :secrets:awsSessionToken }}`                             |
| `region`                 | String   | Required. AWS region of the target SNS topic.                                                                                                                                                                                                                          | `us-east-2`                                                   |
| `message`                | String   | Required. The message to publish. Messages must be UTF-8 encoded strings and at most 256 KB in size. `PhoneNumber` is intentionally excluded from this action because it is personally identifiable information (PII). To send a direct SMS, use the AWS SDK directly. | `"Workflow failed at step 3"`                                 |
| `topicArn`               | String   | Optional. Topic ARN to publish to. You must specify either `topicArn` or `targetArn`.                                                                                                                                                                                  | `arn:aws:sns:us-east-2:123456789012:my-topic`                 |
| `targetArn`              | String   | Optional. Target ARN to publish to. You must specify either `topicArn` or `targetArn`.                                                                                                                                                                                 | `arn:aws:sns:us-east-2:123456789012:MySNSTopic`               |
| `subject`                | String   | Optional. Subject for email-based subscriptions.                                                                                                                                                                                                                       | `"Workflow Update"`                                           |
| `MessageStructure`       | String   | Optional. Set to `json` to send different messages to different protocols.                                                                                                                                                                                             | `"json"`                                                      |
| `messageAttributes`      | Map      | Optional. Message attributes to attach to the message.                                                                                                                                                                                                                 | `{"string": {"DataType": "string", "StringValue": "string"}}` |
| `messageDeduplicationId` | String   | Optional. Token used for deduplication of messages in FIFO topics.                                                                                                                                                                                                     | `"abc123deduplicationId5678"`                                 |
| `messageGroupId`         | String   | Optional. Tag that specifies the message group in a FIFO topic.                                                                                                                                                                                                        | `"order-processing-group-2023_A"`                             |

The following table describes the output fields for this action.

| **Output**     | **Type** | **Example**                                                                                                                                                                                      |
| -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `response`     | Object   | `{"MessageId": "2333ededwedwed-52f5-a716-e10355e3e2ff"}`. See the [publish boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sns/client/publish.html). |
| `success`      | Boolean  | `true | false`                                                                                                                                                                                   |
| `errorMessage` | String   | `"An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: TopicArn or TargetArn Reason: no value for required parameter"`                                    |

```yaml
name: sns-publish-test
description: Publishes a notification to an SNS topic
workflowInputs:
  arnRole:
    type: String
steps:
  - name: aws_sns_publish_1
    type: action
    action: aws.sns.publish
    version: '1'
    inputs:
      awsRoleArn: ${{ .workflowInputs.arnRole }}
      region: us-east-1
      topicArn: arn:aws:sns:us-east-1:123456789012:workflow-test-topic
      subject: "Workflow Update"
      message: "The data processing workflow has completed successfully."
    next: end
```
