Makes Creating SNS topics idempotent (#1324)

Make creating SNS topics idempotent

Closes #1323
This commit is contained in:
Adam Gilman 2017-11-06 19:06:55 +00:00 committed by Jack Danger
commit d0a285536d
2 changed files with 29 additions and 3 deletions

View file

@ -193,9 +193,12 @@ class SNSBackend(BaseBackend):
self.sms_attributes.update(attrs)
def create_topic(self, name):
topic = Topic(name, self)
self.topics[topic.arn] = topic
return topic
candidate_topic = Topic(name, self)
if candidate_topic.arn in self.topics:
return self.topics[candidate_topic.arn]
else:
self.topics[candidate_topic.arn] = candidate_topic
return candidate_topic
def _get_values_nexttoken(self, values_map, next_token=None):
if next_token is None: