Skip to content

Commit

Permalink
sns_topic: Allow canonical international-format phone numbers in SMS …
Browse files Browse the repository at this point in the history
…subscriptions (ansible-collections#454)

* Update sns_topic.py

Adds `+` to the list of acceptable characters in an SMS endpoint.

Closes ansible-collections#453.

* Add changelog fragment for ansible-collections#454

* sns_topic: comment explaining SMS canonicalization

Add comment documenting to what standard SMS endpoint addresses (phone
numbers) are canonicalized

* sns_topic: fix changelog

* Get quoting correct
* Simplify message to leave details in PR description

Co-authored-by: Mark Chappell <[email protected]>

Co-authored-by: Mark Chappell <[email protected]>
  • Loading branch information
2 people authored and danquixote committed May 16, 2021
1 parent dffb9be commit a2025ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- sns_topic - Add ``+`` to allowable characters in SMS endpoints (https://github.com/ansible-collections/community.aws/pull/454).
5 changes: 4 additions & 1 deletion plugins/modules/sns_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,11 @@ def _set_topic_attrs(self):
return changed

def _canonicalize_endpoint(self, protocol, endpoint):
# AWS SNS expects phone numbers in
# and canonicalizes to E.164 format
# See <https://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html>
if protocol == 'sms':
return re.sub('[^0-9]*', '', endpoint)
return re.sub('[^0-9+]*', '', endpoint)
return endpoint

def _set_topic_subs(self):
Expand Down

0 comments on commit a2025ea

Please sign in to comment.