Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

SNS Support #332

Merged
merged 15 commits into from Jun 14, 2017
Merged

SNS Support #332

merged 15 commits into from Jun 14, 2017

Conversation

uberblah
Copy link

@uberblah uberblah commented May 8, 2017

This PR adds support for SNS Topics and Subscriptions

Please see "topic_arns" in sns_topic.rb for an example of paging AWS results to ensure arbitrary numbers of resources can be imported.

def subscriptions
subscription_arns.map do |subscription_arn|
# check explicitly for an issue with some subscriptions that returns ARN=PendingConfirmation
if subscription_arn == "PendingConfirmation" then next end
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||. :ref

resp = @client.list_subscriptions(next_token: token)
arns += resp.subscriptions.map(&:subscription_arn).flatten
token = resp.next_token
end until token.nil?
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Use Kernel#loop with break rather than begin/end/until(or while). :ref

resp = @client.list_topics(next_token: token)
arns += resp.topics.map(&:topic_arn).flatten
token = resp.next_token
end until token.nil?
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Use Kernel#loop with break rather than begin/end/until(or while). :ref


module Terraforming
module Resource
describe SNSTopicSubscription do
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Block has too many lines. [57/25]


module Terraforming
module Resource
describe SNSTopic do
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Block has too many lines. [103/25]

client.stub_responses(:get_topic_attributes, attributes: attributes)
end

describe ".tf" do
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Block has too many lines. [56/25]

@coveralls
Copy link

coveralls commented May 8, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 7ba1108 on uberblah:sns into 918540b on dtan4:master.

@coveralls
Copy link

coveralls commented May 8, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 19506c0 on uberblah:sns into 918540b on dtan4:master.

@uberblah
Copy link
Author

uberblah commented May 8, 2017

Let me know if these large block comments from Rubocop are really important, but for now I'm assuming they aren't a huge deal within tests, since tests for other resources have comparably-sized blocks

@coveralls
Copy link

coveralls commented May 8, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 4ddb5e0 on uberblah:sns into 918540b on dtan4:master.

@coveralls
Copy link

coveralls commented May 8, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 479c05f on uberblah:sns into 918540b on dtan4:master.

@uberblah uberblah changed the title SNS Support, suggestions for paged request handling SNS Support May 14, 2017
@dtan4
Copy link
Owner

dtan4 commented Jun 1, 2017

Sorry for late review 🙇

SNS Topics snst works well, but SNS Topic Subscriptions snss does not.

One of our SNS Topic Subscription uses email protocol. However, Terraform does not support email protocol.
See: https://www.terraform.io/docs/providers/aws/r/sns_topic_subscription.html#protocols-supported

resource "aws_sns_topic_subscription" "xxx" {
  topic_arn                       = "arn:aws:sns:ap-northeast-1:xxx:dev"
  protocol                        = "email"
  endpoint                        = "xxx@example.com"
  raw_message_delivery            = "false"
}
$ terraform plan
1 error(s) occurred:

* aws_sns_topic_subscription.xxx: Unsupported protocol (email) for SNS Topic

I have a suggestion 💡 if a SNS subscription uses email or another unsupported protocol...

  • do not generate tfstate for the resource
  • generate tf for the resource as comment

end

def tfstate
subscriptions.reject{|x| x["Protocol"].include?("email")}
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Space missing to the left of {.
  • Space between { and | missing.
  • Space missing inside }.

@coveralls
Copy link

coveralls commented Jun 2, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 260db3d on uberblah:sns into 918540b on dtan4:master.

@coveralls
Copy link

coveralls commented Jun 2, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 1d7fd3d on uberblah:sns into 918540b on dtan4:master.

@coveralls
Copy link

coveralls commented Jun 2, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 30facaf on uberblah:sns into 918540b on dtan4:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 30facaf on uberblah:sns into 918540b on dtan4:master.


module Terraforming
module Resource
describe SNSTopicSubscription do
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Block has too many lines. [81/25]

@coveralls
Copy link

coveralls commented Jun 2, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 23e1a32 on uberblah:sns into 918540b on dtan4:master.

@uberblah
Copy link
Author

uberblah commented Jun 2, 2017

I can't see what's going on in the SideCI tests, so I can't tell why that's failing but everything on my end appears to work properly... Let me know if this update helped. Should now produce no tfstate and commented tf. Thanks for the advice! @dtan4

@dtan4
Copy link
Owner

dtan4 commented Jun 14, 2017

SideCI says the lines of method exceeds threshold... but it's not a important issue. You can ignore it.
(I'll remove this check asap...)

I checked the behavior again with the latest patch, and it suceeded!
LGTM 👍 Thanks ❗️

@dtan4 dtan4 merged commit 8061079 into dtan4:master Jun 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants