Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify region when publishing to an SNS topic using AWS SDK for Ruby

I am publishing a message to and AWS SNS topic from a Rails 3 application using the AWS SDK for Ruby as below:

sns = AWS::SNS.new
topic = sns.topics['arn:aws:sns:eu-west-1:55555555555:my_topic']
topic.publish("MESSAGE", :subject => "SUBJECT")

When I publish to a topic in "us-east-1" it works as expected, but publishing to a topic in region "eu-west-1" does not work throwing:

AWS::SNS::Errors::InvalidParameter - Invalid parameter: TopicArn:

With the AWS SDK for Java set the region when creating the client object. Is there a similar way to set the region with the AWS SDK for Ruby?

like image 364
ljcundiff Avatar asked Jan 17 '14 20:01

ljcundiff


People also ask

Can SNS publish cross region?

Amazon SNS supports cross-region deliveries, both for Regions that are enabled by default and for opt-in Regions.

How do I publish AWS SNS?

To publish messages to Amazon SNS topics using the AWS Management Console. Sign in to the Amazon SNS console . In the left navigation pane, choose Topics. On the Topics page, select a topic, and then choose Publish message.

Can you publish a message to an SNS topic using an AWS Lambda function backed by Python?

The AWS Lambda function receives the message as an input parameter. It can manipulate the information in the message, publish the message to other Amazon SNS topics, or send the message to other AWS services. Log in to your AWS account and go to the Amazon SNS console.

Can SQS subscribe to SNS in different account?

Sending Amazon SNS messages to an Amazon SQS queue in a different account. You can publish a notification to an Amazon SNS topic with one or more subscriptions to Amazon SQS queues in another account.


1 Answers

Yes, in your AWS config which you can either pass in with your config intializer script

:region => 'eu-west-1'

Or create it in a file with your accesskey etc and pass the whole file in when newing up your api client

sns = AWS::SNS.new configFile
like image 74
bennie j Avatar answered Oct 19 '22 17:10

bennie j