github/github-services — pull request #547 by paxan (2013-03-13 00:27:17+00:00)
Title: Allow payload to be published via AWS SNS with least amount of privileges

## Before this fix

In order to use this hook with an AWS account, you have to use credentials (access key and secret key) that are imbued with privileges: `sns:CreateTopic` and `sns:Publish`

## After this fix

The fact that `sns_topic` is set to a topic ARN (e.g. `arn:aws:sns:us-east-1:111222333444:some-topic`) is used as a hint that we **know** what topic to use, instead of implying that we want it created in case it doesn't exist.

So, in such cases, no topic creation is attempted at all. Instead a "publish" action is done straight against the ARN specified.

As a result, the AWS credentials you specify need only to have `sns:Publish` for the given topic ARN and nothing else.

## Caveat

I wasn't able to follow instructions on testing this locally. Please help.

I tried:

```sh
$ bundle exec ruby -r config/load.rb -r services/amazon_sns.rb \
-e "Service::AmazonSNS.new(:push, {}).receive_push"
ruby: no such file to load -- services/amazon_sns.rb (LoadError)
```

But the unit tests pass just fine:

```sh
$ rake test
(in /Users/pavel/src/github_services)
/opt/boxen/rbenv/versions/1.8.7-p358/bin/ruby -I"lib:lib:test" "/Users/pavel/src/github_services/vendor/bundle/ruby/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/active_collab_test.rb" "test/acunote_test.rb" "test/agile_bench_test.rb" "test/agilezen_test.rb" "test/amazon_sns_test.rb" "test/apoio_test.rb" "test/appharbor_test.rb" "test/asana_test.rb" "test/backlog_test.rb" "test/bamboo_test.rb" "test/basecamp_classic_test.rb" "test/basecamp_test.rb" "test/boxcar_test.rb" "test/buddycloud_test.rb" "test/bugherd_test.rb" "test/bugly_test.rb" "test/bugzilla_test.rb" "test/campfire_test.rb" "test/cia_test.rb" "test/codeclimate_test.rb" "test/CodePorting-C#2Java_test.rb" "test/codeship_test.rb" "test/coffeedocinfo_test.rb" "test/conductor_test.rb" "test/coop_test.rb" "test/copperegg_test.rb" "test/cube_test.rb" "test/depending_test.rb" "test/deploy_hq_test.rb" "test/ducksboard_test.rb" "test/email_test.rb" "test/firebase_test.rb" "test/fisheye_test.rb" "test/flowdock_test.rb" "test/fog_bugz_test.rb" "test/freckle_test.rb" "test/friend_feed_test.rb" "test/gemini_test.rb" "test/gemnasium_test.rb" "test/geocommit_test.rb" "test/get_localization_test.rb" "test/git_live_test.rb" "test/grmble_test.rb" "test/group_talent_test.rb" "test/grove_test.rb" "test/habitualist_test.rb" "test/hall_test.rb" "test/harvest_test.rb" "test/hip_chat_test.rb" "test/hubcap_test.rb" "test/humbug_test.rb" "test/icescrum_test.rb" "test/irc_test.rb" "test/irker_test.rb" "test/jabber_test.rb" "test/jaconda_test.rb" "test/jenkins_git_test.rb" "test/jenkins_github_test.rb" "test/jira_test.rb" "test/jquery_plugins_test.rb" "test/kanbanery_test.rb" "test/kickoff_test.rb" "test/leanto_test.rb" "test/lighthouse_test.rb" "test/lingohub_test.rb" "test/loggly_test.rb" "test/mantis_bt_test.rb" "test/masterbranch_test.rb" "test/mqtt_test.rb" "test/nodeci_test.rb" "test/nodejitsu_test.rb" "test/notifo_test.rb" "test/notifymyandroid_test.rb" "test/ontime_test.rb" "test/pachube_test.rb" "test/packagist_test.rb" "test/pivotal_tracker_test.rb" "test/planbox_test.rb" "test/planio_test.rb" "test/presently_test.rb" "test/prowl_test.rb" "test/puppetlinter_test.rb" "test/push_test.rb" "test/pushover_test.rb" "test/pythonpackages_test.rb" "test/rails_brakeman_test.rb" "test/railsbp_test.rb" "test/rally_test.rb" "test/rapidpush_test.rb" "test/rational_team_concert_test.rb" "test/rdocinfo_test.rb" "test/read_the_docs_test.rb" "test/redmine_test.rb" "test/rubyforge_test.rb" "test/schema_test.rb" "test/scrumdo_test.rb" "test/service_test.rb" "test/shiningpanda_test.rb" "test/slatebox_test.rb" "test/socialcast_test.rb" "test/softlayer_messaging_test.rb" "test/sourcemint_test.rb" "test/splendid_bacon_test.rb" "test/sprintly_test.rb" "test/sqs_queue_test.rb" "test/stackmob_test.rb" "test/statusnet_test.rb" "test/talker_test.rb" "test/target_process_test.rb" "test/teamcity_test.rb" "test/tender_test.rb" "test/tenxer_test.rb" "test/test_pilot_test.rb" "test/toggl_test.rb" "test/trac_test.rb" "test/trajectory_test.rb" "test/travis_test.rb" "test/trello_test.rb" "test/twilio_test.rb" "test/twitter_test.rb" "test/unfuddle_test.rb" "test/web_test.rb" "test/web_translate_it_test.rb" "test/weblate_test.rb" "test/yammer_test.rb" "test/youtrack_test.rb" "test/zendesk_test.rb" "test/zohoprojects_test.rb"
Loaded suite /Users/pavel/src/github_services/vendor/bundle/ruby/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Finished in 1.268328 seconds.
```