From 9fa1a8c5beb3032b39249e1d9fa580e48b530b44 Mon Sep 17 00:00:00 2001 From: Ross Williams Date: Mon, 8 Mar 2021 15:41:45 -0500 Subject: [PATCH] sns_topic: Allow canonical international-format phone numbers in SMS subscriptions (#454) * Update sns_topic.py Adds `+` to the list of acceptable characters in an SMS endpoint. Closes #453. * Add changelog fragment for #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 Co-authored-by: Mark Chappell --- .../454-sns_topic_fix_sms_endpoint_canonicalization.yaml | 2 ++ plugins/modules/sns_topic.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/454-sns_topic_fix_sms_endpoint_canonicalization.yaml diff --git a/changelogs/fragments/454-sns_topic_fix_sms_endpoint_canonicalization.yaml b/changelogs/fragments/454-sns_topic_fix_sms_endpoint_canonicalization.yaml new file mode 100644 index 00000000000..fd4cf415cef --- /dev/null +++ b/changelogs/fragments/454-sns_topic_fix_sms_endpoint_canonicalization.yaml @@ -0,0 +1,2 @@ +bugfixes: + - sns_topic - Add ``+`` to allowable characters in SMS endpoints (https://github.com/ansible-collections/community.aws/pull/454). diff --git a/plugins/modules/sns_topic.py b/plugins/modules/sns_topic.py index 79070cbabc5..1be60a38ec9 100644 --- a/plugins/modules/sns_topic.py +++ b/plugins/modules/sns_topic.py @@ -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 if protocol == 'sms': - return re.sub('[^0-9]*', '', endpoint) + return re.sub('[^0-9+]*', '', endpoint) return endpoint def _set_topic_subs(self):