The ListTopics method is used to fetch upto 100 SNS topics at a time until a SNS topic with an TopicArn that matches topicName is found.
public Topic FindTopic(string topicName) { var nextToken = string.Empty; do { var response = this.ListTopics(new ListTopicsRequest { NextToken = nextToken }); var matchedTopic = response.Topics.FirstOrDefault(x => TopicNameMatcher(x.TopicArn, topicName)); if (matchedTopic != null) { return matchedTopic; } nextToken = response.NextToken; } while (!string.IsNullOrEmpty(nextToken)); return null; } #endregion
public void DeleteTopic(string topicName) { using (var client = new AmazonSimpleNotificationServiceClient()) { var topic = client.FindTopic(topicName); client.DeleteTopic(topic.TopicArn); } }