Created
November 11, 2011 01:19
-
-
Save amscotti/1356844 to your computer and use it in GitHub Desktop.
This is a sample file for AWS-SDK gem that uses the Amazon Simple Notification Service. - http://www.128bitstudios.com/2011/11/10/playing-around-with-amazon-sns-in-ruby/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.expand_path(File.dirname(__FILE__) + '/../samples_config') | |
# Topic's arn can be found in AWS Management, under Topic Details. | |
(topic_arn, message) = ARGV | |
unless topic_arn && message | |
puts "Usage: upload.rb <TOPIC_ARN> <MESSAGE>" | |
exit 1 | |
end | |
# Get an instance of the SNS interface using the default configuration | |
sns = AWS::SNS.new | |
# Find the topic by using the topic's arn | |
t = sns.topics[topic_arn] | |
puts "Now publishing to '#{t.name}' topic the following message:" | |
puts "\"#{message}\"" | |
# Publish the message to the topic | |
t.publish(message) | |
puts "\nMessage published" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment