Skip to content

Commit

Permalink
Added clarification on specifying SNS ARN
Browse files Browse the repository at this point in the history
This is critical, to avoid a race condition when deploying or updating a stack.
  • Loading branch information
ffxsam authored Sep 12, 2019
1 parent fa0f675 commit 58d4bdc
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion docs/providers/aws/events/sns.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ functions:
arn: arn:xxx
```

Or with intrinsic CloudFormation function like `Fn::Join` or `Fn::GetAtt`.
Or with intrinsic CloudFormation function like `Fn::Join`, `Fn::GetAtt`, or `Fn::Ref` (or their shorthand counterparts).
**Note:** The arn can be in a different region to enable cross region invocation

```yml
Expand All @@ -80,6 +80,25 @@ functions:
topicName: MyCustomTopic
```

If your SNS topic doesn't yet exist but is defined in the serverless.yml file you're editing, you'll need to use `Fn::Ref` or `!Ref` to get the ARN. Do not build a string as in the above example!

```yml
functions:
dispatcher:
handler: dispatcher.dispatch
events:
- sns:
arn: !Ref SuperTopic
topicName: MyCustomTopic
resources:
Resources:
SuperTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: MyCustomTopic
```

**Note:** If an `arn` string is specified but not a `topicName`, the last substring starting with `:` will be extracted as the `topicName`. If an `arn` object is specified, `topicName` must be specified as a string, used only to name the underlying Cloudformation mapping resources. You can take advantage of this behavior when subscribing to multiple topics with the same name in different regions/accounts to avoid collisions between Cloudformation resource names.

```yml
Expand Down

0 comments on commit 58d4bdc

Please sign in to comment.