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

SNS confirm_subscription raising error #523

Closed
jwarchol opened this issue Apr 26, 2014 · 2 comments
Closed

SNS confirm_subscription raising error #523

jwarchol opened this issue Apr 26, 2014 · 2 comments

Comments

@jwarchol
Copy link

I'm trying to determine if an error I'm seeing is caused by my code (most likely) or in the SNS code of this gem. I've got a working AWS::SNS::Client (I can list topics, etc), and I've added an new subscription via the web console with an HTTP endpoint. I've created a new AWS::SNS::Message from the body of the posted in confirmation, and when I try to use the lib to confirm the subscription I get this error:

AWS::SNS::Errors::InvalidParameter: Invalid parameter: Topic

Where c is the client, and a is the message, here is how i'm calling it:

>> c.confirm_subscription topic_arn: a.topic_arn, token: a.token
[AWS SNS 400 0.328125 0 retries] confirm_subscription(:token=>"23....8b65",:topic_arn=>"arn:aws:sns:us-west-1:3.....1:testing-jw") AWS::SNS::Errors::InvalidParameter Invalid parameter: Topic

AWS::SNS::Errors::InvalidParameter: Invalid parameter: Topic
        from /Users/joshua/.rvm/gems/ruby-2.0.0-p247/gems/aws-sdk-1.39.0/lib/aws/core/client.rb:374:in `return_or_raise'
        from /Users/joshua/.rvm/gems/ruby-2.0.0-p247/gems/aws-sdk-1.39.0/lib/aws/core/client.rb:475:in `client_request'
        from (eval):3:in `confirm_subscription'
        from (irb):30

Which seems correct from my reading of the docs. Has anyone else had problems confirming subscriptions in this way? I'd prefer to use this method rather than independently making an HTTP call to the message's subscription_url.

Ruby 2.1.1
aws-sdk gem 1.39.0

@trevorrowe
Copy link
Member

Your stack trace indicates this error is being retuned from SNS and is not a client-side validation error. Given the message indicates the topic (or rather the topic arn) is invalid, my best guess is that you are connecting to one region and attmpeing to confirm a subscription to a topic in a different region.

You can verify this with the following:

# my guess at the cause of the error
c.config.sns_endpoint
#=> "sns.us-east-1.amazonaws.com"

If the endpoint returned has a different region than the topic arn that is likely the cause. The arn above indicates you are using us-west-1. The Ruby v1 SDK defaults to us-east-1. You would need to create the client with the appropriate region (you may need to extract this region from the arn):

c = AWS::SNS::Client.new(region:'us-west-1')

Let me know if this helps or not.

@jwarchol
Copy link
Author

Thank you, I think that was it exactly. What confused me was that I was able to list topics and saw the right number. Turns out I have two topics in us-east-1 that I'd never really used myself (SES related, and billing alerts) and it coincidentally matched the number in us-west-1. When I configured the client properly it all worked.

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

No branches or pull requests

2 participants