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):