Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SNS topics #1952

Closed
wants to merge 4 commits into from
Closed

Conversation

ctiwald
Copy link
Contributor

@ctiwald ctiwald commented May 13, 2015

Chips away at #28. This would have been the simplest thing in the world to do were it not for one, uh, feature of the SNS API. There is no way to describe or filter for an individual topic.

Instead, you have to page results back from a complete topic list, and unlike autoscaling groups (whose paging limit is something like 1600), the paging limit for SNS topics is 100. I didn't feel right not supporting result paging here; it's entirely possible a TF user could have more than 100 SNS topics if they really love the product, so I wrote a pager.

The file is sns_topic_seeker.go and implements a basic state machine whose design will look mighty familiar if you've ever seen this presentation by Rob Pike or read the source code to text/template/parse/lex.go in the stdlib. It's basically a slimmed down implementation of the same pattern, and I've covered it with a bunch of unit tests to make sure it works and works well.

For what it's worth, I think it could be abstracted to an interface and used to "page" anything in AWS that returns a NextToken, but I didn't want to build a generalized version if this is the only AWS resource that'll use it.

Anyway, let me know if there are any problems here. I'm going to add SNS topic support to AS groups too per #1419, but that file's a bit complex and I didn't feel like biting it off quite yet. I need it though so I'll try to finish it off later this week.

@@ -0,0 +1,104 @@
package aws
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this file should be actually called resource_ since it's not really a resource with its own schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Easy fix. One moment.

ctiwald added 3 commits May 13, 2015 16:43
This is a cut and dry resource addition with one exception: There's no
way to describe or filter for a single topic in the AWS API. Callers
must paginate their response every 100 topics, and match on a known ARN.

So, implement an SNS topic seeker. This is a fairly simple state
machine based on Rob Pike's "Lexical Scanning in Go" presentation:

http://cuddle.googlecode.com/hg/talk/lex.html#title-slide
@ctiwald
Copy link
Contributor Author

ctiwald commented May 16, 2015

Self-closing this in favor of #1974. It adds more support and uses a GetTopicAttributes call I wasn't aware of to better flesh out the topic's computed properties.

@ctiwald ctiwald closed this May 16, 2015
@catsby
Copy link
Contributor

catsby commented May 18, 2015

Thanks for the follow up @ctiwald , I'll see about getting #1974 merged this week!

@ghost
Copy link

ghost commented May 2, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants