From c58c1b32e00d556362055b9374fbfbec3b067a41 Mon Sep 17 00:00:00 2001 From: Raz M Date: Wed, 29 Jun 2022 00:36:36 -0700 Subject: [PATCH] sns_topic - Fix bug when used in GovCloud - issue 836 (#1195) SUMMARY Add region detection to skip usage of FIFO topics when using GovCloud regions Fixes #836 ISSUE TYPE Bugfix Pull Request COMPONENT NAME community.aws.sns_topic * * Add endpoint detection to skip usage of FIFO topics for GovCloud regions * * Remove GovCloud hack for FIFO topics * Update plugins/modules/sns_topic.py * Update plugins/modules/sns_topic.py * minor docs tweak --- sns_topic.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sns_topic.py b/sns_topic.py index 9755450c455..561c9d615c4 100644 --- a/sns_topic.py +++ b/sns_topic.py @@ -26,8 +26,11 @@ type: str topic_type: description: - - The type of topic that should be created. Either Standard for FIFO (first-in, first-out) - choices: ['standard', 'fifo'] + - The type of topic that should be created. Either Standard for FIFO (first-in, first-out). + - Some regions, including GovCloud regions do not support FIFO topics. + Use a default value of 'standard' or omit the option if the region + does not support FIFO topics. + choices: ["standard", "fifo"] default: 'standard' type: str version_added: 2.0.0 @@ -363,9 +366,11 @@ def __init__(self, self.attributes_set = [] def _create_topic(self): - attributes = {'FifoTopic': 'false'} + attributes = {} tags = [] + # NOTE: Never set FifoTopic = False. Some regions (including GovCloud) + # don't support the attribute being set, even to False. if self.topic_type == 'fifo': attributes['FifoTopic'] = 'true' if not self.name.endswith('.fifo'): @@ -373,7 +378,9 @@ def _create_topic(self): if not self.check_mode: try: - response = self.connection.create_topic(Name=self.name, Attributes=attributes, Tags=tags) + response = self.connection.create_topic(Name=self.name, + Attributes=attributes, + Tags=tags) except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: self.module.fail_json_aws(e, msg="Couldn't create topic %s" % self.name) self.topic_arn = response['TopicArn'] @@ -506,7 +513,6 @@ def ensure_gone(self): def main(): - # We're kinda stuck with CamelCase here, it would be nice to switch to # snake_case, but we'd need to purge out the alias entries http_retry_args = dict(