# SNS

> Publish messages to SNS topics and check the messages your services publish.

Source: https://axx.nimbusxr.us/references/steps/aws-sns/

Publish messages to SNS topics and check the messages your services publish.

The steps use the scenario's AWS account (`the {word} aws account with the following properties:`, from aws-core).

**Checking a topic** does not take messages from anyone: for the topics a run checks, Axx subscribes a queue of its own (`axx-<run>-<topic>`, with raw message delivery) once the apps are up, and removes the subscription and the queue when the run ends. A check only looks at the messages received since its scenario started; match on data unique to the scenario, since scenarios run in parallel.

## `aws-sns.send`

```gherkin
When a message is published to the {word} sns topic:
  """
  ...
  """
```

Send a message whose body is the doc string to a sns topic.

**Parameters:** `{word}` (one word, no spaces)

**Example:**

```gherkin
When a message is published to the claim-decisions sns topic:
```

_Since 0.1.0._

## `aws-sns.send.file`

```gherkin
When the {filepath} message is published to the {word} sns topic[[ with the following attributes:]]
```

Send a message whose body is the file (resolved against `resources`) to a sns topic, with the attributes of the table (`name | value`).

**Variants** (optional parts in `[[...]]` above):

- `the {filepath} message is published to the {word} sns topic`
- `the {filepath} message is published to the {word} sns topic with the following attributes:`

**Parameters:** `{filepath}` (A file of the project, without whitespace: a path relative to the `resources` directories or to the directory of axx.yaml, or an absolute path. Editors link it to the file), `{word}` (one word, no spaces)

**Example:**

```gherkin
When the messages/shipment-delivered.json message is published to the claim-decisions sns topic
When the messages/shipment-delivered.json message is published to the claim-decisions sns topic with the following attributes:
```

_Since 0.1.0._

## `aws-sns.received`

```gherkin
Then [[within {duration} ]]the {word} sns topic has a message where:
  | ... | ... |
```

Wait (10s, or the given time) until the sns topic has a message, received since the scenario started, that meets every row: `path | value` on the JSON body (a field name, a dotted path or a JSONPath, compared as text; `null` for null and `undefined` for absent), or `attribute <name> | value` on a attribute sent with it. Axx subscribes a queue of its own to the topic for the run.

**Variants** (optional parts in `[[...]]` above):

- `the {word} sns topic has a message where:`
- `within {duration} the {word} sns topic has a message where:`

**Parameters:** `{duration}` (A duration in seconds or minutes, e.g. `5s` or `2m`), `{word}` (one word, no spaces)

**Example:**

```gherkin
Then within 30s the claim-decisions sns topic has a message where:
```

_Since 0.1.0._
