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

Support cross-region SNS topic subscription #71

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kaorimatz
Copy link
Contributor

I would like to support subscribing a topic in a different region from the SQS queue.

I came up with a few options:

  1. Select a region from all regions first and then select a topic from the list of topics in the region
  2. Input the ARN of the topic to subscribe directly
  3. Select a topic from all topics in the regions configured beforehand

This is an implementation of the third option, which involves no change in UI.

@kaorimatz kaorimatz force-pushed the support-cross-region-sns-topic-subscription branch from 9d90b0e to d87ddde Compare July 6, 2018 18:20
@kaorimatz
Copy link
Contributor Author

Please let me know if you think I should take another option (or this request is not acceptable in the first place 😂 ).

@riseshia
Copy link
Contributor

cc @cookpad/dev-infra

@@ -44,6 +46,12 @@ def destroy
private

def fetch_sns_topic_arns
Barbeque::SNSSubscriptionService.sns_client.list_topics.topics.map(&:topic_arn)
if Barbeque.config.sns_regions.empty?
Aws::SNS::Client.new.list_topics.topics.map(&:topic_arn)
Copy link
Member

Choose a reason for hiding this comment

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

Aws::SNS::Clinet should be memoized because Aws::SNS::Client.new retrieves credentials each time when ECS task role or EC2 instance profile is available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

06d3a6c

Copy link
Contributor Author

Choose a reason for hiding this comment

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

2a14998 (revised commit comment 💦 )

@@ -7,5 +7,9 @@ class SNSSubscription < ApplicationRecord
validates :topic_arn,
uniqueness: { scope: :job_queue, message: 'should be set with only one queue' },
presence: true

def region
/\Aarn:aws:sns:([a-z0-9-]+):/.match(topic_arn)[1]
Copy link
Member

Choose a reason for hiding this comment

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

(nit) /\Aarn:aws:sns:([a-z0-9-]+):/.slice(topic_arn, 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

0a81ea7

@kaorimatz kaorimatz force-pushed the support-cross-region-sns-topic-subscription branch from 06d3a6c to 2a14998 Compare July 11, 2018 06:40
@riseshia
Copy link
Contributor

FYI conflicted ;)

@kaorimatz kaorimatz force-pushed the support-cross-region-sns-topic-subscription branch from 2a14998 to f581ea6 Compare July 16, 2018 08:23
@kaorimatz
Copy link
Contributor Author

Thanks, rebased ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants